PWM base on node-red-contrib-gpio

1,077 views
Skip to first unread message

darlin

unread,
Oct 4, 2015, 2:27:21 PM10/4/15
to Node-RED
Which way I can use PWM base on node-red-contrib-gpio ?

Luis Montes

unread,
Oct 9, 2015, 5:21:18 PM10/9/15
to node...@googlegroups.com
This was resolved.

Needed a PWM number to be set.

Also, looks like it works on beaglebone which I hadn't tested myself.

On Sun, Oct 4, 2015 at 11:27 AM, darlin <dare...@gmail.com> wrote:
Which way I can use PWM base on node-red-contrib-gpio ?

--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

darlin

unread,
Oct 9, 2015, 6:03:14 PM10/9/15
to Node-RED
Yes, its work perfect for servo. But what about DC motor?
Motor  needs specific PWM  frequency e.g 20 kHz..
I tried to use  combination tiger 0.05 ms and  function  to set number of PWM (duty cycle) something as:
[{"id":"1b18db1c.004bfd","type":"inject","name":"","topic":"","payload":"1","payloadType":"string","repeat":"","crontab":"","once":false,"x":176.8000030517578,"y":492.8000030517578,"z":"db69519.e55633","wires":[["6fa8597d.de979"]]},{"id":"6fa8597d.de979","type":"trigger","op1":"1","op2":"0","op1type":"val","op2type":"val","duration":"0.05","extend":false,"units":"ms","name":"","x":376.79998779296875,"y":492.79998779296875,"z":"db69519.e55633","wires":[["e1613e92.d480b"]]},{"id":"59102d44.6f1acc","type":"gpio out","name":"PWM P8_13","state":"SERVO","pin":"P8_13","i2cDelay":"0","i2cAddress":"","i2cRegister":"","outputs":0,"board":"","x":688.7999877929688,"y":472.79998779296875,"z":"db69519.e55633","wires":[]},{"id":"e1613e92.d480b","type":"function","name":"set 180 PWM Duty Cycle","func":"msg = {payload: 180};\nreturn msg;","outputs":1,"noerr":0,"x":486.79998779296875,"y":569.7999877929688,"z":"db69519.e55633","wires":[["59102d44.6f1acc"]]}]

but it doesn't work.

Mark Setrem

unread,
Oct 9, 2015, 6:08:21 PM10/9/15
to Node-RED
Use a motor controller IC.

There's an Adafruit guide for inspiration https://learn.adafruit.com/downloads/pdf/adafruit-raspberry-pi-lesson-9-controlling-a-dc-motor.pdf

darlin

unread,
Oct 9, 2015, 6:18:03 PM10/9/15
to Node-RED
sorry, correction
of course, I control motor base on motor driver which needs PWM signal. Will be fine if I could run this base on node-red-contrib-gpio

Luis Montes

unread,
Oct 9, 2015, 8:18:59 PM10/9/15
to node...@googlegroups.com
The pwm value should only need to be set once.  The hardware itself is controlling the duty cycle on the wires once a PWM pin is set. Unfortunately Javascript timers don't have the precision or speed to create a duty cycle, so this is always deferred to the hardware.

 If you had servos working then it's likely your pwm setting is ok.

--
Reply all
Reply to author
Forward
0 new messages