Shop OBEX P1 Docs P2 Docs Learn Events
PLX-DAQ and the H48C accelerometer — Parallax Forums

PLX-DAQ and the H48C accelerometer

zagnorfzagnorf Posts: 2
edited 2008-01-26 23:30 in BASIC Stamp
I'm trying to make a tri-axis, short period seismometer, using the H48C accelerometer and the PLX-DAQ to graph seismic waves.
I need a little help with the code... I can't seem to get the data to move to the next row. It just rewrites itself in row 1. I'm a noob when it comes to code.

Here is what I have so far... Any help would be greatly appreciated. Thanks in advance - Josh



'
[noparse][[/noparse] I/O Definitions ]

Dio PIN 15 ' data to/from module
Clk PIN 14 ' clock output
CS PIN 13 ' active-low chip select


'
[noparse][[/noparse] Constants ]

XAxis CON 0 ' adc channels
YAxis CON 1
ZAxis CON 2
VRef CON 3
sPin CON 16 'Serial Pin - P16, Programming port
Baud CON 84 'Baud mode for a rate of 9600, 8-N-1
'BS2P, BS2SX use 240 for 9600, 8-N-1

'
[noparse][[/noparse] Variables ]

axis1 VAR Byte
axis2 VAR Byte
axis3 VAR Byte
x VAR Word
y VAR Word
z VAR Word
Row VAR Word


Main:
DO
FOR axis1 = XAxis TO XAxis
LOW CS
SHIFTOUT Dio, Clk, MSBFIRST, [noparse][[/noparse]%11\2, axis1\3]
SHIFTIN Dio, Clk, MSBPOST, [noparse][[/noparse]x\13]
HIGH CS
NEXT
FOR axis2 = YAxis TO YAxis
LOW CS
SHIFTOUT Dio, Clk, MSBFIRST, [noparse][[/noparse]%11\2, axis2\3]
SHIFTIN Dio, Clk, MSBPOST, [noparse][[/noparse]y\13]
HIGH CS
NEXT
FOR axis3 = ZAxis TO ZAxis
LOW CS
SHIFTOUT Dio, Clk, MSBFIRST, [noparse][[/noparse]%11\2, axis3\3]
SHIFTIN Dio, Clk, MSBPOST, [noparse][[/noparse]z\13]
HIGH CS

PAUSE 200
NEXT
SEROUT sPin,Baud,[noparse][[/noparse]CR,"LABEL,x axis,y axis,z axis",CR]
SEROUT sPin,Baud,[noparse][[/noparse]"DATA,", DEC x,",", DEC y,",", DEC z,CR]
' Request last row of data
SEROUT sPin,Baud,[noparse][[/noparse]"ROW,GET",CR]
SERIN sPin, Baud,200,TimeOut,[noparse][[/noparse]DEC Row]
' If Row is or exceeds 300, set row back to 2
IF row >= 300 THEN SEROUT sPin,Baud,[noparse][[/noparse]"ROW,SET,2",CR]
Timeout:

LOOP

Comments

  • FranklinFranklin Posts: 4,747
    edited 2008-01-26 05:42
    I don't understand the for loops and I don't see where you are incrementing row. Does this code compile and load on a stamp? Could you ATTACH the actual program you are running? Thanks.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • zagnorfzagnorf Posts: 2
    edited 2008-01-26 14:55
    I rewrote the code for stamp plot. It was a lot more strait forward....

    Post Edited (zagnorf) : 1/26/2008 9:51:04 PM GMT
  • skylightskylight Posts: 1,915
    edited 2008-01-26 23:30
    From the help file:


    attachment.php?attachmentid=74055


    attachment.php?attachmentid=74056

    Looks like you need to set the variable row with the first statement DEBUG "ROW,GET",CR and DEBUGIN DEC row

    then using ROW,SET,Value you put DEBUG "ROW,SET,(replace the 2 with the variable row+1 here)",CR

    Post Edited (skylight) : 1/26/2008 11:45:49 PM GMT
    806 x 112 - 3K
    806 x 48 - 1K
Sign In or Register to comment.