Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using PWM output as servo control signal (1ms to 2ms pulse) corresponding to 0-100% set point #99

Closed
HardSoftMus opened this issue Mar 7, 2022 · 13 comments

Comments

@HardSoftMus
Copy link

It would be very interesting to have a "modified" PWM output for controlling mechanical servos.
It sould generate a PWM pulse of about 50Hz with an "on" time varying from 1ms to 2ms when the parameter goes from 0% to 100%

This opens a new world of oportunities for controlling a lot of common mechanic devices (venetian curtains, AC grids...)
There are a lot of powerful servos out there, moving up to 50kg/cm force that could be used, like these:

https://es.aliexpress.com/item/1005003352672567.html?spm=a2g0o.productlist.0.0.2cc75d4aZgOwbA&algo_pvid=f67a634b-9e75-451a-9402-b8f1044549b0&algo_exp_id=f67a634b-9e75-451a-9402-b8f1044549b0-4&pdp_ext_f=%7B"sku_id"%3A"12000025360895100"%7D&pdp_pi=-1%3B50.28%3B-1%3B-1%40salePrice%3BEUR%3Bsearch-mainSearch
https://es.aliexpress.com/item/725115447.html?spm=a2g0o.productlist.0.0.2cc75d4aZgOwbA&algo_pvid=f67a634b-9e75-451a-9402-b8f1044549b0&aem_p4p_detail=202203071451144733336428780000003821898&algo_exp_id=f67a634b-9e75-451a-9402-b8f1044549b0-0&pdp_ext_f=%7B"sku_id"%3A"66461318699"%7D&pdp_pi=-1%3B32.81%3B-1%3B-1%40salePrice%3BEUR%3Bsearch-mainSearch

Thank you very much for your wonderful software.
Best regards

@ptvoinfo
Copy link
Owner

What do you mean by ""on" time varying from 1ms to 2ms"?

@HardSoftMus
Copy link
Author

HardSoftMus commented Mar 12, 2022 via email

@LenirSantiago
Copy link

I could definitely use this feature!!!!!

To be able to control a Servo using PWM just like ATMEGA chips can would be ideal.

Right now the only solution is to use the PCA9685 with adds unnecessary costs to a project, especially when you only need one or two Servos.

@ptvoinfo
Copy link
Owner

ptvoinfo commented Nov 4, 2022

I've tested low frequency PWM output that is available in the Premium version with MG90S, and it works well at 120 Hz. The main disadvantage is you cannot use the full range of the PWM output. The servo accepts impulses in the range from 20 to 79.

@HardSoftMus
Copy link
Author

HardSoftMus commented Nov 4, 2022 via email

@LenirSantiago
Copy link

I've tested low frequency PWM output that is available in the Premium version with MG90S, and it works well at 120 Hz. The main disadvantage is you cannot use the full range of the PWM output. The servo accepts impulses in the range from 20 to 79.

The reason that it only accepts 20 to 79 may be because the servos need a PWM signal at 50Hz, not 120Hz. I believe this is the case for most servos in the market.

Could you retest using 50Hz?

@LenirSantiago
Copy link

Or perhaps looking at the Servo class for Arduino. Here are some good references:
https://gist.github.com/ajfisher/8c5146bff264b88d04cc
https://github.com/arduino-libraries/Servo

@HardSoftMus
Copy link
Author

HardSoftMus commented Dec 11, 2022 via email

@ptvoinfo
Copy link
Owner

@LenirSantiago With the 50Hz frequency, this range (20 - 79) is rather narrow. I don't know the precise numbers, but in my case, 120 Hz provides more smooth control.

@HardSoftMus
Copy link
Author

HardSoftMus commented Dec 12, 2022 via email

@LenirSantiago
Copy link

@LenirSantiago With the 50Hz frequency, this range (20 - 79) is rather narrow. I don't know the precise numbers, but in my case, 120 Hz provides more smooth control.

In that case, as long as follows how servos signal works, meaning 20 is an ON pulse of 0.5ms, 50 is an ON pulse of 1.5ms and 79 is an ON pulse of 2.5ms, updating at least every 20ms, then as per @HardSoftMus it should work without causing any mechanical/electrical problems.

@LenirSantiago
Copy link

@HardSoftMus
Copy link
Author

HardSoftMus commented Dec 12, 2022 via email

ptvoinfo pushed a commit that referenced this issue Jan 13, 2023
[All chips] Added options to set minimum and maximum limits of a PWM signal (by default, 0 and 255). It can be useful if control servo motors with limited PWM pulse width (#99).
[All chips] Added an option to configure an offset (shift) for PWM outputs. It may help to control LED outputs with low sensitivity for short PWM impulses.
[All chips][LED] Added a possibility to configure RGB order for WS2812B strips (#167). By default, it is GRB.
[All chips][LED] Added support for RGBW and RGBWW modes with color temperature control (#168). Checked with the GledOpto bulb (look at the corresponding preset).
[All chips][LED] Fixed color control using Hue/Saturation commands (#163).
[All chips][LED] All LED lamps and strips, after flashing, start switched off.
[All chips][LED] All PWM control channels of RGB, RGBW or RGBWW lamps start at the same time. It prevents blinking of some LEDs when the lamp if off, and you connect power.
[СС2652] Added the SCD40/41 sensor (#81).
[СС2652][OTA] Added support for some new flash modules (#162).
[All chips] Now, you can link a rotary encoder to a LED or PWM outputs and crease a versatile dimmer device (#155).
[All chips] Other minor fixes and improvements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants