Shop OBEX P1 Docs P2 Docs Learn Events
Logging data to SD Card - What is the best method? — Parallax Forums

Logging data to SD Card - What is the best method?

HughHugh Posts: 362
edited 2010-02-06 15:39 in Propeller 1
Hi Folks,

I need to log some data that is encoded as 12V = 0, 0V = 1. The timings are 'variable' to say the least so I'd like to be able to cope with some of the faster transitions, though there's nothing the SD card shouldn't be able to handle.

I have the 12V input connected to a TLP-504A opto-isolator and via a repeat loop driving an LED I have verifed that the Prop is seeing the state correctly.

My first two thoughts were:
a) Write the value of the prop counter to the SD card every time the state changed - knowing the clock speed I can then read the data and work out what happened. This would involve writing quite a large number to the SD card quite often.
b) Write the value of the change in prop counter every time the state changed - this would involve writing a smaller number, but I'd have to deal with the roll-over of the counter

Any other thoughts or suggestions? smile.gif

Thanks
Hugh

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hugh - the thinking woman's Geoffrey Pyke.

Comments

  • localrogerlocalroger Posts: 3,452
    edited 2010-02-06 14:51
    Dealing withe the counter roll-over shouldn't be a problem; integer math is circular across the rollover, so if you calculate cnt - oldcnt you will get the amount it changed even across a rollover. This is different from for example most BASICs which will throw an error.
  • HughHugh Posts: 362
    edited 2010-02-06 15:39
    localroger said...
    Dealing withe the counter roll-over shouldn't be a problem; integer math is circular across the rollover, so if you calculate cnt - oldcnt you will get the amount it changed even across a rollover. This is different from for example most BASICs which will throw an error.

    Aha! I didn't know that - thanks. That makes all the difference!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Hugh - the thinking woman's Geoffrey Pyke.
Sign In or Register to comment.