 |
|
 |
| Parallax Forums > Public Forums > Propeller Chip > Program help, not making sence..... | Forum Quick Jump
|
|  jknightandkarr Registered Member

       Date Joined Apr 2009 Total Posts : 57 | Posted 11/6/2009 9:58 PM (GMT -8) |   | I have the PropRPM & I'm having issues trying to create my first program using all 10 leds, to light em up 1 at a time. one per sec. Here's the problem. Instead of doing what I want, it's doing the exact opposite, starts with all on & turns em off 1 per sec, that orone of 2 other things, no leds come on or P17, 18, 19, 23, 24 & 25 light on at once & P16, 20, 21, 22 stay off. Pendinging how I try & figure out what I've done wrong. I also did a very similar program on my BS2 & it worked just fine, so I know the leds are fine. There's an error someplace, According to what I know on the BS2 it should work.
My problem prone program. 'Countup LEDs
Con _clkmode = xtal1+pll8x _xinfreq = 5_000_000 PUB Ledallon dira[16]:=1 dira[17]:=1 dira[18]:=1 dira[19]:=1 dira[20]:=1 dira[21]:=1 dira[22]:=1 dira[23]:=1 dira[24]:=1 dira[25]:=1 outa[16]:=1 repeat 25 waitcnt(80_000_000+cnt) outa[17]:=1 waitcnt(80_000_000+cnt) outa[18]:=1 waitcnt(80_000_000+cnt) outa[19]:=1 waitcnt(80_000_000+cnt) outa[20]:=1 waitcnt(80_000_000+cnt) outa[21]:=1 waitcnt(80_000_000+cnt) outa[22]:=1 waitcnt(80_000_000+cnt) outa[23]:=1 waitcnt(80_000_000+cnt) outa[24]:=1 waitcnt(80_000_000+cnt) outa[25]:=1 waitcnt(80_000_000+cnt)
I know the chip & LEDs are fine. This other program works flawlessly.
'Alternating LEDs
Con _clkmode = xtal1+pll16x _xinfreq = 5_000_000 PUB Ledallon dira[16]:=%1 outa[16]:=%1 dira[17]:=%1 outa[17]:=%0 dira[18]:=%1 outa[18]:=%1 dira[19]:=%1 outa[19]:=%0 dira[20]:=%1 outa[20]:=%1 dira[21]:=%1 outa[21]:=%0 dira[22]:=%1 outa[22]:=%1 dira[23]:=%1 outa[23]:=%0 dira[24]:=%1 outa[24]:=%1 dira[25]:=%1 outa[25]:=%0 REPEAT 25 !outa[16] !outa[17] !outa[18] !outa[19] !outa[20] !outa[21] !outa[22] !outa[23] !outa[24] !outa[25] waitcnt(clkfreq+cnt)
This don't make sence. Anytime I try & get all LED's to light up at once, they all stay off. I thought it was my 9V, 900 mA power supply, figured it wasn't enough mA to do it, so I put it on my old 486 pc Power supply, & taking my 10.1 VDC out of the power supply made a quick voltage divider out of 2 resistors & took the voltage to 9.17 VDC & same thing, so my problem isn't mA. According to what I've read soo far & from what I know on the BS2 Homeworkboard kit, my program should have worked correctly & done what I wanted it to do. What am I missing here??
Joe I'm going insaine. It's SOOOOOO much fun. lolPost Edited (jknightandkarr) : 11/7/2009 6:41:27 AM GMT | | Back to Top | | |
 |  ElectricAye Registered Member

       Date Joined Jul 2008 Total Posts : 972 | Posted 11/6/2009 10:07 PM (GMT -8) |   | First, try using the CODE formatting buttons to enclose your code so it shows up on this screen the way it would on your computer.
