SX/B and the H48C Tri-Axis Accelerometer
infoseeker34
Posts: 3
Hello!
Question: I am attempting·to aquire data from·an H48C using the SX28AC/DP and coding in SX/B.· This is my first time using the controller/language and I'm having a bit of trouble.· I've been using the sample code given on the site using BS2, but have had to modify it some...
I call to subroutine "get_h48c" from my main statement.· Subroutine "get_h48c" looks like this:
Get_H48C:
···RB = 0
······················· CS = 0
······················· SHIFTOUT········ DIO, CLK, MSBFIRST, VRef\3
·· ···INPUT RB.1··
······················· SHIFTIN········· DIO, CLK, MSBPOST, rvCount\8
······················· SHIFTIN········· DIO, CLK, MSBPOST, rvCount2\5
······················· CS = 1
·······················
···PAUSE··········· 1
··
·· ···RB = 0
······················· CS = 0
······················· SHIFTOUT········ DIO, CLK, MSBFIRST, axis\3
· ···INPUT RB.1
······················· SHIFTIN········· DIO, CLK, MSBPOST, axCount\8
······················· SHIFTIN········· DIO, CLK, MSBPOST, axCount2\5
······················· CS = 1
RETURN
I've verified with my scope that there is data flying around everywhere on my DIO line, but variables rvCount, rvCount2, axCount, axCount2 all stay zero.· I'm using SEROUT to send the data to an XBee, and I've verified that that operation is working correctly.· It seems that I'm not accessing the information correctly.
So here's the question...
Does anyone see anything obviously wrong with what I'm doing here?
any help would be greatly appreciated.
Question: I am attempting·to aquire data from·an H48C using the SX28AC/DP and coding in SX/B.· This is my first time using the controller/language and I'm having a bit of trouble.· I've been using the sample code given on the site using BS2, but have had to modify it some...
I call to subroutine "get_h48c" from my main statement.· Subroutine "get_h48c" looks like this:
Get_H48C:
···RB = 0
······················· CS = 0
······················· SHIFTOUT········ DIO, CLK, MSBFIRST, VRef\3
·· ···INPUT RB.1··
······················· SHIFTIN········· DIO, CLK, MSBPOST, rvCount\8
······················· SHIFTIN········· DIO, CLK, MSBPOST, rvCount2\5
······················· CS = 1
·······················
···PAUSE··········· 1
··
·· ···RB = 0
······················· CS = 0
······················· SHIFTOUT········ DIO, CLK, MSBFIRST, axis\3
· ···INPUT RB.1
······················· SHIFTIN········· DIO, CLK, MSBPOST, axCount\8
······················· SHIFTIN········· DIO, CLK, MSBPOST, axCount2\5
······················· CS = 1
RETURN
I've verified with my scope that there is data flying around everywhere on my DIO line, but variables rvCount, rvCount2, axCount, axCount2 all stay zero.· I'm using SEROUT to send the data to an XBee, and I've verified that that operation is working correctly.· It seems that I'm not accessing the information correctly.
So here's the question...
Does anyone see anything obviously wrong with what I'm doing here?
any help would be greatly appreciated.
Comments
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
"People who are willing to trade their freedom for·security deserve neither and will lose both." Benjamin Franklin
·
FREQ 50000000
PROGRAM START_POINT
'==============================================================================================================
'Constants
'==============================================================================================================
XAxis CON 0
YAxis CON 1
ZAxis CON 2
VRef CON 3
Cnt2Mv CON $CE4C
Gfcnv CON $3852
'==============================================================================================================
'Variables
'==============================================================================================================
axis VAR BYTE
rvCount VAR BYTE
rvCount2 VAR BYTE
axCount VAR BYTE
axCount2 VAR BYTE
CLK VAR RB.0
DIO VAR RB.1
CS VAR RB.2
'=============================================================================================================
'SUBROUTINES
'============================================================================================================
Get_H48C:
RB = 0
CS = 0
SHIFTOUT DIO, CLK, MSBFIRST, VRef\3
INPUT RB.1
SHIFTIN DIO, CLK, MSBPOST, rvCount\8
SHIFTIN DIO, CLK, MSBPOST, rvCount2\5
CS = 1
PAUSE 1
RB = 0
CS = 0
SHIFTOUT DIO, CLK, MSBFIRST, axis\3
INPUT RB.1
SHIFTIN DIO, CLK, MSBPOST, axCount\8
SHIFTIN DIO, CLK, MSBPOST, axCount2\5
CS = 1
RETURN
'=============================================================================================================
'=============================================================================================================
'Main
'=============================================================================================================
START_POINT:
FOR axis = XAxis TO Zaxis
GOSUB Get_H48C
OUTPUT RC.2
SEROUT RC.2, T9600, rvCount
NEXT
GOTO START_POINT
E.O.P....
So all I'm trying to do is gather the info and send it. Actually at this point I'm just checking to see if I have successfully placed the info into a variable. I haven't even begun to try and format the data.
SHIFTOUT DIO, CLK, MSBFIRST, %11\2
SHIFTOUT DIO, CLK, MSBFIRST, VRef\3
SHIFTOUT DIO, CLK, MSBFIRST, %11\2
SHIFTOUT DIO, CLK, MSBFIRST, axis\3
See if that works...
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
"People who are willing to trade their freedom for·security deserve neither and will lose both." Benjamin Franklin
·
While I have you on the line... you wouldn't happen to know if there is any source code floating about for turning the input from this operation into ascii for the purpose of serial transmission?
I'm fairly certain I can accomplish this on my own, but I never want to work harder than completely neccessary. Plus it's always nice to have a reference even if it doesn't suit my app.
- N
Trying to do this in C using the pic16f887 but can't get it to work anyone got any ideas?