accelerometer and gyroscope
trannh
Posts: 24
Hi,
I am a biomedical engineering student and I am doing a project on using an accelerometer and a gyroscope to measure acceleration of the foot (x/y axis) and rotational velocity of the foot. I was wondering if anybody could give me an idea on how I can make these sensors output the necessary data. I'm having a hard time finding a way to incorporate an accelerometer and gyroscope onto a shoe. How can I allow the sensors to output digitally onto a computer? I am using the accelerometer and gyroscope modules right from Parallax. Any help would be greatly appreciated. I just need something to help me get going. Thank you.
I am a biomedical engineering student and I am doing a project on using an accelerometer and a gyroscope to measure acceleration of the foot (x/y axis) and rotational velocity of the foot. I was wondering if anybody could give me an idea on how I can make these sensors output the necessary data. I'm having a hard time finding a way to incorporate an accelerometer and gyroscope onto a shoe. How can I allow the sensors to output digitally onto a computer? I am using the accelerometer and gyroscope modules right from Parallax. Any help would be greatly appreciated. I just need something to help me get going. Thank you.
Comments
Then run wires from the sensors up to a belt which would hold a microcontroller and a transmitter to transmit the information to another microcontroller and then to the PC?
Communications...
http://www.parallax.com/Store/Accessories/CommunicationRF/tabid/161/CategoryID/36/List/0/Level/a/Default.aspx?SortField=ProductName,ProductName
Then, when you're done sampling, debug the eeprom data to the stamp software, which you can copy directly into EXCEL, Matlab, etc...
Hope that helps,
Dave
P.S. If you can, low-pass filter your sensors prior to the ADC input... accelerometers and MEMS gyros can be a little noisy. Also put a cap across the sensor's power supply and ground, as well as at the ADC reference voltage and ground. It'll help you get smoother, less noisy data.
bill190: That's a good idea. I had a similar idea. Would the Velcro straps be strong enough to hold the system together? I plan on putting the sensors on the side of the shoe since that would allow for the best data collection. Also, how would the straps connect to the sensors?
Some microcontrollers have on-board ADCs, but the stamp doesn't, so you need to add it if you use a stamp. I'd recommend at least a 10-bit ADC depending on your sensor sensitivity. If you get one with 4 channels, you'll only need 1 chip.
As far as your program goes, basically it would go something like this:
Wait for start event (like a button push)
LOOP:
read ADC value for accelerometer X-dir
read ADC value for accelerometer Y-dir
read ADC value for gyro
write values to EEPROM (<4 bytes if you're using a 10-bit ADC)
if address is >65530 then end
increment address
pause X milliseconds
goto LOOP
end
To debug, upload a new program that'll read the data off the EEPROM 4 bytes at a time and debug it to the computer screen.
Hope that helps,
Dave
Just using velcro would have a bit of "wobble" to it I would imagine.
More firmly attached would be to screw or glue the sensors to the shoe, but then you would need different shoes for each person.
If it is just for one person, then maybe get a pair of shoes for just this and glue/screw/bolt or whatever - the sensors onto the shoes.
There is a learning curve to this "fastening" business! Probably the best thing to do would be to take the shoes and sensors to a small local hardware store. Then look for the old guy there. Show him what you want to do, then I would bet he would have some ideas.
Also note that the accelerometers and gyroscope sold by parallax do not require an external ADC. The modules have all the analog circuitry incorporated on the board itself, so you just need to use serial communication to get the data. As always, look on the product page for sample code. All the Parallax products come with sample code for the BS2 that demonstrates how the sensor can be used.
You may also want to consider a faster BS2 such as the BS2px, or consider the Propeller as a microcontroller. I don't think the stock BS2 would have enough memory or speed to give you useful data in a project such as this. Also, you may want to consider streaming the data (either wirelessly or through a cable) to your computer, and log it there. The advantage is that you can see the data in real time, you don't have to recover it, and you can have a computer program parse the data on the fly. Plus, it gives you immediate feedback on if it's working or not. Of course, it may not be suitable for your application/
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Powered by enthusiasm
Also, can the board hold all the necessary components: the two sensors, the microcontroller, and the transmitter (if used), as well as the 9V battery? Should I use multiple boards or would that be too cumbersome or big for proper placement on the heel?
I feel like directly connecting the board to the computer using a cable would be best for my project. Also, what exactly is the order of "construction"? I would like to keep everything on one board that can be mounted on the back of the foot. So the sensors would have to be sodered to the board, along with the microcontroller?
Does anybody think using the following microcontroller would work:
https://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/CategoryID/9/List/0/SortField/0/Level/a/ProductID/9/Default.aspx
(does it already have an ADC?)
I want to thank everybody for helping me out and giving me their input. Thank you.
The BS2sx might work, but it would depend on how fast you want to sample. If you just want slow motion then 10Hz (my estimate with the sx) would be okay. Otherwise, I'd go with the BS2px. It can send serial data faster, which is a big boost in your throughput. Of course, if you're comfortable with programming then the Propeller would work as well, although the initial learning curve IMHO is steeper.
As for the design, unless you are making your own custom PCB (board) you may want to consider separating the sensors and the other things (microcontroller and power supply, namely). The more mass that you attach to the sensors, the more likely it is that it will cause bad measurements as the foot accelerates.
Accelerometers can be used for either rotation or linear acceleration, but not both at the same time. If you want both datasets then you need a gyroscope. Note also that if you want full three dimensional motion than you need three axes of acceleration data and three axes of gyro data. Theres lots more information on this subject floating around on the internet that you can find.
To go any further, we need to know more about your project, including the type of motion, it's speed, and the application.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Powered by enthusiasm
For my project I want the accelerometer to give me data along 2 axes, to see acceleration upward and forward during walking. I want the gyroscope to measure the rotational velocity of the ankle as you lift your foot up during walking. I was told that using sampling at 50 Hz or more would be sufficient for this. I only want to record data for 5-10 ft of walking or about 5 seconds of recording. What do you recommend I get in regards to the board, microcontroller, or any connections needed? Also, where do I get the program needed to read the data from the sensors?
There will be example code for both sensors at the bottom of their downloads pages. You will need to adapt the sample code to your application.
For more in-depth programming and·datalogging applications for the·Memsic 2-axis Accelerometer with a BASIC Stamp, see Smart Sensors and Applications - the text and sample code are free downloads. For beginner BASIC Stamp programming, see What's a Microcontroller - it's also included as a PDF in the BASIC Stamp Editor Software.
-Steph
The microcontroller will always need some sort of connection to the computer, if only to program it. I suggest that you start reading What's A Microcontroller, pdf available from the Parallax website. It will give you an introduction to PBASIC programming. You can use the sample code that is included with each of the sensors to give you a start, but you will have to program the application yourself. It isn't a particularly difficult program as far as these things go.
To get the data from the microcontroller to the PC you have two options: wireless or wired. The wired option is easier, and may or may not be possible. I don't know, but what I would do is buy some USB extension cables that would go the entire distance that you expect to get the motion. It would probably be better if the cables were powered and shielded, but plain vanilla might work. You could also put the subject on a treadmill and then you wouldn't need an extension cable. Alternatively, you could use wireless. This is a bit more involved, but I would use the XBee modules and adapter boards from Parallax (one 3.3v to 5v board and 1 USB board). You'll have to reconfigure them to have a higher baud rate, since 9600 is just too slow. The reconfiguration is simple by using the free X-CTU software.
As far as the board you'll probably want to go with something that is soldered, since that is more mechanically robust than a solderless breadboard (like the BOE). The carrier board family would work.
Where to go from here? Amass knowledge about your materials: read all the datasheets, read "What's a Microcontroller", learn some basic electric circuits (what WAM provides is enough), and do some test programs and connections to make sure you know everything.
On second thought, let's compute your data rate. Suppose that each axis is two bytes (1 word) of data, then you have 6 bytes of data for each cycle. Let's double the data magnitude for side effects and delays and whatnot, so that's 12 bytes per cycle. At your desired 50Hz, that 600 bytes of data per second. If you use a 9600 baud, then you can get 9600/8 bytes per second or 1200 bytes per second. Therefore, fully half the time will be spend just transmitting the data, which is far to slow to allow you to acquire it all.
I'd go with the Propeller, since you won't have any trouble with low speed. If you really don't think that you're up to the programming, then a BS2px would be your best alternative. It can transmit at 19200, which would give you 25% time in transmission.
And an hour and a dozen interruptions later I finish... Sorry for the randomness.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Powered by enthusiasm
Also, where can I get the USB extension cables at?
Lastly, all the connections have been made on the carrier board (the sensors as well as the microcontroller), and I have found the USB cables of the right length, how do I start programming and testing? I know that PBasic is used to program, but do I need to buy the software or does it come with something?
Also, for the BS2px, I'm using the accelerometer on 2 axes and only 1 for the gyroscope. Does that affect how much time is spent transmitting?
Would you recommend using the BS2 carrier board or the HW Board?
Post Edited (trannh) : 4/8/2010 2:36:11 AM GMT
As for the longer wires, I simple mean that components don't have to be located physically close to one another. In electric circuit theory, a wire is considered to have no resistance so you can move things indefinately far from one another with no effect. Of course the real world doesn't operate like that, but you can probably get a couple of feet. What this means is that you can mount your sensors at the end of a wire bundle (5 or 6 wires, probably) and have it located further away from the microcontroller board. It won't change anything as far as the code or sensing is concerned, because to the uC it's just like the sensors were right next door. All that I'm saying with this is that a whole board on the shoe might be a little clunky, so you can just put the sensors there and run wires to the board on the belt or something. I doubt that you could just put the board on the desk and run 15 feet of wire: that's probably too far for reliable operation.
PBASIC is free. The environment (program) is available for download from Parallax. I suggest that you take a look at the WAM tutorial, it gives a complete introduction to getting started with the BS2. Note though that you'll need to get a USB to serial adapter from Parallax, unless your computer has a serial port.
Yes, that extension cable would probably work.
As for the data transmitted, the more sensors/axes that you have the more data that you transmit. If you add more sensors, you will clearly have more data to get to the destination (the computer), so it will spend more time transmitting and hence slow down how often it can collect data. Note also that you may be able to optimize your data transmission by packing together the bits of the value. My estimate was based on two bytes per DOF, but IIRC the sensors provide 10 bit resolution. This means that you can really get all three samples in 4 bytes of data if you shove them together. This is a little bit more complicated (not much), and isn't human readable, but it does reduce the amount of data transmitted by 1/3.
The HW board is just a board with a BS2 permanently mounted to it. It also has a solderless breadboard, which wouldn't be mechanically strong for this sort of project.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Powered by enthusiasm
Could I be able to have the whole board, with uC, sensors, and battery attached (compactly) to the back of the shoe and have the wires(wouldn't be more than 12 ft of wire) run directly to the computer? Would that be too far away where it would affect data collection?
Thank you so much for taking time out of your day to help me. I appreciate everybody's help and don't hesitate to give add your input.
Post Edited (trannh) : 4/8/2010 11:43:30 PM GMT
Now I'm no expert in "footology", but I would think that some people walk with their feet pointing straight forward? And others different ways?
So·if I was doing this kind of testing, I would want to be able to "adjust" each sensor so as to be able to record this if possible. Or be able to adjust each sensor to take these differences into account.
And initially I would want to·do a bit of testing, then look at the data. Perhaps there would be a problem with the direction or placement of the sensors and this might need to be changed? Maybe adjusted a little this way or that way? Or maybe even placed in a different spot on the shoe for some reason?
Might be best to temporarily place the sensors on the shoes with rubber bands, elastic straps, or whatever works for now, then later make it all one unit?
(Actually when engineers change a design in something, it is called an Engineering Change Order. I just searched google.com for those words and found 38,000,000! So not uncommon to run into problems after something is designed.)
·
It's your choice where you mount things, based on how you plan on doing your experiment. You don't need to mount the sensors on a mini board, but it might be a good idea just to make sure that they align correctly mechanically. Electrically it doesn't make a difference, although you may be able to reduce two wires from the number in the bundle if you go with a mini board. I like the idea of putting just the sensors on the shoe since that is the least intrusive to the natural movement of the foot, but that may not be an issue for you. You'll have to figure this part out. If you mount the whole board on there, you won't be able to get any smaller than the board and the battery although you might be able to mount the battery somewhere else. It's your choice where you place things.
Otherwise, you've go the general flow of data correct: sensor -> microcontroller -> serial_to_USB -> computer.
Note that the serial_to_USB step is transparent, and you don't have to do any special sort of code for that part.
Like I said, I can't be absolutely sure that a 12 foot USB cable would work, since I've never tried it and it seems a bit far. However, I think with a proper powered cable it can. That's the best that I can offer.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Powered by enthusiasm
SRLM: For the wire bundle, I would need something longer than 14 inches right? Since it would go from about the ankles to the hip. Also, I'm not sure about connecting that bundle to my sensors. It seems like a better idea to mount the sensors to a mini board or something like that because I feel like if I mount the sensors, carrier board w/ the uC to the back of the shoe, and have the wire connect to the PC, the wires may pull on the board, which would shift the sensors. That's why I want to know more about how to connect the wire bundle to the sensors and microcontroller. I'm just not sure how the 8-pin accelerometer would connect to the 3 pin extension cable you showed me, as well as how it connects to the microcontroller. Also, is there any stores (best buy, circuit city, radio shack) that would sell such a mini board or any cables or components that I may need so that I don't have to order online and have to wait?
You may want to find an electrical engineering student to offer some help on building the board. Any EE worth his salt should be able to do it no sweat. Otherwise, you'll have to learn how to solder and get a general understanding of how to make a circuit. It's not that difficult, but it would take time and money. Oh, and before I forget: make sure you have access to a soldering iron, either one at your school or to buy one. Wire strippers are also nice, but not essential.
To go any further, you really need to do some reading. Learn how circuits are built, figure out how it relates to the devices that you are going to use (read the datasheets!), and if possible try it out on a solderless breadboard first. We are dancing around the dilemma that you don't know much about circuits, which is fine, but it will take some learning or a friend on your part to finish the project.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Powered by enthusiasm
2) The most reliable method to tell which holes are connected is to use an Ohm meter. 0 ohms = connected
3) You should have a wire for each signal, and two wires for power (+ and -).
4) Yes, do read WAM.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Powered by enthusiasm
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Powered by enthusiasm
If I plan on soldering the parts at my house, do I need to ground something when soldering the sensors to the mini board and the wires to the carrier board? Because I remember something about damaging the components if not grounded. How do I do that if I was to solder at home or even a lab?
I just bought 22 gauge hookup wires to connect the mini board to the carrier board. Is this ok?
Post Edited (trannh) : 4/14/2010 5:58:50 PM GMT
1)See my answer #1 two posts ago. You put the pin and the wire through adjacent holes and make some sort of electrical connection between them. Generally you don't put two things through the same hole.
2)The pins on the board are labeled. A note here: I'd use the super carrier board, but if you go with the regular carrier board you'll have to be careful about how much current you draw. Take a look at the datasheet (available online) for the BS2 module you're using and see how much current it's onboard regular can source (in units of mA). The add up the three current drains that you have (the BS2, the accelerometer and the gyro) and make sure that the sum total doesn't surpass the regular capacity. If it does then you'll have to add a regulator or upgrade to the super carrier board.
3)You don't need to do any grounding when soldering. Just make sure that there isn't any power connected to the circuit. Don't touch anything when you're charged with static electricity.
4)22 is fine.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Powered by enthusiasm
Gyroscope:
Power requirements: 3.4 VDC to 6.5 VDC (5 VDC recommended) @ 5.25mA
Accelerometer:
Power requirements: 2.5 – 5.5 VDC;
26 µA standby, 0.5 – 3 mA active
uC:
Current Draw @ 5 VDC: 55mA Run, 450 μA Sleep
Source/Sink Current per I/O: 30 mA / 30 mA
Source/Sink Current per unit: 60 mA / 60 mA per 8 I/O pins
The datasheet for the BS2 px uC says that all the I/O pins should not exceed 75 mA. From the data I provided, I am over? If I am, where do I get an external regulator and how to I connect it?
Accelerometer - 3 mA
microcontroller - 55 mA
total comsumption - 63.25 mA
From that, you'll probably want to add in again some extra mA just to have a margin of safety.
You still don't have the amount of current that can be provided. Look for something tied to "onboard regulator" or something like that. The amount of current that can be sourced per IO pin is different. That's important if you're powering an LED or speaker from the IO pin, but you're not doing that. Everything is powered from the 5V rail in your case.
Anyway, my guess is that you'll be fine by using the onboard regulators (*I'm not absolutely sure though). The regulator is certainly enough to power the BS2 itself, and an additional 8.25 mA isn't that much.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Powered by enthusiasm
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Powered by enthusiasm