Shop OBEX P1 Docs P2 Docs Learn Events
Numeric Display failing to work. — Parallax Forums

Numeric Display failing to work.

jknightandkarrjknightandkarr Posts: 234
edited 2009-12-21 06:33 in Propeller 1
StefanL38 said...
Hello jknightandkarr,

a SPIN program always starts with the first method o execute code regardless of its name

Your first method is start which just does a cognew with speedometer

Inside method speedometer you have a repeat-loop that is executed endlessly
and that's all what you program is doing. al the other lines of code are NEVER executed.

So this is a real beautiful example that a program does always what's programmed.
And if it does something different then the programmer intended, that the programmer has
not understand his programming YET.

Things like that you can find out by adding debug-output to your code that you get a feedback what and where your prgram is doing

Do you know how to add debug-output over the serial connection ?
if not drop a line

best regards

Stefan
I'm having trouble getting my display to work. Tested the leds with another simple program & they are fine, but on my speedometer program I get only a blank screen, no leds at all are lit. I used the code available here as the base for my program display. What am I doing wrong here? Like I said I checked my led connectrion with a simple display pattern, so I know all are hooked up & work, but in the program I'm working on nothing. Thanks.

Joe

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

Post Edited (jknightandkarr) : 12/19/2009 5:10:46 PM GMT

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2009-12-19 09:04
    Hello jknightandkarr,

    a SPIN program always starts with the first method o execute code regardless of its name

    Your first method is start which just does a cognew with speedometer

    Inside method speedometer you have a repeat-loop that is executed endlessly
    and that's all what you program is doing. al the other lines of code are NEVER executed.

    So this is a real beautiful example that a program does always what's programmed.
    And if it does something different then the programmer intended, that the programmer has
    not understand his programming YET.

    Things like that you can find out by adding debug-output to your code that you get a feedback what and where your prgram is doing

    Do you know how to add debug-output over the serial connection ?
    if not drop a line

    best regards

    Stefan
  • MicrocontrolledMicrocontrolled Posts: 2,461
    edited 2009-12-19 12:09
    If that's EXACTLY what your code looks like you have a lot of problems. There is NO indenting, which in spin is what defines EVERYTHING! Your repeat loop is endlessly repeating nothing, and that's holding up your program, your IF loops are doing nothing if defined because nothing is indented under them, etc.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Computers are microcontrolled.

    Robots are microcontrolled.
    I am microcontrolled.

    But you·can·call me micro.

    Want to·experiment with the SX or just put together a cool project?
    SX Spinning light display·
    My overstock is killing me.
    PM me for absolutly FREE 8-pin Mini Din connectors.
  • jknightandkarrjknightandkarr Posts: 234
    edited 2009-12-19 16:58
    StefanL38 said...
    Hello jknightandkarr,

    a SPIN program always starts with the first method o execute code regardless of its name

    Your first method is start which just does a cognew with speedometer

    Inside method speedometer you have a repeat-loop that is executed endlessly
    and that's all what you program is doing. al the other lines of code are NEVER executed.

    So this is a real beautiful example that a program does always what's programmed.
    And if it does something different then the programmer intended, that the programmer has
    not understand his programming YET.

    Things like that you can find out by adding debug-output to your code that you get a feedback what and where your prgram is doing

    Do you know how to add debug-output over the serial connection ?
    if not drop a line

    best regards

    Stefan

    The Start method will actually start 3, one is disabled & the other isn't actually written yet, but there will be 3 when it's all done. How do you do that debug-output thing. I'm not sure. I think it may be something with the original program. I've tried it & I get no display from it as well. Had messed with it before & got all gobbly gook on the display, but never a display from my program yet.
    microcontrolled said...
    If that's EXACTLY what your code looks like you have a lot of problems. There is NO indenting, which in spin is what defines EVERYTHING! Your repeat loop is endlessly repeating nothing, and that's holding up your program, your IF loops are doing nothing if defined because nothing is indented under them, etc.
    It's indented, I'll post the program later, so you can see it.

    Joe

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

    Post Edited (jknightandkarr) : 12/19/2009 5:24:16 PM GMT
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-12-19 19:48
    OK here is a short demo-code how the debug-output works

    CON
      'serial communication requires a precise clockmode
      'internal oscillator-mode is much too much unprecise
      'so ALWAYS use a xtal1-mode  
      _clkmode = xtal1 + pll16x
      'when using another chrystal than 5 MHz adjust constant _xinfreq
      'to the right value
      _xinfreq = 5_000_000 
    
      'result of pll16x * _xinfreq should NOT exceed 80MHz  
      'example if _xinfreq = 10_000_000 than use pll8x instead of pll16x
      'as 10_000_000 * 16 = 160MHz   and 10_000_000 * 8 = 80MHz   
    
    
    OBJ
      Debug  : "FullDuplexSerial"
    
    
    VAR
      long MyVar1
      long MyCounterVar
    
    
    PUB Main
      Debug.Start(31,      30,0,115200) 'start(rxpin, txpin, mode, baudrate) :
      ''        '"rx" and "tx" viewed from Propeller-Chip.   Propeller-Chip-PIN-Tx ----> PC
    
      Debug.Str(string("Debug.Start(31,      30,0,115200) done"))
    
      Debug.Str(string("message right before entering the loop"))
    
      repeat MyCounterVar from 1 to 5
        Debug.Str(string("Decimal Value of variable MyCounterVar="))
        Debug.dec(MyCounterVar)
        Debug.Tx(13) 'carriage return
        waitCnt(ClkFreq * 2 + cnt)  
        Debug.Tx(13) 'carriage return
        Debug.Tx(13) 'carriage return
    
      Debug.Str(string("message right after exiting the loop"))
    
    



    You have to adjust PST.EXE to 115200 baus 8N1 to get the correct characters

    best regards

    Stefan
  • jknightandkarrjknightandkarr Posts: 234
    edited 2009-12-19 21:29
    Cool, Thanks.

    Joe

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm going insaine. It's SOOOOOO much fun. lol
  • jknightandkarrjknightandkarr Posts: 234
    edited 2009-12-19 21:36
    Speedometer.spin
    Here is my program. I had to zip it up & post it, for some reason I couldn't access it unzipped.

    Joe

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm going insaine. It's SOOOOOO much fun. lol
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-12-20 06:47
    in the attachment I have added debug-output to show you what is going on

    best regards

    Stefan
  • jknightandkarrjknightandkarr Posts: 234
    edited 2009-12-20 21:34
    Oh Thank you. Really appreciate that.

    Joe

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm going insaine. It's SOOOOOO much fun. lol
  • w8anw8an Posts: 176
    edited 2009-12-21 04:35
    Joe,

    What I see right away is your Start routing launches the Speedometer routine. The Speedometer routine then perpetually initializes some of your vars in a non-terminating repeat loop.

    The command that launches the display multiplexer (ShowValue) is actually after this endless loop so it will never execute. Even if the display was started, you are not sending it any value to show (the SetValue) routine.

    Try out and study the demo and that came with the seven-segment functions you got from Obex and I think you'll understand why you're having problems.

    Steve
  • jknightandkarrjknightandkarr Posts: 234
    edited 2009-12-21 06:33
    w8an said...
    Joe,

    What I see right away is your Start routing launches the Speedometer routine. The Speedometer routine then perpetually initializes some of your vars in a non-terminating repeat loop.

    The command that launches the display multiplexer (ShowValue) is actually after this endless loop so it will never execute. Even if the display was started, you are not sending it any value to show (the SetValue) routine.

    Try out and study the demo and that came with the seven-segment functions you got from Obex and I think you'll understand why you're having problems.

    Steve

    I just noticed that a section in my code wasn't indented, so that's probly one source of the issue. Thanks for the help everyone.

    Joe

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