Go to Post I'd love to see a simple, robust system that connects quickly and dependably. - Andy Baker [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 14-02-2013, 22:44
alberth alberth is offline
Programmer and Engineer
FRC #4067 (The Incredible Hawk)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2011
Location: Maryland
Posts: 9
alberth is an unknown quantity at this point
Outputting PWM on the Digital Sidecar Digital I/O

I'm most familiar with Arduino's PWM interface - basically,
Code:
// Usage: analogWrite(pin, value 0-255)
analogWrite(1, 255);
I'm trying to accomplish this with the FRC Java DigitalOutput class, which seems to contain some methods related to PWM output.

Our situation is that we use a LOT of motors - to the point that we have few (if not zero) PWM slots! Therefore, we are using the Digital I/O GPIO instead, which technically can also output PWM. We are trying to drive a 12 V LED ring that we bought using PWM and an op-amp to ramp the 5 V PWM output to 12 V. We haven't gotten the op-amp nor LED ring yet, so we're currently testing it using the breadboard and a small LED. At the moment, the code looks like this:
Code:
// robotInit
DigitalOutput doutput = new DigitalOutput(1);
doutput.enablePWM(0.0);
// testPeriodic
doutput.updateDutyCycle(1.0);
It does not light up.** The code seems to be correct, since the duty cycle is what affects the LED's brightness... but it doesn't work.

I would appreciate any help!

** I am probably too tired to think/remember, but it *might* be that it did light up - we went from 0.00 to 1.00 by 0.05 increments, going up and down. However, instead of a fading LED, it was just 100% on.
__________________
Team #4067 - The Incredible Hawk
Role: Lead Programmer
Team Website

2012 Rookie Inspiration Award (Chesapeake Regional)

"You can't warm up by standing still in the frigid cold. Get moving!"
Reply With Quote
  #2   Spotlight this post!  
Unread 14-02-2013, 22:58
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,590
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Outputting PWM on the Digital Sidecar Digital I/O

Have you tried calling setPWMRate also?
Reply With Quote
  #3   Spotlight this post!  
Unread 15-02-2013, 22:40
DonRotolo's Avatar
DonRotolo DonRotolo is offline
Back to humble
FRC #0832
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Atlanta GA
Posts: 7,014
DonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond repute
Re: Outputting PWM on the Digital Sidecar Digital I/O

Did you have a dropping resistor in series with the LED (if it was 100% lit all the time)? If not, put one in there. ALL LEDs require a dropping resistor (12V pre-made arrays usually have one in there...)
__________________

I am N2IRZ - What's your callsign?
Reply With Quote
  #4   Spotlight this post!  
Unread 18-02-2013, 16:37
1014Electronics 1014Electronics is offline
Registered User
FRC #1014
 
Join Date: Feb 2013
Location: Columbus
Posts: 1
1014Electronics is an unknown quantity at this point
Re: Outputting PWM on the Digital Sidecar Digital I/O

We used your PWM code to run a strip of RGB LEDs. And it Worked. I don't understand why you are using an op-amp. We used a PWM channel and connected the signal wire to the base of a BC547 NPN transistor and grounded the circuit along with the PWMs black ground wire.(The Red Wire was unused). We used the PWM signal with three transistors, each one controlling the different colors of the RGB LED strip, and we were able to create many combinations of colors. The following schematic attached to this post is what the circuit looks like for 1 channel for controlling a string of LEDs. The 12 volt supply is from the power distribution board and we put a 20 amp breaker for that slot. Note that this is for 1 channel. Also, Thanks for the code! It really helped us make some cool colors!
[IMG]/Users/13hong_jeremy/Downloads/schemeit-project.png[/IMG]
Reply With Quote
  #5   Spotlight this post!  
Unread 19-02-2013, 09:09
mathking's Avatar
mathking mathking is offline
Coach/Faculty Advisor
AKA: Greg King
FRC #1014 (Dublin Robotics aka "Bad Robots")
Team Role: Teacher
 
Join Date: Jan 2005
Rookie Year: 1999
Location: Columbus, OH
Posts: 642
mathking has a reputation beyond reputemathking has a reputation beyond reputemathking has a reputation beyond reputemathking has a reputation beyond reputemathking has a reputation beyond reputemathking has a reputation beyond reputemathking has a reputation beyond reputemathking has a reputation beyond reputemathking has a reputation beyond reputemathking has a reputation beyond reputemathking has a reputation beyond repute
Re: Outputting PWM on the Digital Sidecar Digital I/O

Here is a little bit of video where we are testing the lights.
__________________
Thank you Bad Robots for giving me the chance to coach this team.
Rookie All-Star Award: 2003 Buckeye
Engineering Inspiration Award: 2004 Pittsburgh, 2014 Crossroads
Chairman's Award: 2005 Pittsburgh, 2009 Buckeye, 2012 Queen City
Team Spirit Award: 2007 Buckeye, 2015 Queen City
Woodie Flowers Award: 2009 Buckeye
Dean's List Finalists: Phil Aufdencamp (2010), Lindsey Fox (2011), Kyle Torrico (2011), Alix Bernier (2013), Deepthi Thumuluri (2015)
Gracious Professionalism Award: 2013 Buckeye
Innovation in Controls Award: 2015 Pittsburgh
Event Finalists: 2012 CORI, 2016 Buckeye
Reply With Quote
Reply


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 12:53.

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