Shop OBEX P1 Docs P2 Docs Learn Events
writing LIGHT readings to eeprom — Parallax Forums

writing LIGHT readings to eeprom

mbreihanmbreihan Posts: 3
edited 2008-11-06 02:45 in Learn with BlocklyProp
I am working on a school project and we have hit a roadblock in our programming. We have two photometers hooked up to the Basic stamp and trying to get them to take alternating light·readings and saving them to eeprom. perhaps someone out there can find the flaw in our program?

writing program


' {$STAMP BS2}
' {$PBASIC 2.5}
z VAR Word
x VAR Word
cnt VAR Word
cnt2· VAR Word
eepromAddress VAR Byte

S0· CON 0
S1· CON 1
S2· CON 2
S3· CON 3
S4· CON 6
S5· CON 7
S6· CON 8
S7· CON 9

HIGH S0
HIGH· S1
LOW· S2
LOW S3
LOW· 4
HIGH· S4
HIGH· S5
LOW S6
LOW S7
LOW 10

FOR z=1 TO 5

FOR x=1 TO 1
COUNT 5, 1000, cnt

FOR eepromAddress = 0 TO 9 STEP 2
· WRITE eepromAddress, Word cnt
NEXT

DEBUG DEC cnt, CR

NEXT

PAUSE 1000

FOR x=1 TO 1
COUNT 11, 1000, cnt2

FOR eepromAddress = 10 TO 19 STEP 2
· WRITE eepromAddress, Word cnt2
NEXT

DEBUG DEC cnt2, CR

NEXT

PAUSE 2000

NEXT

END





reading program

reading program

' {$STAMP BS2}
' {$PBASIC 2.5}

cnt VAR Word
cnt2 VAR Word
eepromAddress VAR Byte

FOR eepromAddress = 0 TO 9 STEP 2
· READ eepromAddress, Word cnt
· DEBUG DEC2 eepromAddress, " ", DEC cnt, CR
NEXT

FOR eepromAddress = 10 TO 19 STEP 2
· READ eepromAddress, Word cnt2
· DEBUG DEC2 eepromAddress, " ", DEC cnt2, CR

NEXT

END

Comments

  • Tracy AllenTracy Allen Posts: 6,664
    edited 2008-11-05 23:52
    What would you say is the roadblock? What happened, or not? Readings displayed? Recording to eeprom?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • mbreihanmbreihan Posts: 3
    edited 2008-11-05 23:58
    When we run the program the debug screen shows all the data correctly but when we run the program to read the data, the same number comes up for all the eepromaddress meant for one photometer. we've figured out that it is displaying the last data reading over and over again for each photometer but we don't know whether it is not writing the data correctly or if the bug is in the program to read the data.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2008-11-06 00:47
    Every time your program reads new data with the COUNT command, it writes it to all 5 of the word locations. So it is no wonder it is left only with the final reading at the end. It seems to me that you want to write one value for each value of z, something like this:

    FOR z=0 TO 4   ' <-- zero to 4
      COUNT 5, 1000, cnt
      eepromAddress = z * 2   ' a new value of eepromAddress for each cnt
      WRITE eepromAddress, Word cnt
      DEBUG DEC cnt, CR
      PAUSE 1000
      COUNT 11, 1000, cnt2
      eepromAdress = eepromAddress + 10   ' offset up 10
      WRITE eepromAddress, Word cnt2
      PAUSE 2000
    NEXT 
    END
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • mbreihanmbreihan Posts: 3
    edited 2008-11-06 02:45
    thank you so much!

    Matt
Sign In or Register to comment.