Help with basic closed loop example

Hi there. I’m hoping someone can help me here because after half a day I’m at my wit’s end with this.

I have been trying to work my way through the beginner’s examples and I am completely stuck.

I have a GBM4108H-120T motor hooked up to a BGC3.1 Arduino-based board, which has a pair of L6234D controllers on it. I’m using an AS5600 magnetic sensor as the position sensor. I believe that the motor has 11 pole pairs, and this value has been entered in the code.

The sensor works fine, giving a correct angle in radians as I rotate the motor.

The motor works fine, because in the open open-loop the motor it rotates freely and slowly and steadily around.

In closed loop mode however the motor either behaves very strangely, trying to move back to it’s starting position but only sort of maybe and sometimes tries to go somewhere else, or sometimes it just goes haywire vibrating all over the place.

I am at the point of tearing my hair out because I can’t make sense of what’s going on. The example notes don’t help much because it’s not clear what behaviour I should expect from the motor in the example. Whatever it is, it’s clear that it’s not what I’m getting.

If anybody has any thoughts I’d be very grateful!!!

I’m posting an update just in case anybody’s interested.

I tried several other code examples and I kept seeing the same problem. It was as though the number of poles was wrong but only in some parts of the rotation.

I had another look at the encoder and I think I know what the problem is. The AS5600 sensor is showing a 6.28 angle increase (radians then) for every full rotation of the motor. However, 90-degree increments are: 1.29, 2.41, 3.99 and 6.28, which is not linear!

I think I’ve found the problem.

Hey @Tempest,

You might have an issue with magnet polarization.

When the motor is not connected the sensor seems to kinda work,but once the motor is connected the sensor angle is not precise enough to make for smooth operation (even any opration in most cases).

We had a lot of issues about wrongly polarized magnets with as5600 at some point last year, so you might be a bit unlucky there :smiley:

Yeah it appears to be a problem with the magnet and not the AS5600. I’ve tried with an alternate chip and I get exactly the same problem. I’m going to try a different magnet/mounting arrangement.

Try this to check the quality of the magnets. Chinese diametrically polarized magnets are notoriously poor quality.

2 Likes

Good shout.

I got in some 5mm cube neodymium magnets that weren’t made of chinesium and the encoders work just fine now.

:rofl: :joy:

Cheers,
Valentine