How should I tune an encoder for a wheelchair motor?

General discussion of using Roboclaw motor controllers
Post Reply
gannicus
Posts: 28
Joined: Sat Aug 06, 2016 4:33 am
How should I tune an encoder for a wheelchair motor?

Post by gannicus »

Hi,

I'm trying to add an Encoder to a wheelchair motor, I bought the encoder from ebay:
https://www.ebay.com.au/itm/Photoelectr ... .l4275.c10

I glued the encoder to the bottom of the motor shaft(Not gearbox shaft), I'm not too sure about the gearbox ratio, 1:30 maybe, the motor RPM is about 4500 - 4600.

After I autotuned the motor/encoder, when I trying to test, I increased the velocity to 55, but the motor just shaking instead of running smoothly, I must done something wrong.

any help will be appreciated.

This is my motor:
Image

I glued the encoder to the bottom of the motor shaft (Not gearbox shaft) like the picture below:
Image

This is my General settings:
Image

I used Autotune M1 in the velocity settings, Here is the values after tune:
Image

I set velocity to 55, but the motors just shaking instead of running smoothly, please check the video link at the bottom:
Image

https://drive.google.com/file/d/1h6WTLQ ... sp=sharing

Thanks,
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: How should I tune an encoder for a wheelchair motor?

Post by Basicmicro Support »

Make sure the encoder is reading correctly and in the correct direction. Open Ion Studio and start the motor moving forward by moving the PWM Settings motor slider UP. Make sure the encoder counts for that motor are increase in value.

Some motors the autotuner doesnt work well with. In those cases you will need to manually tune the motor. With a motor with a worm drive output there is potentially alot of backlash in the worm gear which can screw up the autotuner.

The autotuned values look very high for this motor/encoder so Im going to guess its getting garbage readings when it runs the autotune routine. Manual tuning is pretty simple though.

1. Zero the P I and D value.
2. Using the PWM Settings screen, run the motor at full speed and note the Speed displayed at the top of the screen. Set the QPPS setting in Velocity Settings to this value(doesnt need to be perfect, just in the ballpark is fine).
3. Set the P value to 1000 as a starting point. Move the motor back and forth using the Velocity Sliders. Does it move smoothly. If so, increase the P value(to 2000 for example) and retest. Repeat this, increaing the P value until it feels like the motor is running rough/vibrating. Then back the P value off to 2/3rds this value.
4. Set the I value to 1/10th the P value. Run the motor back and forth in a couple tests. make sure it runs smooth and runs at the speed set. If it runs rough, back the I value off until it runs smooth again. If it doesnt match the requested speed accurately enough, increase the I value until it does or until the motor starts feeling rough again. There will be a middle point between betst speed accuracy and lowest motor roughness/vibration.

That should be all you need to do. Once you are satisifed make sure you save the settings to the controller(Device menu/Save Settings).
gannicus
Posts: 28
Joined: Sat Aug 06, 2016 4:33 am
Re: How should I tune an encoder for a wheelchair motor?

Post by gannicus »

Thanks for your reply,

https://www.screencast.com/t/zQlBiwvl0

Please see the video above, is that looks normal? The speed seems to between -1 to maximum 6, It is changing very fast looping from -1 to 6.

If you don't have flash, here is the video file:
https://drive.google.com/file/d/1fh6c4W ... sp=sharing

And this is what it looks like in Velocity settings, is this m1 encoder and speed looking correct?
https://www.screencast.com/t/U3QQNC4MdVi5

Video file:
https://drive.google.com/file/d/1IUe3Ai ... sp=sharing
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: How should I tune an encoder for a wheelchair motor?

Post by Basicmicro Support »

No. This doesnt look right. The encoder value shouldnt bounce back and forth. It shoul;d be much faster than that.

According to your original email the motor RPM rating is around 4500. So at 41% duty(411 in your video) the motor should be turning around 2100 rpm. The encoder shown has a hundred or so slots so should have around 400 counts per single rotation. At 2100 you should see an encoder speed of around 14000 per second and the Encoder position value should be increasing by that much.

This tells me the encoder is not being read.

Some encoders require pullup resistors to operate. These are usually between 1k and 10k. For higher speeds go with lower resistor values. The pullup should go to 3.3 or 5v. Usually you can pull them up using the Roboclaws 5v but you should double check your encoder will work at 5v. My guess is it is safe to use 5v pullups.

The ebay listing has no useful information.
gannicus
Posts: 28
Joined: Sat Aug 06, 2016 4:33 am
Re: How should I tune an encoder for a wheelchair motor?

Post by gannicus »

Thanks a lot, I add a resistor to vcc, it seems helped a lot,
This is the 220 resistor I used:
Image

Added to the vcc:
Image

The encoder reading seems better, but the speed is going back and forth, is that normal? Please check the video below:
https://www.screencast.com/t/K3HxjD2GpuKV

I've also tried 1000 resistor, but the encoder reading increases even I control the motor run opposite direction.
https://www.screencast.com/t/W51zmzVKu

It seems like when I use 220 resistor the reading is correct in terms of direction, 1000 resistor reading is increase much faster(but it has no directions), I've also tried 440(no reading), 660(no reading), 1220(it has reading but the direction is not correct), 2000(no reading), at the end I tried 10K resistor it has no reading.

I Then used 220 resistor, set P to 1000, I to 100 and QPPS to 800, and when I test the motor is shaking badly.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: How should I tune an encoder for a wheelchair motor?

Post by Basicmicro Support »

This also sounds wrong. Something may be wrong with the encoder. At most a 1k resistor may be required. Never a 220ohm.

If you can, look at the signals(both channels on a oscilloscope. If you can get a screen cap of the scope that would also be helpfull.

And again, you know what the encoder counts per roation are(count the slots in the wheel, multiple by 4). That is for one rotation. Then count the number of rotations per second of the motor. Multiply that by the counts per rotation and that will tell you what you should be getting for any given movement. If its no were close(which I suspect is the case) the encoder is still not working correct(eg you need to look at this with a scope).

Ebay junk isn't uncommon. In the end you may be better off buying an encoder(or motor with encoder already on it) from a reputable company.
gannicus
Posts: 28
Joined: Sat Aug 06, 2016 4:33 am
Re: How should I tune an encoder for a wheelchair motor?

Post by gannicus »

Thanks a lot,

I think the 1000 resistor is giving more accurate reading. Is that speed going back and forth normal?

You are probably right, I should try a more decent encoder.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: How should I tune an encoder for a wheelchair motor?

Post by Basicmicro Support »

Depends by how much. If its all over the place it could indicate a problem. You should check to see if you are losing or gaining extra counts. Zero the encoder, then move the motor back and forth several times and then come back to the exact starting point. As close as you can physically get to it. If the count doesnt come back to zero(or near zero) it could indicate a problem.
gannicus
Posts: 28
Joined: Sat Aug 06, 2016 4:33 am
Re: How should I tune an encoder for a wheelchair motor?

Post by gannicus »

Ok, Thanks.
The problem I'm having now is doesn't matter I move the motor back and forth, the encoder counts always increase.

The encoder has 2 output, does it matter which output pin I plug to controller?

I will try it later.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: How should I tune an encoder for a wheelchair motor?

Post by Basicmicro Support »

1. On a quadrature encoder the arangement of the wires will dictate the direction of the count relative to the direction of the motor. Eg will it count up going forward and down going backwards or will it count down going forward and down going backwards.

2. If you encoder is only counted in one direction no matter the direction of the motor it is still not functioning correctly. You really need to see whats going on with it on a scope.

Post Reply