Shop OBEX P1 Docs P2 Docs Learn Events
Program help, not making sence..... — Parallax Forums

Program help, not making sence.....

jknightandkarrjknightandkarr Posts: 234
edited 2009-11-08 07:06 in Propeller 1
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[noparse][[/noparse]16]:=1
  dira[noparse][[/noparse]17]:=1
  dira[noparse][[/noparse]18]:=1
  dira[noparse][[/noparse]19]:=1
  dira[noparse][[/noparse]20]:=1
  dira[noparse][[/noparse]21]:=1
  dira[noparse][[/noparse]22]:=1
  dira[noparse][[/noparse]23]:=1
  dira[noparse][[/noparse]24]:=1
  dira[noparse][[/noparse]25]:=1
  outa[noparse][[/noparse]16]:=1
  repeat 25
    waitcnt(80_000_000+cnt)
    outa[noparse][[/noparse]17]:=1
    waitcnt(80_000_000+cnt)
    outa[noparse][[/noparse]18]:=1
    waitcnt(80_000_000+cnt)
    outa[noparse][[/noparse]19]:=1
    waitcnt(80_000_000+cnt)
    outa[noparse][[/noparse]20]:=1
    waitcnt(80_000_000+cnt)
    outa[noparse][[/noparse]21]:=1
    waitcnt(80_000_000+cnt)
    outa[noparse][[/noparse]22]:=1
    waitcnt(80_000_000+cnt)
    outa[noparse][[/noparse]23]:=1
    waitcnt(80_000_000+cnt)
    outa[noparse][[/noparse]24]:=1
    waitcnt(80_000_000+cnt)
    outa[noparse][[/noparse]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[noparse][[/noparse]16]:=%1
  outa[noparse][[/noparse]16]:=%1
  dira[noparse][[/noparse]17]:=%1
  outa[noparse][[/noparse]17]:=%0
  dira[noparse][[/noparse]18]:=%1
  outa[noparse][[/noparse]18]:=%1
  dira[noparse][[/noparse]19]:=%1
  outa[noparse][[/noparse]19]:=%0
  dira[noparse][[/noparse]20]:=%1
  outa[noparse][[/noparse]20]:=%1
  dira[noparse][[/noparse]21]:=%1
  outa[noparse][[/noparse]21]:=%0
  dira[noparse][[/noparse]22]:=%1
  outa[noparse][[/noparse]22]:=%1
  dira[noparse][[/noparse]23]:=%1
  outa[noparse][[/noparse]23]:=%0
  dira[noparse][[/noparse]24]:=%1
  outa[noparse][[/noparse]24]:=%1
  dira[noparse][[/noparse]25]:=%1
  outa[noparse][[/noparse]25]:=%0
  REPEAT 25
    !outa[noparse][[/noparse]16]
    !outa[noparse][[/noparse]17]
    !outa[noparse][[/noparse]18]
    !outa[noparse][[/noparse]19]
    !outa[noparse][[/noparse]20]
    !outa[noparse][[/noparse]21]
    !outa[noparse][[/noparse]22]
    !outa[noparse][[/noparse]23]
    !outa[noparse][[/noparse]24]
    !outa[noparse][[/noparse]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. lol

Post Edited (jknightandkarr) : 11/7/2009 6:41:27 AM GMT

Comments

  • ElectricAyeElectricAye Posts: 4,561
    edited 2009-11-07 06:07
    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.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-07 06:15
    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
  • jknightandkarrjknightandkarr Posts: 234
    edited 2009-11-07 06:36
    Sorry, I didn't know about the CODE button, but ok I edited the code & on I had everything after repeat 10 indented & all it does is flash on for a split second & then goes out.

    Con
      _clkmode = xtal1+pll16x
      _xinfreq = 5_000_000
    PUB Ledallon
      dira[noparse][[/noparse]16..25]:=%1111111111
      outa[noparse][[/noparse]16..25]:=%0000000000
      repeat 10
        OUTA[noparse][[/noparse]16]:=1
        waitcnt(80_000_000+cnt)
        OUTA[noparse][[/noparse]17]:=1
        waitcnt(80_000_000+cnt)
        OUTA[noparse][[/noparse]18]:=1
        waitcnt(80_000_000+cnt)
        OUTA[noparse][[/noparse]19]:=1
        waitcnt(80_000_000+cnt)
        OUTA[noparse][[/noparse]20]:=1
        waitcnt(80_000_000+cnt)
        OUTA[noparse][[/noparse]21]:=1
        waitcnt(80_000_000+cnt)
        OUTA[noparse][[/noparse]22]:=1
        waitcnt(80_000_000+cnt)
        OUTA[noparse][[/noparse]23]:=1
        waitcnt(80_000_000+cnt)
        OUTA[noparse][[/noparse]24]:=1
        waitcnt(80_000_000+cnt)
        OUTA[noparse][[/noparse]25]:=1
        waitcnt(80_000_000+cnt)
    



    Mike,
    On the PropRPM my bargraph leds are built into the circuit board straight from parallax on Pins 16-25, while removable, I cannot change the pin wiring or anything like that I can only remove the bargraph leds & replace them. They are working, so I know there in the socket correctly. My Alternating LEDs program works perfictly as I wanted it too, it the one I posted above that's the problem. I want it to start with P16 & light each led up in sequance to P25 being the 10th led with about 1 second between them, I tested it on my BS2 I have & my program worked flawlessly, so I don't get why it's not working here.

    Joe

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm going insaine. It's SOOOOOO much fun. lol
  • Nick MuellerNick Mueller Posts: 815
    edited 2009-11-07 06:53
    In your repeat loop, you are repeatedly switching on the LEDs, but never off.

    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • jknightandkarrjknightandkarr Posts: 234
    edited 2009-11-07 06:55
    I just got my problem program working as I wanted it too. After looking over the scematics for the PropRPM board, the 10 built in leds are wired as follows.

    3.3VDC to 10-180 Ohm Resistors, then to each led, & then to P16 to P25 of the Propeller Chip. All I had to do is change....
    outa[noparse][[/noparse]16..25]:=%0000000000 to outa[noparse][[/noparse]16..25]:=%1111111111

    & change the...

    OUTA[noparse][[/noparse]pin]:=1 to OUTA[noparse][[/noparse]pin]:=0

    to ground the leds & complete the circuit. I'll have to remember that & when I build a permant circuit with a Propeller to change them back to the way they was before. tongue.gif Thanks Guys!!!

    Joe

    Ok New problem. I get to P24, it lights up but VERY VERY breefly. Then restarts over odd, P25 don't even light up. I figured adding more pause time would help, but it didn't do anything to change it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm going insaine. It's SOOOOOO much fun. lol

    Post Edited (jknightandkarr) : 11/7/2009 7:08:38 AM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-07 07:14
    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.
  • jknightandkarrjknightandkarr Posts: 234
    edited 2009-11-07 07:35
    I tried that, increased the 80_000_000 to 320_000_000, so should be 4 seconds? Same effect Also copied waitcnt(80_000_000+cnt) & made it

    waitcnt(80_000_000+cnt)
    waitcnt(80_000_000+cnt)
    waitcnt(80_000_000+cnt)
    waitcnt(80_000_000+cnt)

    Either way it didn't seam to help. I've looked into alternative ways of pausing & all had the same effect.

    Joe

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm going insaine. It's SOOOOOO much fun. lol
  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-07 15:35
    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.
  • jknightandkarrjknightandkarr Posts: 234
    edited 2009-11-07 17:34
    here it is.

    Joe

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm going insaine. It's SOOOOOO much fun. lol
  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-07 18:31
    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.
  • T ChapT Chap Posts: 4,249
    edited 2009-11-07 18:42
    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.
  • jknightandkarrjknightandkarr Posts: 234
    edited 2009-11-08 04:31
    Todd Chapman, was just trying to look at ways of keeping the leds on & trying to figure out my problem.

    Question. If I go over on mA, will the propeller reset itself? I ask this because after putting ' infront of outa[noparse][[/noparse]24] & outa[noparse][[/noparse]25] lines that turned them into the same as comments, the leds quit restarting & stayed lit. that is after I moved the repeat command down to the bottom to make it just repeat nothing. I think I'm just over on the mA is why my display is screwing up.

    Joe

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm going insaine. It's SOOOOOO much fun. lol
  • T ChapT Chap Posts: 4,249
    edited 2009-11-08 05:09
    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.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-08 05:36
    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.
  • jknightandkarrjknightandkarr Posts: 234
    edited 2009-11-08 06:03
    Well first I was using a 9V 900 mA transformer, now I"m using an old 486 style powersupply It's runing from, After measuring the powersupply out voltage & got 10.10 V & used a resistor voltage divider network to drop it too about 9.17V. Both had been giving me the same results.

    Joe

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm going insaine. It's SOOOOOO much fun. lol
  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-08 06:10
    If you're using a voltage divider, that's your problem. As the current climbs because more LEDs are lit, the output voltage of the voltage divider will decrease and drop below about 4V at which time the supply voltage of the Prop will drop below 2.7V and it will reset.

    A voltage divider will only provide a stable voltage when the current drain is fixed. Work it out using Ohm's Law. You'll see.

    There's about a 0.7V drop across the input diode of the PropRPM plus about 0.5V across the voltage regulator. The Prop requires something like 2.7V or better to work and really is supposed to get 3.3V. You need at least 4.5V at the power connector. The Propeller datasheet has graphs showing how much current per cog it draws at different clock speeds plus a base current for the hub. Have a look at the datasheet.

    Post Edited (Mike Green) : 11/8/2009 6:16:54 AM GMT
  • jknightandkarrjknightandkarr Posts: 234
    edited 2009-11-08 06:53
    Thanks for telling me that. My electronics book I was looking at failed to give any info on that, other then how to do the calculations for doing them. Will remember that, much appreiciated. After I hooked my digital MM up to the proprpm board & with each led that came on, I watched the voltage drop down to about 3.7 V with the 8th led from about 8 volts idle, so that's my problem. I'm guessing my other 9V power supply will work just fine then. Thanks again.

    Joe

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm going insaine. It's SOOOOOO much fun. lol
  • jknightandkarrjknightandkarr Posts: 234
    edited 2009-11-08 07:06
    After swaping out power supplies, I now get all 10 leds lit. Thanks. My other power supply was the problem. Thanks all!

    Joe

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm going insaine. It's SOOOOOO much fun. lol
Sign In or Register to comment.