Out of the box support for AS5048

Are there any features that you would like to add to the VESC?
dpetrillo
Posts: 25
Joined: 24 Dec 2015, 01:47

Out of the box support for AS5048

Postby dpetrillo » 26 Jan 2016, 16:23

I'd like to see support for the AS5048 encoder added to the config tool.

http://ams.com/eng/Products/Position-Se ... rs/AS5048A

It's a popular choice for Gimbal motors and could be useful for robotics applications.

Dave

benjamin
Site Admin
Posts: 280
Joined: 15 Dec 2015, 08:38
Location: Sweden
Contact:

Re: Out of the box support for AS5048

Postby benjamin » 27 Jan 2016, 09:37

I have actually ordered an AS5047 and a small PCB for it is on its way, so I'm going to implement support for that soon. I also think that these sensors are nice as they are easy to mount and don't require running the motor to an index pulse first.

hexakopter
Posts: 86
Joined: 24 Dec 2015, 15:24
Location: Germany

Re: Out of the box support for AS5048

Postby hexakopter » 27 Jan 2016, 12:28

What AS5047 do you mean? There is the AS5047P and the AS5047D. The datasheet says that the P version is for "High speed application" so I think you will use the P.
Is the AS5048 not fast enough or why going with the AS5048? Think the AS5048 is better available than the AS5047.

GvB
Posts: 8
Joined: 15 Sep 2017, 20:39
Location: Eindhoven

Re: Out of the box support for AS5048

Postby GvB » 11 Jan 2018, 12:44

My as5048 reads position between 180 and 360 really well but not from 0-180 degrees.
I tried on two vesc's but same. The data coming from AS5047 is clean. When I rotate motor by hand 1 full rotation the position ends up at exact position in BLDC tool, it just skips from 360 to 180 and then up again.
As a result using position control under 180 does not work. between 180 and 360 works perfect.
What am I doing wrong?

ThierryGTLTS
Posts: 85
Joined: 09 Aug 2017, 11:10

Re: Out of the box support for AS5048

Postby ThierryGTLTS » 11 Jan 2018, 17:50

Do you use Digital or PWM output :?: :!:

Thierry

GvB
Posts: 8
Joined: 15 Sep 2017, 20:39
Location: Eindhoven

Re: Out of the box support for AS5048

Postby GvB » 11 Jan 2018, 18:38

Digital

GvB
Posts: 8
Joined: 15 Sep 2017, 20:39
Location: Eindhoven

Re: Out of the box support for AS5048

Postby GvB » 11 Jan 2018, 18:44

Just found other people with same problem on other forum:
I have the same problem with data range. Only 8192 - 16383 values are available.
Does someone knows where is the problem?

Their solution was
But more importantly you need to set the right SPI mode, this chip uses falling clock edge,
not the more usual rising edge.
looks like you need:
SPI.setDataMode (SPI_MODE1) ;

Over here :https://forum.arduino.cc/index.php?topic=155238.0

GvB
Posts: 8
Joined: 15 Sep 2017, 20:39
Location: Eindhoven

Re: Out of the box support for AS5048

Postby GvB » 12 Jan 2018, 13:03

Someone using AS5048 and trying to do position control that has the same problem / has a solution?

pf26
Posts: 289
Joined: 28 Mar 2016, 14:37
Location: FR Valence

Re: Out of the box support for AS5048

Postby pf26 » 13 Jan 2018, 16:16

I think the AS5047 support uses a software SPI, in encoder.c :
The MISO ReadPad is done after the SCK SetPad, when it probably should only occur after the SCK ClearPad

Code: Select all

static void spi_transfer(uint16_t *in_buf, const uint16_t *out_buf, int length) {
   for (int i = 0;i < length;i++) {
      uint16_t send = out_buf ? out_buf[i] : 0xFFFF;
      uint16_t recieve = 0;

      for (int bit = 0;bit < 16;bit++) {
         //palWritePad(HW_SPI_PORT_MOSI, HW_SPI_PIN_MOSI, send >> 15);
         send <<= 1;

         spi_delay();
         palSetPad(SPI_SW_SCK_GPIO, SPI_SW_SCK_PIN);
         spi_delay();
         
         palClearPad(SPI_SW_SCK_GPIO, SPI_SW_SCK_PIN);   // Moved before MISO Read
         spi_delay();
         
         recieve <<= 1;
         if (palReadPad(SPI_SW_MISO_GPIO, SPI_SW_MISO_PIN)) {
            recieve |= 1;
         }
      }

      if (in_buf) {
         in_buf[i] = recieve;
      }
   }
}

I haven't tried , and I don't use AS5047/5048, so I cannot test for you. I am interested to know if it works though, because I am fullt happy with the AMT103 I currently use instead.

raess
Posts: 1
Joined: 02 Apr 2018, 22:32
Location: sweden
Contact:

Re: Out of the box support for AS5048

Postby raess » 02 Apr 2018, 22:45

I also have the same problem with the AS5048A and the AS5047D.
they reads position between 180 and 360 very well and not at all 0-180.

I have tried to compile the latest FW with your suggestions pf26 but that had no effect on the outcome of the readings.

Code: Select all

// Software SPI
static void spi_transfer(uint16_t *in_buf, const uint16_t *out_buf, int length) {
   for (int i = 0;i < length;i++) {
      uint16_t send = out_buf ? out_buf[i] : 0xFFFF;
      uint16_t recieve = 0;

      for (int bit = 0;bit < 16;bit++) {
         //palWritePad(HW_SPI_PORT_MOSI, HW_SPI_PIN_MOSI, send >> 15);
         send <<= 1;

         spi_delay();
         palSetPad(SPI_SW_SCK_GPIO, SPI_SW_SCK_PIN);
         spi_delay();
         
         palClearPad(SPI_SW_SCK_GPIO, SPI_SW_SCK_PIN); // Moved before MISO Read
         spi_delay();

         int r1, r2, r3;
         r1 = palReadPad(SPI_SW_MISO_GPIO, SPI_SW_MISO_PIN);
         __NOP();
         r2 = palReadPad(SPI_SW_MISO_GPIO, SPI_SW_MISO_PIN);
         __NOP();
         r3 = palReadPad(SPI_SW_MISO_GPIO, SPI_SW_MISO_PIN);

         recieve <<= 1;
         if (utils_middle_of_3_int(r1, r2, r3)) {
            recieve |= 1;
         }
      }

      if (in_buf) {
         in_buf[i] = recieve;
      }
   }
}



However The AS5047D did support ABI interface and that worked very well, reading 0-360 degrees perfectly.

I am also going to try the AS5047P tomorrow and see how that works.

Any other suggestions on how to get this encoders working at 0-360degreess with SPI?

The Encoders are connected SPI as below (the pin position is for the AS5048A)

Code: Select all

SCL/SCK (P1-5) -> HALL 1
A2/MISO (P1-7) -> HALL 2
A1/MOSI (P1-6) -> VCC
SDA/CSn (P1-4) -> HALL 3
GND (P1-8) -> GND
VCC (P1-1) > VCC


IMG_2725.jpg
IMG_2725.jpg (110.07 KiB) Viewed 597 times



thanks Robin


Return to “Feature Requests”

Who is online

Users browsing this forum: No registered users and 3 guests