Recording Data
Maxwell
Posts: 3
Hi everyone, was hoping I could get some help with recording some data for the project I'm working on.
I'm building·a simple pressure sensor using the Board of Education, and had a pre-written program that I'm using (From the book 50 model rocket projects for the Evil Genius).· I get an error message: "Label is Missing ':' " and I'm not sure what to change.· The I2COUT is where I'm getting the error message.
The program is listed below, and any help anyone can give me will be greatly appreciated.
Also, what do I do to make sure that I don't overwrite the program when taking data.
'·· Project 3
'·· BarometricAltimeter.bas
'·· {$STAMP BS2sx}
'·· {$PBASIC 2.5}
'·· {$PORT COM3}
'
' [noparse][[/noparse] Pin assignments ]
G_SWITCH· PIN······ 1········ ' Acceleration switch
ADC_SCLK· PIN······ 0········ ' ADC serial clock pin
ADC_CS··· PIN······ 1········ ' ADC chip select pin
ADC_DATA· PIN······ 2········ ' ADC serial data pin
EEPROM··· PIN······ 0········ ' EEPROM data pin is 0; EEPROM clock pin is 1
' [noparse][[/noparse] Constant definitions ]
EEPROM_WRITE· CON·· %10100000 ' Control code to perform write operation to I2C EEPROM
EEPROM_SIZE·· CON·· 8192···· ' Size in bytes of EEPROM
' [noparse][[/noparse] Variable definitions ]
adc_value VAR······ Word····· ' Value read from ADC
address·· VAR······ Word····· ' Address in EEPROM to write data
eeprom_data· VAR··· Byte····· ' Data byte to be written to EEPROM
' [noparse][[/noparse] Initialisation ]
INPUT G_SWITCH··············· ' Sets g-switch pin to input
HIGH ADC_CS·················· ' Turns off ADC
address = 0
' [noparse][[/noparse] Main program ]
Wait_for_liftoff:
· IF G_SWITCH=0 THEN wait_for_liftoff··· ' Waiting for lift off
DO
· GOSUB Read_ADC
· eeprom_data = adc_value.HIGHBYTE
· GOSUB Write_EEPROM
· eeprom_data = adc_value.LOWBYTE
· GOSUB Write_EEPROM
LOOP WHILE address < EEPROM_SIZE
END
' [noparse][[/noparse] Subroutines ]
Read_ADC:
· LOW ADC_CS
· SHIFTIN ADC_DATA,ADC_SCLK,MSBPOST,[noparse][[/noparse]adc_value\12]
· HIGH ADC_CS
RETURN
Write_EEPROM:
· I2COUT EEPROM, EEPROM_WRITE, address.HIGHBYTE\address.LOWBYTE, [noparse][[/noparse]eeprom_data]
· address = address + 1
RETURN
Post Edited (Maxwell) : 6/28/2007 10:24:07 PM GMT
I'm building·a simple pressure sensor using the Board of Education, and had a pre-written program that I'm using (From the book 50 model rocket projects for the Evil Genius).· I get an error message: "Label is Missing ':' " and I'm not sure what to change.· The I2COUT is where I'm getting the error message.
The program is listed below, and any help anyone can give me will be greatly appreciated.
Also, what do I do to make sure that I don't overwrite the program when taking data.
'·· Project 3
'·· BarometricAltimeter.bas
'·· {$STAMP BS2sx}
'·· {$PBASIC 2.5}
'·· {$PORT COM3}
'
' [noparse][[/noparse] Pin assignments ]
G_SWITCH· PIN······ 1········ ' Acceleration switch
ADC_SCLK· PIN······ 0········ ' ADC serial clock pin
ADC_CS··· PIN······ 1········ ' ADC chip select pin
ADC_DATA· PIN······ 2········ ' ADC serial data pin
EEPROM··· PIN······ 0········ ' EEPROM data pin is 0; EEPROM clock pin is 1
' [noparse][[/noparse] Constant definitions ]
EEPROM_WRITE· CON·· %10100000 ' Control code to perform write operation to I2C EEPROM
EEPROM_SIZE·· CON·· 8192···· ' Size in bytes of EEPROM
' [noparse][[/noparse] Variable definitions ]
adc_value VAR······ Word····· ' Value read from ADC
address·· VAR······ Word····· ' Address in EEPROM to write data
eeprom_data· VAR··· Byte····· ' Data byte to be written to EEPROM
' [noparse][[/noparse] Initialisation ]
INPUT G_SWITCH··············· ' Sets g-switch pin to input
HIGH ADC_CS·················· ' Turns off ADC
address = 0
' [noparse][[/noparse] Main program ]
Wait_for_liftoff:
· IF G_SWITCH=0 THEN wait_for_liftoff··· ' Waiting for lift off
DO
· GOSUB Read_ADC
· eeprom_data = adc_value.HIGHBYTE
· GOSUB Write_EEPROM
· eeprom_data = adc_value.LOWBYTE
· GOSUB Write_EEPROM
LOOP WHILE address < EEPROM_SIZE
END
' [noparse][[/noparse] Subroutines ]
Read_ADC:
· LOW ADC_CS
· SHIFTIN ADC_DATA,ADC_SCLK,MSBPOST,[noparse][[/noparse]adc_value\12]
· HIGH ADC_CS
RETURN
Write_EEPROM:
· I2COUT EEPROM, EEPROM_WRITE, address.HIGHBYTE\address.LOWBYTE, [noparse][[/noparse]eeprom_data]
· address = address + 1
RETURN
Post Edited (Maxwell) : 6/28/2007 10:24:07 PM GMT
Comments
The very last line of your program is "RETURNg"; sure looks suspicious! [noparse]:)[/noparse] Typo, or is it really there?
As far as your EEPROM question, I am not sure my suggestion is very good: Count the bytes you write and DON'T write more than the EEPROM's capacity.
Good luck!
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
Edit -- Nope, just verified, the BS2sx doesn't support I2COUT, only the BS2p, pe, and px.
·
Nuts&Volts articles 79, 85, and 115 show you how to do I2C when you don't have I2COUT/I2CIN.
·I have built several rocket payloads and have plenty of pics, schematics and code if you would like to see them.
Have fun,
Jim
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Arguing with an engineer is like mud wrestling with a pig.
You both end up covered in mud and the pig likes it.