Shop OBEX P1 Docs P2 Docs Learn Events
Useing the TV screen? — Parallax Forums

Useing the TV screen?

krazyideaskrazyideas Posts: 119
edited 2008-12-14 14:12 in Propeller 1
Hello,

I am useing the TV to display a varaible but the screen keeps rolling so fast I can't read the number.· What is the clear sreen command for the tv terinal???

It should work if I clear the screen and then string dec.term (variable)· Then the number would stay in the upper left corner shouldn't it??

Thanks for any help

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-13 20:38
    Yes, but you'd be better off to use the "home screen" control code and add extra spaces after the number. Clearing the screen takes more time and is not necessary if you're just rewriting part of the screen. For other display lines, you can use the Set X and Set Y control codes
  • krazyideaskrazyideas Posts: 119
    edited 2008-12-13 21:39
    Thanks
  • krazyideaskrazyideas Posts: 119
    edited 2008-12-13 21:54
    Hello

    Well I am trying to make an RPM Gage.

    I have a pules that·goes high·1/2 second and then low 1/2 second.·

    I am useing RPM := ((((measure2 - measure1) * 36) / clkfreq) * 60)·to give me RPM. Where Measure2 is the cnt value when the pin goes low and measure1 is the cnt value with the pin goes high.· It just reads Zero.

    If I take out the clkfreq out and just have RPM := (Measure2 - Measure1) The number I get varies up and down,· 10_000 counts or so

    Is that just the counter's window of error or what?

    my program is attached

    Thanks for any thoughts
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-13 23:29
    Since the system clock is 80MHz, a difference of 10_000 is about 125us or 0.000125 seconds out of a 0.5 second width pulse.
  • AribaAriba Posts: 2,690
    edited 2008-12-14 02:36
    I suggest to use the 'TV_Text' object instead of 'TV_Terminal', the Terminal version uses the grafic object and therefore 1 cog, and a lot of RAM more. And TV_Text uses the ROM font, which I find nicer.

    Your code only measure the high pulswith of the RPM sensor. To get the time of a full turn you need to capture the cnt 2 times at the same edge:
      waitpeq (pin, pin, 0)
      waitpne (pin, pin, 0)
      measure2 := cnt
      waitpeq (pin, pin, 0)
      waitpne (pin, pin, 0)
      measure1 := cnt
      RPM := (measure1 - measure2)
      ...
    
    



    to calculate the RPM:
    RPM := clkfreq / ((measure2 - measure1) / 60)

    Andy
  • StefanL38StefanL38 Posts: 2,292
    edited 2008-12-14 14:12
    Hello KraziIdeas,

    if you REALLY want to know what is going on in your code you have to check EVERY detail

    hand upon heart ! How many hours did you spend on trying things with this issue ?

    it's not nescessary to answer this question here in the forum. It's enough to answer it to yourself

    I want to show you a way of how you can learn a lot of things. At first it might look
    like "oh ! So many extra-lines to code ?!?!"

    But if you count how many MINUTES it takes to code these lines and compare it to the HOURS
    you tryed around with no success the minutes pay off in many hours and days

    So here it is:

    I prefer a serial connection to debug and check things

    and if you take the programming-cable no additional hardware is needed

    The basic idea here is:
    create a signal that is rocksteady 1Hz 500 milliseconds ON 500 milliseconds OFF
    connect this signal to your IO-PIN No 2 (IO-pin-counting starts at zero)
    which you use to measure the ON/OFF-time by WAITPEQ/WAITPNE

    In the testphase of a program :
    If you take SOME signal you don't know exactly what the signal is
    and you don't know exactly what your code is doing
    these are condition where it is hard to find out what is going on
    so you have to reduce the things that are uncontrolled.

    Here is a democode showing this with your program

    I added an object serial (FullDuplexSerial) and an object heart (heartbeat.spin)

    heartbeat.spin starts a cog and make one IO-PIN toggle at a frequency infinitly
    this creates the rocksteady signal with 1Hz

    you just connect IO-PIN 10 with IO-PIN 2 to have this signal on your waitpeq-pin

    Then I wrote some short methods that make it a little bit easier to write
    code for debugging what is going on in the code

    object heartbeat.spin

    ''This object should be used like this:
    
    ''VAR
    ''long  stack[noparse][[/noparse] 20]
    
    ''OBJ
    ''heart :       "heartbeat"
    
    ''Start IO-PIN to toggle with ON/OFF-time
    ''  heart.start(10,500) 'start a cog that "blinks" IO-PIN 10
    ''                       with ON/OFF-Time each 500 milliseconds
    
    {
    CON
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    }
    
    VAR
      long  Stack[noparse][[/noparse] 20]                      'Stack space for new cog
      byte  Cog                           'Hold ID of cog in use, if any
    
    
    PUB Start(Led_pin, delayMS) : Success
      Stop
      Success := (Cog := cognew(Blink_LED(Led_pin, delayMS), @Stack) + 1)
    
    PUB Stop
    {{Stop }}
    
      if Cog
        cogstop(Cog~ - 1)
    
    PUB Active : YesNo
    {{Return TRUE if process is active, FALSE otherwise.}}
    
      YesNo := Cog > 0
    
    PRI Blink_LED(Led_PIn, DelayMS)
    
      dira[noparse][[/noparse]Led_PIn] := 1
      repeat
        !outa[noparse][[/noparse]Led_PIn]
        waitcnt(clkfreq / 1000 * DelayMS + cnt)  '  Wait for DelayMS cycles    
    
    
    



    and here your sourcecode with added debug-functionality

    I added some constants that make it easy to change between very detailed debugoutput and a short output
    I renamed some of your variables in that way that the name is REALLY SELFEXPLAINING

    you might thing ey man I'm intellgent enough to get things done by shorter easier names !
    In a short program you're right. But SELFEXPLAINING names set free brain-capacity for the REAL problem
    and as bigger as a program gets as more brain-capacity it sets free
    or as more brain-capacity it takes away from analysing the REAL problem !
    additional if you take a look into sourcecode with selfexplaining names after months or years
    is much easier to remember or understand new what the code does

    OK that's enough explaining around it here the code

    CON
      _clkmode        = xtal1 + pll16x
      _xinfreq        = 5_000_000
    
      _TVmode       = false
      _SerialMode   = not _TVmode
      _DebugDetails = true 
      
    OBJ
      term    : "tv_terminal"
      serial  : "FullDuplexSerial"
      heart   : "heartbeat"
      
    VAR
      long RPM
      long SnapShot_at_PulseBegin
      long SnapShot_at_PulseEnd
      long pin
    
    PUB TVDisplay
      
      heart.start(10,500) 'start a cog that "blinks" IO-PIN 10 with ON/OFF-Time each 500 milliseconds
    
      if _TVmode
        term.start(12)
      
      if _SerialMode  
        serial.start(31,30,0,115200)
      
        Writeln(string("serial.start(31,30,0,115200)"))
           
      pin := %00000000000000000000000000000100 
    
      Writeln(string("Enter repeat-loop"))
    
      repeat
        if _DebugDetails
          Writeln(string("direct before waitpeq (pin, pin, 0)"))
        waitpeq (pin, pin, 0)
        SnapShot_at_PulseBegin := cnt
        if _DebugDetails
          Writeln(string("direct after waitpeq (pin, pin, 0)"))
    
        
        waitpne (pin, pin, 0)
        SnapShot_at_PulseEnd := cnt
        if _DebugDetails
          Writeln(string("direct after waitpne (pin, pin, 0)"))
        'RPM := (measureStop - measureStart)
        RPM := ((((SnapShot_at_PulseEnd - SnapShot_at_PulseBegin) * 36) / clkfreq) * 60)
    
        if _TVmode
          term.out ($00)    
          term.dec (RPM)                                {Displying Results on TV for tracking firing positions}
          term.str(string("   "))
          term.str(string(" ",13))
    
        if _SerialMode
          if _DebugDetails
            Write(string("(SnapShot_at_PulseEnd - SnapShot_at_PulseBegin)=")) 
            Dec(SnapShot_at_PulseEnd - SnapShot_at_PulseBegin)
            CR
            
            Write(string(" ((SnapShot_at_PulseEnd - SnapShot_at_PulseBegin) * 36)= "))
            Dec((SnapShot_at_PulseEnd - SnapShot_at_PulseBegin) * 36)
            CR
    
            Write(string(" ((SnapShot_at_PulseEnd - SnapShot_at_PulseBegin) * 36) / ClkFreq= "))
            Dec( ((SnapShot_at_PulseEnd - SnapShot_at_PulseBegin) * 36) / ClkFreq)
            CR
            
            Write(string(" (((SnapShot_at_PulseEnd - SnapShot_at_PulseBegin) * 36) / ClkFreq) * 60= "))
            Dec( ( ((SnapShot_at_PulseEnd - SnapShot_at_PulseBegin) * 36) / ClkFreq) * 60)
            CR
            
          Write(string(" RPM= "))
          Dec (RPM)           
          CR
          CR
          CR
          
          'waitcnt (ClkFreq / 2 + cnt)
    
    
    PUB CR
      serial.tx(13)
    
    
    PUB Write (StrPointer)
      serial.str(StrPointer)
    
    
    PUB Writeln (StrPointer)
      serial.str(StrPointer)
      CR
    
    
    PUB Dec(Value)
      serial.dec (Value)           
    
    
    



    connect IO-pIN 10 to IO-PIN 2
    load this version of code into your propeller and watch the debugoutput with PST.EXE

    best regards

    Stefan

    Post Edited (StefanL38) : 12/14/2008 2:39:26 PM GMT
Sign In or Register to comment.