Shop OBEX P1 Docs P2 Docs Learn Events
Hitachi Tri-Axis program code — Parallax Forums

Hitachi Tri-Axis program code

Pablo  MartosPablo Martos Posts: 14
edited 2009-05-05 17:53 in Accessories
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?

Comments

  • Jessica UelmenJessica Uelmen Posts: 490
    edited 2009-05-05 15:33
    Hi Pablo,

    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.
  • Pablo  MartosPablo Martos Posts: 14
    edited 2009-05-05 15:40
    Thanks Michelle!! by the way, is there a way or do you know, how would i display this on an Parallax LCD display?? Source Code?
  • SRLMSRLM Posts: 5,045
    edited 2009-05-05 15:53
    Take a look at the documentation on the product page, and it will give sample code. There is also lots of sample code floating around on the forums.
  • dandreaedandreae Posts: 1,375
    edited 2009-05-05 16:36
    This has been taken care of and it was missing some variables.



    Dave

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dave Andreae

    Parallax Tech Support·
  • Jessica UelmenJessica Uelmen Posts: 490
    edited 2009-05-05 17:53
    Hi Pablo,

    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.
Sign In or Register to comment.