Shop OBEX P1 Docs P2 Docs Learn Events
Help with Comparison and Variable Types — Parallax Forums

Help with Comparison and Variable Types

DiablodeMorteDiablodeMorte Posts: 238
edited 2007-04-07 19:12 in BASIC Stamp
'ello everybody,

I've having alittle difficulty getting my IF statement working

Here's my code:
Seconds VAR Byte
AlarmSecond VAR Byte

IF((AlarmSecond = Seconds)) THEN Alarm


The IF statement never returns true!


When ever I refrenced Seconds I usually do it w/ Seconds.HIGHNIB and Seconds.LOWNIB
When I had AlarmSecond defined as such:
AlarmSecond = $21

the comparison worked, but when I derive AlarmSecond from a serin command the comparison fails.
I usually derived Seconds from the following line:
SHIFTOUT DTA, Clk, LSBFIRST, [noparse][[/noparse]%1\1,BrstReg\5,%10\2]
SHIFTIN DTA, Clk, LSBPRE, [noparse][[/noparse]Seconds,Minutes,Hours,Date,Month,Day,Year]




Any help?
Is there a function I'm missing?

Comments

  • ZootZoot Posts: 2,227
    edited 2007-04-07 05:31
    What are you SHIFTINing from? In other words, how is the data formatted from the device that you are reading? Most likely your error is because the data coming in is not in the same format as your AlarmSecond. You will probably need to convert one or the other so they match.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • DiablodeMorteDiablodeMorte Posts: 238
    edited 2007-04-07 16:09
    I'm shifting in from the DS1302 timekeeping chip, the shiftin part of my code comes directly from parallax's sample code for the DS1302.

    How would i convert this data to the right type?
  • ZootZoot Posts: 2,227
    edited 2007-04-07 19:12
    So when you set AlarmSecond to be $21 you mean for it to be "21" seconds, correct? BCD notation just like the DS1302? Seems like it should be OK, then. Are you reading the DS1302 at least once per second?

    Can you post your complete program?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
Sign In or Register to comment.