Hitachi Tri-Axis program code
Pablo Martos
Posts: 14
i am trying to do the demo from the parallax spec sheet that u can download on parallax now the code is of the following........
'
[noparse][[/noparse] Initialization ]
Reset:
HIGH CS ' deselect module
DEBUG CLS, ' paint display
"=========================", CR,
"H48C 3-Axis Accelerometer", CR,
"=========================", CR,
CR,
" Count Volts G ", CR,
"
", CR,
"VRef ", CR,
" X ", CR,
" Y ", CR,
" Z "
ok, i did that and i have that output in the debugger window. then i do this...
'
[noparse][[/noparse] Program Code ]
Main:
FOR axis = XAxis TO ZAxis ' loop through each axis
GOSUB Get_H48C ' read vRef & axis counts
dValue = rvCount ' display vRef count
DEBUG CRSRXY, 6, 6
GOSUB RJ_Print
dValue = axCount ' display axis count
DEBUG CRSRXY, 6, (7 + axis)
GOSUB RJ_Print
mVolts = rvCount ** Cnt2Mv ' convert vref to mv
DEBUG CRSRXY, 13, 6, ' display
DEC (mVolts / 1000), ".",
DEC3 mVolts
mVolts = axCount ** Cnt2Mv ' convert axis to mv
DEBUG CRSRXY, 13, (7 + axis),
DEC (mVolts / 1000), ".",
DEC3 mVolts
' calculate g-force
' -- "gForce" is signed word
IF (axCount >= rvCount) THEN
gForce = (axCount - rvCount) ** GfCnv ' positive g-force
ELSE
gForce = -((rvCount - axCount) ** GfCnv) ' negative g-force
ENDIF
DEBUG CRSRXY, 20, (7 + axis), ' display g-force
" " + (gForce.BIT15 * 13),
DEC1 (ABS(gForce) / 100), ".",
DEC2 ABS(gForce)
NEXT
PAUSE 200
GOTO Main
when i hit the RUN button, i get this error message, "expected a variable" and the "axis" letters are highlighted (bottom of Main[noparse]:)[/noparse] whats wrong?
'
[noparse][[/noparse] Initialization ]
Reset:
HIGH CS ' deselect module
DEBUG CLS, ' paint display
"=========================", CR,
"H48C 3-Axis Accelerometer", CR,
"=========================", CR,
CR,
" Count Volts G ", CR,
"
", CR,
"VRef ", CR,
" X ", CR,
" Y ", CR,
" Z "
ok, i did that and i have that output in the debugger window. then i do this...
'
[noparse][[/noparse] Program Code ]
Main:
FOR axis = XAxis TO ZAxis ' loop through each axis
GOSUB Get_H48C ' read vRef & axis counts
dValue = rvCount ' display vRef count
DEBUG CRSRXY, 6, 6
GOSUB RJ_Print
dValue = axCount ' display axis count
DEBUG CRSRXY, 6, (7 + axis)
GOSUB RJ_Print
mVolts = rvCount ** Cnt2Mv ' convert vref to mv
DEBUG CRSRXY, 13, 6, ' display
DEC (mVolts / 1000), ".",
DEC3 mVolts
mVolts = axCount ** Cnt2Mv ' convert axis to mv
DEBUG CRSRXY, 13, (7 + axis),
DEC (mVolts / 1000), ".",
DEC3 mVolts
' calculate g-force
' -- "gForce" is signed word
IF (axCount >= rvCount) THEN
gForce = (axCount - rvCount) ** GfCnv ' positive g-force
ELSE
gForce = -((rvCount - axCount) ** GfCnv) ' negative g-force
ENDIF
DEBUG CRSRXY, 20, (7 + axis), ' display g-force
" " + (gForce.BIT15 * 13),
DEC1 (ABS(gForce) / 100), ".",
DEC2 ABS(gForce)
NEXT
PAUSE 200
GOTO Main
when i hit the RUN button, i get this error message, "expected a variable" and the "axis" letters are highlighted (bottom of Main[noparse]:)[/noparse] whats wrong?
Comments
That message means you have not declared that variable at the beginning of the program. Be sure that all your variables have been declared and you should be fine.
Hope this helps,
Jessica
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jessica Uelmen
Education Department
Parallax, Inc.
Dave
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dave Andreae
Parallax Tech Support·
You can also check out Smart Sensors and Applications Chapter 1. It introduces displaying text and characters to the Parallax Serial LCD, and should help you get started!
Happy Developing!
Jessica
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jessica Uelmen
Education Department
Parallax, Inc.