joan2937 / pigpio

pigpio is a C library for the Raspberry which allows control of the General Purpose Input Outputs (GPIO).
The Unlicense
1.45k stars 406 forks source link

gpioHardwarePWM() pins and channel ? #213

Closed Pluscrafter closed 4 years ago

Pluscrafter commented 6 years ago

Is that right, that you only can use the pins 12,13,18,19 for HardwarePWM and are the pins 12,18/13,19 connected together ?

joan2937 commented 6 years ago

As far as I am aware the information at http://abyz.me.uk/rpi/pigpio/cif.html#gpioHardwarePWM is correct.

For the Pis with the 40 pin expansion header you can route hardware PWM to 12/13/18/19. 12/18 may be connected to PWM channel 0, 13/19 may be connected to PWM channel 1.

Of course you can use pigpio standard PWM on GPIO 0-31. This is hardware timed but has a restricted set of frequencies and less dutycycle resolution.

Pluscrafter commented 6 years ago

I've tried that, but it has too much jitter and I've found, that I can use a pwm driver like that PCA9685, but this has too many outputs for my project and is there a pwm driver with only 4-6 outputs with 12bit resolution?

guymcswain commented 6 years ago

The jitter issue on pigpio generated pwm has come up before. Has anyone tried registering the pwm outputs to an external D-type flip flop using the pwm/pcm peripheral clock on the half phase? Octal DFF devices are pretty cheap.

joan2937 commented 6 years ago

What are you driving?

I have only noticed jitter when I sample at 1MHz. That hammers the DMA bus with traffic. I have not noticed jitter at lower sampling rates.

Of course jitter will be present, I'm just wondering if you can quantify the degree.

Pluscrafter commented 6 years ago

I've connected one esc to the raspi and set gpioCfgClock(1,0,0); then I've set the samplerate to 250Hz and the resolution to 4000, witch is the max realResolution. Then I've control bldc motor with a pulse between 1000us and 2000us. when the throttle is at the lowest postiton the motor is shaking a little bit, but with hardwarepwm the the motor stops with 0% throttle and the motorspeed was stable.

Pluscrafter commented 6 years ago

I also noticed that a servo shake at the 0 position with a dutycycle of only 50Hz.

guymcswain commented 6 years ago

Have you tried gpioCfgClock(5,0,0)?

Pluscrafter commented 6 years ago

yes but it also shake. But when I increment the values a little bit the servo is stable, but not 100% in the 0 degree position.

joan2937 commented 6 years ago

Is this a continuous rotation servo? If so that sounds like a dead band calibration problem.

Pluscrafter commented 6 years ago

no. Thats also the problem with my esc in the 0 Position it shakes a little bit, but with a little bit of throttle is has a stable rotation.