Open randynwalsh opened 9 years ago
Hi, Randy. I'm trying to use this plugin to control some LEDs. Have you found the way to control the pwm duty cycle?
No, unfortunately not. I used an Arduino instead. On Apr 6, 2016 2:00 AM, "Tsehsuan Wang" notifications@github.com wrote:
Hi, Randy. I'm trying to use this plugin to control some LEDs. Have you found the way to control the pwm duty cycle?
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/AppShed/ioio-cordova-plugin/issues/2#issuecomment-206196752
I took a look at the code, and I found this in src/com/appshed/ioioplugin/services/IOIOCOmmunicationService.java
line 117:
@Override protected void setup() throws ConnectionLostException,InterruptedException { led_ = ioio_.openDigitalOutput(IOIO.LED_PIN); for(Integer pinPort:pins.keySet()){ Pin pin = pins.get(pinPort); if(pin instanceof PinPwmOutput){ // PinPwmOutput PinPwmOutput pinPwmOutput = (PinPwmOutput)pin; pinPwmOutput.pwmOutput = ioio_.openPwmOutput(pinPort, PWN_MAX_FREQ); ...
and this in line 151:
Pin pin = pins.get(pinPort); if(pins.get(pinPort) instanceof PinPwmOutput){ // PinPwmOutput PinPwmOutput pinPwmOutput = (PinPwmOutput)pins.get(pinPort); pinPwmOutput.pwmOutput.setPulseWidth(pinPwmOutput.freq); try { parameters.put(pinPwmOutput.getJson()); } catch (Exception e) {}
It seems that the author set up the pwmOutput with the PWN_MAX_FREQ
(which is 10000), and the functionsetPwnOutput
is to set the plusewidth. But the problem is that I currently don't have an IOIO to test this function because I have to wait a few more days to get one. So is setPwnOutput
only set the frequency of the pwn output?
Can any tell me if this code supports the ability to set the duty cycle on a pulse modulation? I'd like to be able to control some servos.
Thank you in advance!
Randy