Driving a RC servo from Fan0 output
-
Hi!
I'm trying to drive a RC servo using the Fan0 output. I disabled it using:
M106 P0 I-1
Then drive it using:
M280 P20 S1500
But I don't get anything. Looking at the schematic, I think I need a pullup resistor on the signal pin, as the FET only switches to ground. Am I right? What value do you suggest? 10kOhm?
Thanks.
-
I suggest 1K to +5V. You will also need to invert the polarity using I1 in the M280 command.
-
Ok, thank you!
-
I have a question and a request for the M280 command, as using values below 200 set the angle, and values above 200 set the pulse duration:
-
is there a way to set the relation between the setpoint angle (value below 200) and the real pulse width sent to the servo? Or is it really hard coded to 0°/544.0µs - 180°/2400.0µs?
-
I plan to use a servo able to rotate up to 270°. With the current code, it is not possible to set its position using angle, as values above 200 are µs. Could it be possible to use distincts params to set either the angle (any value, using a relation between angle and pulse freely configurable) or the pulse width?
Thanks.
-
-
-
It's hard coded, because that's how RC servos generally behave, and to change it would mess up the values used by BLTouch.
-
I guess we could add additional parameters, but I would want the basic behaviour to remain as-is for compatibility with other 3D printer firmwares. I think I chose 200 as the cutoff angle because that's what Marlin did.
Is there any reason why you can't use microsecond values?
-
-
@dc42 said in Driving a RC servo from Fan0 output:
- It's hard coded, because that's how RC servos generally behave
I don't think all servos really use the same angle/pulse width ratios; servos I used so far all differ a little bit, so angles are always wrong. More or less, depending on the brand, and quality.
- I guess we could add additional parameters, but I would want the basic behaviour to remain as-is for compatibility with other 3D printer firmwares. I think I chose 200 as the cutoff angle because that's what Marlin did.
I understand. I propose this:
- by default, RRF uses the current ratio (0°/544µs - 180°/2400µs)
- add a param 'R' to change this ratio (for example, R800:2200 to use 0°/800µs - 180°/2200µs);
- add another param 'F' to force usage of angle or µs ('F0' to force angle, and 'F1' to force µs), so values below 200 could be µs, and values above 200 could be angles (don't limit angles in the firmware; just make the computation, even for negative angles);
Is there any reason why you can't use microsecond values?
Yes, I can, but it would be nice to be able to think in degrees, rather than µs. And it would allow me to tune things (offset...) from the config file, instead to have to change values in different places.