0

Currently I am building a tricopter which runs on nodejs and uses pi-blaster(https://github.com/sarfata/pi-blaster) I've got everything working nicely except my custom PID can't stop small oscillations. By watching and listening (to RPM difference), I came to the conclusion that the RPM of the engines only change when the values for example go from 0.128 to 0.129; when the PID gives 0.12812 for example, nothing seem to change. And this is most likely the main reason it can't get accurate stabilisation.

So I went on to investigate it more and discovered that indeed the (pi-blaster) resolution is currently limited to 3 decimals (0.000)..

This is the relevant config:

PWM frequency:                100 Hz
PWM steps:                    1000
Maximum period (100  %):      10000us
Minimum period (0.100%):      10us

If I can get a resolution (or steps) of 4 decimals (0.0000) I would probably get very nice results, a resolution of 5 would be even nicer, but I am not sure if the is possible performance-wise.

I can play around with the values but I don't really understand the underlying logic and what I am doing..

Can anyone assist me on getting the desired resolution?

Some more info:

  • the tricopter uses 3 ESC's with 3 engines
  • the gyro update loop runs at 50 times per second (20ms per update)
  • running on raspberry pi3

If you need more info please let me know.

1 Answer 1

1

pi-blaster, like servoblaster (its parent), pigpio, and RPIO.GPIO, and doubtless others, use DMA to time the PWM pulses.

For various reasons this limits the pulse width step resolution to 1µs and in practice to a minimum of 2µs steps. This means if a servo/ESC accepts values in the range 1000 to 2000 µs you could send 1000, 1002, 1004, ..., 1996, 1998, 2000.

By default I think servoblaster and pi-blaster use 10µs steps and (my) pigpio 5µs steps. I know you can configure servoblaster to use 1 or 2µs steps as can pigpio. I don't know about pi-blaster. I assume it can use the same.

For a comparison the PCA9685 hardware PWM module uses about 4.5µs steps.

If you need higher resolution (doubtful) you could use the Pi's hardware PWM for two of the servos/ESCs (there are only two channels).

2
  • Thanks for your answer @joan. So if I understand you correctly, I can change 'Minimum period (0.100%): 10us' - to for example 5us as a start and then test it down to 2us or even 1us? Commented Jun 25, 2017 at 16:46
  • edit: just tried it, it made effect after I changed the values to the following: Maximum period (100 %): 20000us (was 10000) - Minimum period (0.100%): 2us (was 10). Thanks again! Commented Jun 25, 2017 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.