Shop OBEX P1 Docs P2 Docs Learn Events
Time clock — Parallax Forums

Time clock

sidecar-racersidecar-racer Posts: 82
edited 2011-11-12 09:13 in Propeller 1
I know this is a simple task but after spending a day batting my head, I thought I'd ask the experts .
I have a loop running at 100ms rep rate for telemetry logging.
In the loop I have 4 byte varibles, hours, minutes, seconds, and tenths of seconds.
These varibles increment correctly and will display on CRT
I want to create a string in HH:MM:SS.S format from these varibles to insert in SD-FAT file record (Excel CSV format)

Any thoughts??
Rick Murray

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-11-10 21:45
    There's an AppNote on how to use a SD card.

    EDIT: I just looked through this code again. This is a really old example. I'll try to find a newer (better) example tomorrow. This code is very akward.

    Here are parts of an old program that does this. I don't think the SD card methods in this example are named the same as they are in the newest FAT driver. I think the clock driver is an old one too.

    The AddDecToString method is probably the most useful method (of those in the code below) to help you with what you want to do.
    OBJ
      Tv : "tv_terminal"                                    ' Uses two cogs
      Sd : "FATEngine.spin"                                 ' Uses one cog
      Clock : "RTCEngine.spin"                              ' no added cog, uses I2C lines
      
    
    PUB RecordData | indexPrivate2, localIndex
          
            ' write other data
            Sd.writeCharacter(44) ' a coma seperates fields
            Sd.writeCharacters(@timeArray + 5) ' I don't want to write the first five characters in the array
            Sd.writeCharacter(13)
            Sd.writeCharacter(10) ' New line (new row in Excel)
            
    
     PRI SendTime
      days := Clock.getday
      years := Clock.getyear
       months := Clock.getmonth
      date := Clock.getdate         '(_i2cSCL, _Address)
      hours := Clock.gethours
      minutes := Clock.getminutes
      seconds := Clock.getseconds
      AddDecToString(years, 0)
      AddDecToString(months, 1)
      AddDecToString(date, 2)
      AddDecToString(hours, 3)
      AddDecToString(minutes, 4)
      AddDecToString(seconds, 5)
       
    PRI AddDecToString(value, position) | indexPrivate
      if position == 0
        byte[@TimeArray][position * 3 + 5] := value / 1000 + "0"
        value //= 1000
        byte[@TimeArray][position * 3 + 6] := value / 100 + "0"
        value //= 100
      byte[@TimeArray][position * 3 + 7] := value / 10 + "0"
      value //= 10
      byte[@TimeArray][position * 3 + 8] := value + "0"
    
    

    Duane
  • sidecar-racersidecar-racer Posts: 82
    edited 2011-11-12 09:13
    Thanks, Duane.
    Your info put me on the right track. Progress continues
    Rick
Sign In or Register to comment.