This is an awesome little sensor. Below is the working code for the BAP 28:
;Sensor Port Constants
;
;ABB Pin Label<-> ATOM PRO Pin name
;AX0 <-> P19
;AX1 <-> P18
;AX2 <-> P16
;AX3 <-> P17
accelyport con P16 ;y-axis port for the 2-axis accelerometer
accelxport con P17 ;x-axis port for the 2-axis accelerometer
yaccel var word
xaccel var word
GOGETACCEL
ADIN accelyport, yaccel
ADIN accelxport, xaccel
serout s_out,i9600,"Acceleration Y-axis:",dec yaccel,13]
serout s_out,i9600,"Acceleration X-axis:",dec xaccel,13]
pause 1000
goto GOGETACCEL
This code outputs the tilt on Y-axis and X-axis every second on terminal 1 (s_out).
I’ve been experimenting with this code for awhile and, I have been trying to figure out what value it gives me when it is level with the ground and not moving. So far though, it has been giving me a value from around 400 to 600 which I don’t find very consistant. What should I do? Is this sort of accuracy expected in the first place?
I’m not sure if what you’re seeing is normal or not. You can try adding caps to the analog outputs to filter / smooth the response. There are even solder pads for doing this.
I’ve used a couple different accel chips and that range seems a little wide. On my accel boards I get about that range from when it’s pointing with gravity to when it’s pointing away from gravity. Which accel chip is on that board?
Are their any schematics on how to add caps to the sensor? Due to my amazing amount of noobiness I don’t really know that much about how to filter analog outputs this way.
The only one lynxmotion sells of course.
lynxmotion.com/p-606-lynxmotion-buffered-2g-accelerometer.aspx
would one be correct in thinking that to use this sensor with the current phoenix code it would look like this?
the idea is that the body stays level on incline?
[code];[SERIAL CONNECTIONS]
cSSC_OUT con P11 ;Output pin for (SSC32 RX) on BotBoard (Yellow)
cSSC_IN con P10 ;Input pin for (SSC32 TX) on BotBoard (Blue)
cSSC_BAUD con i115200 ;SSC32 BAUD rate 38400 115200
;Body Inverse Kinematics
BodyRotX var sbyte ;Global Input pitch of the body
BodyRotZ var sbyte ;Global Input roll of the body
XAxis con P16 ;X-Axis InPut AX2
ZAxis con P17 ;Z-Axis InPut AX3
X_Accel var word
Z_Accel var word
BodyRotX = BodyRotX + X_Accel
BodyRotZ = BodyRotZ + Z_Accel
READSENSOR
ADIN XAxis, X_Accel
ADIN ZAxis, Z_Accel
serout cSSC_OUT,cSSC_BAUD,“BodyRotX:”,dec X_Accel,13]
serout cSSC_OUT,cSSC_BAUD,“BodyRotZ:”,dec Z_Accel,13]
pause 1000
goto READSENSOR[/code]