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

Pulse Width Duty Cycle #2

Open
randynwalsh opened this issue Nov 8, 2015 · 3 comments
Open

Pulse Width Duty Cycle #2

randynwalsh opened this issue Nov 8, 2015 · 3 comments

Comments

@randynwalsh
Copy link

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

@w-zx
Copy link

w-zx commented Apr 6, 2016

Hi, Randy. I'm trying to use this plugin to control some LEDs. Have you found the way to control the pwm duty cycle?

@randynwalsh
Copy link
Author

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
#2 (comment)

@w-zx
Copy link

w-zx commented Apr 6, 2016

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 functionsetPwnOutputis 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?

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

2 participants