Problems with programming accelerometer and gyroscope with BS2px
trannh
Posts: 24
Can any body help me with programming the BS2px stamp? I've been look at What's a Microcontroller and all the datasheets for the bs2px, as well as datasheets and test codes for the accelerometer and gyroscope I am using and I can't figure it out. I'm using the LISY200 Gyroscope and the MMA7455 3-axis accelerometer. I want to be able to get graphs for about 5 seconds of testing. Can anybody help me with this problem? I don't know where to start here.
Post Edited (trannh) : 4/21/2010 8:17:31 PM GMT
Post Edited (trannh) : 4/21/2010 8:17:31 PM GMT
Comments
Use the Attachment Manager (from the Post Reply button dialog) to attach a copy of your program to a message. If you don't have a program yet, you'll have to start with the demo programs for the gyroscope and accelerometer and write your own program first.
It's also important to add a subject to your thread. Use the pencil icon in the upper righthand corner of your first message.
The problems that I have with the program is that the accelerometer I am using, the MMA7455 3-axis accelerometer module, does not have a pin for the x axis data, the y-axis data, and the z-axis data. I'm not sure how to get data from those three axes since the sensor only has one output data pin. Could somebody help me solve this problem? Also, how to do open .spin files? Thank you so much
Post Edited (trannh) : 4/22/2010 1:03:25 AM GMT
And school!
@trannh
Spin files are for the Propeller. They won't work on the BS2, and you should probably ignore them. If you really want to open them, then you can just use a text editor.
Look at the sample code provided on each of the pages for the sensors that you're using. Assuming that you're using the modules from Parallax, they provide plenty of bs2 code to get started.
I would put each of the sensor interface blocks of code into their own subroutine, and call that from your record method. Also, I'd get rid of the whole menu option thing. All that you need is to wait for a keystroke to get started, and then just start streaming the data. When you start programming, start with something simple and slowly add complexity, all the while testing it to make sure that you haven't broken it.
Finally, never post a program that doesn't compile (ctrl+T). It indicates that you aren't willing to solve even the simple problems.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Powered by enthusiasm
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
You asked how the x, y, and z data get out through only a couple of pins. If you read the documentation, you'll see that the data is held in several registers within the MMA7455L3. Your program sends a register address and a byte of data to write to one of the registers or sends a register address, then reads a byte of data to read from one of the registers.
You should be able to take the demo programs and incorporate part of them into your program to read the x,y, and z values.
Data sample format. I have index numbers in the first slot, then three acceleration channels, then two gyro channels.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Powered by enthusiasm
FOR eeIndex = Records TO RecordsEnd STEP 1
READ eeIndex, XAccel
XAccel = XAccel - 100
READ eeIndex + 1, YAccel
YAccel = YAccel - 100
READ eeIndex + 2, ZAccel
ZAccel= ZAccel - 100
READ eeIndex +3, value
value= value -100
DEBUG DEC eeIndex, CRSRX, 7, SDEC XAccel, CRSRX, 14, SDEC YAccel, CRSRX, 21, SDEC ZAccel, CRSRX, 28, DEC5 value, CR
Also, when I try to run my program, this message pops up: Data occupies same location as program. What does this mean and how can I fix it?
Post Edited (trannh) : 4/23/2010 12:02:52 AM GMT
The message means that you're trying to store data where there the program data already. Look up the READ and WRITE commands in the BS2 manual if you want to know more, but you don't really need it for this project.
The data that I showed in my previous post was entirely fictitious. It was merely meant to show how you could format it.
Finally, a little forum support hint. If you're going to post code in the body of your post then a) make sure it isn't a whole lot of code and b) use the [noparse][[/noparse] code ] tags (without the spaces) or the code block option to put the code in a special box that keeps the formating. The sample data that I posted above is an example.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Powered by enthusiasm
index x-axis y-axis z-axis gyro