Second, are you sure you are indenting your code properly under your REPEAT command? It's hard to tell when your code is not using the CODE formatting mentioned above. | | Back to Top | | |
 |  Mike Green Registered Member

       Date Joined Oct 2004 Total Posts : 13554 | Posted 11/6/2009 10:15 PM (GMT -8) |   | Maybe you have the LEDs hooked up wrong. Your program starts off with the I/O pins by default set to low (0V) and you set them one by one to high (3.3V) and leave them there (assuming the indenting is correct ... I can't tell). You need something like:
I/O pin ---\/\/\/\/\/---LED anode
LED cathode --- ground
The resistor can be anything from about 1K to 100 Ohms | | Back to Top | | |
    |  Mike Green Registered Member

       Date Joined Oct 2004 Total Posts : 13554 | Posted 11/6/2009 11:14 PM (GMT -8) |   | | You probably don't really have the indenting the way you've shown it here. When the Ledalion routine exits, the cog is reset and all of the outputs are turned off. Put a long pause after the last OUTA. You'll see that P24 and P25 stay on longer. | | Back to Top | | |
  |  Mike Green Registered Member

       Date Joined Oct 2004 Total Posts : 13554 | Posted 11/7/2009 7:35 AM (GMT -8) |   | | Without a real copy of your program, we're just guessing. Use the Attachment Manager by clicking on the Post Reply button to attach a copy of your program source file to a reply. | | Back to Top | | |
  |  Mike Green Registered Member

       Date Joined Oct 2004 Total Posts : 13554 | Posted 11/7/2009 10:31 AM (GMT -8) |   | Your program should function as written. It initializes I/O pins 16-25 to low outputs, then sets them one by one (16 to 25) to high at one second intervals and repeats that 10 times (with no further visible effect). After 100 seconds, the whole program stops with all the I/O pins set to inputs.
The visual effect should be that all the LEDs initially turn on, then #16 turns off after a few microseconds, then one by one the others (#17 to #25) turn off at one second intervals. | | Back to Top | | |
 |  Todd Chapman Registered Member

       Date Joined May 2006 Total Posts : 1538 | Posted 11/7/2009 10:42 AM (GMT -8) |   | What is the point of repeating the loop 10 times if you never change the LED's back to OFF state?
The cog will die after 10 repeats as is. If you put the repeat at the end the cog will remain alive and the state of the LEDs will be the same as the code you have written. | | Back to Top | | |
  |  Todd Chapman Registered Member

       Date Joined May 2006 Total Posts : 1538 | Posted 11/7/2009 9:09 PM (GMT -8) |   | | There is a limit, look at the manual for more info on it, I don't remember exactly. It is a good test to turn on each LED separately though which will identify if the current is what is causing it, sounds like it is. | | Back to Top | | |
 |  Mike Green Registered Member

       Date Joined Oct 2004 Total Posts : 13554 | Posted 11/7/2009 9:36 PM (GMT -8) |   | | Assuming you have red LEDs, they have a forward voltage of 1.7V. They're running off the 3.3V supply, so you have to drop 3.3V - 1.7V = 1.6V across the 180 Ohm resistors. By Ohm's Law, that sets the LED current to 9mA. If you have 10 of them, that's 90mA. A Prop should be able to handle that easily. The PropRPM uses an LM2940 regulator which should be able to handle 1A, well beyond the LEDs' and the Prop's current requirement. What are you trying to run the PropRPM from? That may be your problem. | | Back to Top | | |
    | Forum Information | Currently it is Friday, November 20, 2009 10:14 PM (GMT -8) There are a total of 393,733 posts in 55,521 threads. In the last 3 days there were 83 new threads and 703 reply posts. View Active Threads
| | Who's Online | This forum has 17687 registered members. Please welcome our newest member, mark09. 52 Guest(s), 4 Registered Member(s) are currently online. Details Zoot, Chris Savage (Parallax), Nick McClick, Highlandtinker |
Forum powered by dotNetBB v2.42EC SP2.02 dotNetBB © 2000-2009 |
|
|