Extracting Digits from SERIN
Hitman
Posts: 5
Hello I have (again) A problem with teh BS2.
I want to extract two digits from 'sdata' (see example)
SERIN 9, 396,[noparse][[/noparse]STR sdata\8]
I have used '' sdata(0) " and " sdata(1) " but I want them together in one nibble.
E.g. the 'sdata\8' is a date (for example 12-12-07) I want the day so I can compare it with another day·this comes from a DS1302 RTC.
When I use sdata(0)+sdata(1) it just increases. Same as sdata(0+1).
I have looked in the stamp manual but I can't find anything.
Thanks in advance
[noparse][[/noparse]Subject added by Moderator]
Post Edited By Moderator (Chris Savage (Parallax)) : 2/7/2007 9:08:58 PM GMT
I want to extract two digits from 'sdata' (see example)
SERIN 9, 396,[noparse][[/noparse]STR sdata\8]
I have used '' sdata(0) " and " sdata(1) " but I want them together in one nibble.
E.g. the 'sdata\8' is a date (for example 12-12-07) I want the day so I can compare it with another day·this comes from a DS1302 RTC.
When I use sdata(0)+sdata(1) it just increases. Same as sdata(0+1).
I have looked in the stamp manual but I can't find anything.
Thanks in advance
[noparse][[/noparse]Subject added by Moderator]
Post Edited By Moderator (Chris Savage (Parallax)) : 2/7/2007 9:08:58 PM GMT
Comments
sdata VAR Byte(8)
Month VAR Byte
Day VAR Byte
Year VAR Byte
main:
· DEBUGIN STR sdata\8
· Month=((sdata(0)-48)*10) + (sdata(1)-48)
· Day=((sdata(3)-48)*10) + (sdata(4)-48)
· Year=((sdata(6)-48)*10) + (sdata(7)-48)
· DEBUG ? Month,? Day,? Year
· DEBUG "Month + Day = ",DEC month + day
GOTO main
Jeff T.
Thanx.
Emile T.
I have question pertaining to logging data from a gps string. My problem now is verifying that the string is actually stored in the EEprom. I am trying to pull out the·characters 10-16·of the string. The problem with GPS is that it only works outside, therefore my program only has write instructions in it. Can anyone give me a suggetion on how I would verify that this data was actually stored.
//my code
' {$STAMP BS2}
sio···· CON·· 6
gps···· VAR·· Byte(7)
eeAddr· VAR·· Byte(7)
samples CON·· 5
log···· DATA· 5
endLog· CON·· log+samples-1
SERIN 6, 188, [noparse][[/noparse]WAIT("GPRMC,"), SKIP 8, STR gps\7]
FOR eeAddr = log TO endLog
WRITE eeAddr, gps
PAUSE 30000
NEXT
STOP
Unless the program is very large, it won't affect the low end of program memory when it's downloaded.
but I would add a WAIT to synch better with the data:
SERIN 9, 396,[noparse][[/noparse]WAIT ("!"),DEC2 Month,SKIP 1, DEC2 Day,SKIP 1,DEC2 Year]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR