Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: Garyhlucas on September 08, 2022, 01:47:02 PM
-
I see we have PWM OUT on the BRX but not in. We have some ClearPath servos that can output torque via PWM which I suspect they did that way because they made it bidirectional. We need this for a project. Suggestion on how to read this? I am thinking two high speed inputs used as timers and then compared to get percentage range.
Thanks,
-
Can you use a High Speed Edge Timer (or Counter) along with the attached Interval Scaling?
-
If the PWM period is known and fixed, you can do it with a single HS timer and a small bit of math. It If isn't, you can do it with two timers, one rising to falling and one rising to rising, and then use some math to convert to percentage.
That's actually how I tested the PWM function. ;)
-
Yes the period is known and fixed so I?ll try the single timer because I need them for other stuff too.
Thanks,
-
Single timer works!
-
BobO
At the risk of resurrecting a zombie thread from four years ago, any chance someone can share a code snippet? I'm just not seeing how to use a single timer. I too have to monitor torque on a Teknic servo. Alternatively, a dedicated PWMIN instruction would be very helpful.
The servo can provide a PWM signal at either 45Hz or 482Hz (user selectable):
5% duty cycle = 100% peak torque, CW direction
50% duty cycle = zero torque
95% duty cycle = 100% peak torque CCW direction.
Thanks,
SceneryDriver
-
If you contact me at gary@zaicdesign.com I'll share the code we use for this.
-
If anyone sees this, I solved it - I'm always annoyed with threads that don't detail the solution. I used a high-speed timer, set to dual-edge on same input. It's measuring the time from the rising edge to the falling edge. Named $MotorTorque, and set to free-run.
The PWM signal from the Teknic servo has a known frequency of 45Hz. To get the duty cycle, I use a MATH instruction:
($MotorTorque.LastTime / 22.22) / 10 = D0
This gives me a whole-number percentage of the duty cycle of the PWM signal.
I hope this helps someone!
SceneryDriver