Go to Post You mean to tell me there's a weight limit this year?!?!?!!? - Carlo [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 29-01-2015, 16:52
IrishFBall32 IrishFBall32 is offline
Electrical CDT Mentor
AKA: Chris Bowles
FRC #1014 (Dublin Robotics/Bad Robots)
Team Role: Electrical
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Dublin, Ohio
Posts: 8
IrishFBall32 is on a distinguished road
Send a message via AIM to IrishFBall32
Tweaking PWM output period for dimming LEDs

Hi all, I'm working on an LED driver circuit and wanted to run this by y'all.

The circuit I'm building is a simple TIP120 transistor based amplifier, which I intend to be connected to PWM outputs on the RoboRIO, with the pulsed output effectively modulating the duty cycle of the LEDs.

The snag I'm running into relates to PWM duty cycles. Ideally, I'd like 0% to be an output of 0vdc, and 100% to be a constant output of 6vdc. 50% would then be 6vdc pulsed at say 1ms on, 1ms off. From my understanding the default PWM signal is a 1-2ms pulse every 20 seconds, which translates to a 5-10% duty cycle. I see references in the WPILib API's PWM class to varying the PWM period potentially down to 5.05ms, and pulses as small as .5ms (which should get me ~10-40%), but does anyone know if it is possible to manipulate the PWM output further? I'm also open to other suggestions such as an efficient way to pulse a DIO pin in the necessary manner.

Disclaimer: I've read the API docs, but I haven't dug into the actual code. I also haven't yet resorted to just tinkering with things and seeing what I get with an oscilloscope.
__________________
Chris Bowles
Team 1014 - Dublin Robotics (Bad Robots)
2015 Electrical CDT Mentor
2006 Controls CDT Leader
2005 Controls CDT Member
  #2   Spotlight this post!  
Unread 29-01-2015, 17:12
Redo91's Avatar
Redo91 Redo91 is offline
Registered User
AKA: Justin
no team
Team Role: Engineer
 
Join Date: Dec 2006
Rookie Year: 2006
Location: Carlsbad
Posts: 149
Redo91 is a glorious beacon of lightRedo91 is a glorious beacon of lightRedo91 is a glorious beacon of lightRedo91 is a glorious beacon of lightRedo91 is a glorious beacon of lightRedo91 is a glorious beacon of light
Re: Tweaking PWM output period for dimming LEDs

The PWM signal sent from the roboRIO is a Hobby PWM signal, slightly different from a typical duty cycle. I would use a digital pin and create my own function to adjust the duty cycle.

Would the analog outputs on the MXP be an option?
__________________
Team 1296-Full Metal Jackets
Alumni 2009
Mentor 2009-2014

Team 624-CRyptonite
Mentor 2014-2015

Last edited by Redo91 : 29-01-2015 at 17:17. Reason: Added to the post
  #3   Spotlight this post!  
Unread 29-01-2015, 18:00
wmarshall11 wmarshall11 is offline
Registered User
FRC #2399
Team Role: Mentor
 
Join Date: May 2013
Rookie Year: 2011
Location: Cleveland, OH
Posts: 34
wmarshall11 is a splendid one to beholdwmarshall11 is a splendid one to beholdwmarshall11 is a splendid one to beholdwmarshall11 is a splendid one to beholdwmarshall11 is a splendid one to beholdwmarshall11 is a splendid one to beholdwmarshall11 is a splendid one to beholdwmarshall11 is a splendid one to behold
Re: Tweaking PWM output period for dimming LEDs

I've previously used PWM.setRaw() to set the duty cycle of PWM channels for driving LEDs, where setRaw(0) is 0% duty cycle and setRaw(255) is 100%.
  #4   Spotlight this post!  
Unread 29-01-2015, 21:53
Bonzabonz Bonzabonz is offline
Registered User
FRC #5052 (RoboLobos)
Team Role: Alumni
 
Join Date: Feb 2014
Rookie Year: 2014
Location: Cedar Park Texas
Posts: 13
Bonzabonz is an unknown quantity at this point
Re: Tweaking PWM output period for dimming LEDs

My team had to do the same thing; there are functions to get a DIO pin to output a PWM signal of a user specified frequency. We did it using LabVIEW, but it should work in a similar way using Java or C++. If you just need to open the DIO pin as normal, you can use the Gen PWM VI to set your duty cycle. There is an additional VI abbreviated Config PWM Rate where you can actually change the frequency of the signal for the DIO pin.

I was also able to find documentation for the Java DigitalOutput class here: http://first.wpi.edu/FRC/roborio/rel...e4aab985133c41 . There are setPWMRate(), enablePWM() and updateDutyCycle() methods to control the PWM functionality for a specific DIO pin. The API should have more details on how to implement them.
  #5   Spotlight this post!  
Unread 29-01-2015, 23:54
philso philso is offline
Mentor
FRC #2587
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Houston, Tx
Posts: 938
philso has a reputation beyond reputephilso has a reputation beyond reputephilso has a reputation beyond reputephilso has a reputation beyond reputephilso has a reputation beyond reputephilso has a reputation beyond reputephilso has a reputation beyond reputephilso has a reputation beyond reputephilso has a reputation beyond reputephilso has a reputation beyond reputephilso has a reputation beyond repute
Re: Tweaking PWM output period for dimming LEDs

Chris

How many LED's are you trying to drive? If you are driving multiple LED's, are they connected in series? How many are connected in series?
  #6   Spotlight this post!  
Unread 02-02-2015, 20:05
IrishFBall32 IrishFBall32 is offline
Electrical CDT Mentor
AKA: Chris Bowles
FRC #1014 (Dublin Robotics/Bad Robots)
Team Role: Electrical
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Dublin, Ohio
Posts: 8
IrishFBall32 is on a distinguished road
Send a message via AIM to IrishFBall32
Re: Tweaking PWM output period for dimming LEDs

Thanks guys, I'm taking a look at those methods now.

As for the number of LEDs, its one of the ubiquitous RGB LED strips. If you're working toward the usual warning about current draw on the PWM pins, I'm quite aware, hence the transistor amp.
__________________
Chris Bowles
Team 1014 - Dublin Robotics (Bad Robots)
2015 Electrical CDT Mentor
2006 Controls CDT Leader
2005 Controls CDT Member
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 17:59.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi