Shop OBEX P1 Docs P2 Docs Learn Events
Recording Data — Parallax Forums

Recording Data

MaxwellMaxwell Posts: 3
edited 2007-06-29 21:53 in BASIC Stamp
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

Comments

  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2007-06-28 21:17
    Maxwell--

    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.
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-06-28 21:40
    I thought the I2COUT command was in the 'p' series, not the 'sx' series -- am I wrong in that?

    Edit -- Nope, just verified, the BS2sx doesn't support I2COUT, only the BS2p, pe, and px.
    ·
  • MaxwellMaxwell Posts: 3
    edited 2007-06-28 22:22
    allanlane5 said...
    I thought the I2COUT command was in the 'p' series, not the 'sx' series -- am I wrong in that?

    Edit -- Nope, just verified, the BS2sx doesn't support I2COUT, only the BS2p, pe, and px.
    The initial program was written for a BS2p, I'd greatly appreciate any suggestions on how to alter the program for the BS2sx, I think I'm a bit far out of my field here.
    Bill said...
    The very last line of your program is "RETURNg"; sure looks suspicious! [noparse]:)[/noparse] Typo, or is it really there?
    ·Yeah, the g was just me fat fingering after copying it over, oops! Thank you for catching that, I'll edit it out of the initial post. Thank you for your advice, as well! [noparse]:)[/noparse]
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-06-29 00:37
    Go over to the Nuts&Volts articles, in the Downloads section, at the Parallax site.·

    Nuts&Volts articles 79, 85, and 115 show you how to do I2C when you don't have I2COUT/I2CIN.

  • Mike15Mike15 Posts: 109
    edited 2007-06-29 04:09
    ·I have built a rocket payload simular except I used a SPI eeprom (free sample from microchip) to record data from an accelerometer and pressure sensor.

    ·I have built several rocket payloads and have plenty of pics, schematics and code if you would like to see them.
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-06-29 15:30
    Good, except SPI uses SHIFTIN/SHIFTOUT, and all BS2's have those.
  • MaxwellMaxwell Posts: 3
    edited 2007-06-29 19:15
    Thank you all very much for your help!
  • Jim_BJim_B Posts: 3
    edited 2007-06-29 21:53
    The Evil Genius book on rockets is where I first learned about basic STAMP and I've been hooked ever since :-)·· I did notice that the editors missed a few minor typos in the .bas code text for some of the data acquisition projects in the hard copy, they weren't obvious until I became a little more·familiar with pbasic.· You can download the corrected .BAS files from the publishers website at www.books.mcgraw-hill.com/authors/harperrockets.· These corrected source code files are a real time-saver, especially if you're·trying to type in the lookup tables for the thermocouples in project 8!·
    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.
Sign In or Register to comment.