Knee Brace Project planted with 6 Accelerometers and BBB

201 views
Skip to first unread message

Zain Dar

unread,
Nov 4, 2013, 11:52:48 PM11/4/13
to beagl...@googlegroups.com
Hello, I'm working on a college project and my task is to develop a software code for a knee brace, that has 6 accelerometers planted on the frame (4 Analog Accelerometers and 2 Digital Accelerometers). The Analog accelerometers have 3 axis of dimensions, X, Y, & Z, whereas the Digital accelerometers have two interrupts (INT0 and INT1), an SDA, an SCL, a 3.3V ref and a GND. I need to program the BBB to turn on the designated pins on the expansion slots for the ref voltage (P8 & P9 respectively), and for the reading of the accelerometers on the computer screen. After that I need to store the data from the accelerometers to an SD card. The main issue for this is that I'm not very good at programming, especially for the BBB since I haven't worked on it before, so is there any examples or tutorials on how I can make the software code from scratch or by putting different kinds of code together to make it work? Or is there any one who knows how to turn on any pin on the BBB and read the accelerometers from the expansion slots? I appreciate anyone who helps me out on this as it is a challenging step for me in. Any advice is appreciated,

Thank you!

Zain Dar

unread,
Nov 8, 2013, 2:01:25 PM11/8/13
to beagl...@googlegroups.com
A note to all those who see this post: please do not be overwhelmed by the project! it really is not that complicated when you think about it. Its just a regular knee brace with acccelerometers planted on it. I just need help on how to make a python code for reading the accelerometers on the gpio pins as well as the ADC pins. They behave like sensors. The Analog accelerometers have 3 connectors for the X, Y and Z dimension respectively and I'm looking for a way to make a code for reading those 3 dimensions in python. Any help is appreciated.

Don deJuan

unread,
Nov 8, 2013, 2:08:46 PM11/8/13
to beagl...@googlegroups.com
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Maybe this will help some. I am not a big python guy so dont have code to share. Why did you choose python over other languages?
http://chumbylab.blogspot.com/2012/04/reading-accelerometer-and-thus-i2c-from.html

Don deJuan

unread,
Nov 8, 2013, 2:11:27 PM11/8/13
to beagl...@googlegroups.com
On 11/08/2013 11:01 AM, Zain Dar wrote:
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Zain Dar

unread,
Nov 8, 2013, 3:03:58 PM11/8/13
to beagl...@googlegroups.com
Well I was thinking of choosing python because of its ease of use for pin manipulation and when I first got the beaglebone, I was setting up the python library. I wasn't sure how to do it in other languages because I don't have that much experience. As far as C++ is concerned, I do know a little bit of it from college, but haven't continued learning it.

Mike Bremford

unread,
Nov 9, 2013, 5:09:23 AM11/9/13
to beagl...@googlegroups.com
If they're analog, surely you'd just hook them up to the analog pins and read them the normal way? Probably  with a couple of resistors to reduce the voltage range to 1.8V? http://learn.adafruit.com/measuring-light-with-a-beaglebone-black?view=all

Out of curiousity is there a reason you're using analog accelerometers? I'm far from a pro but I2C based ones like the ADXL345 are incredibly easy to use - two slave addresses possible, you have 2 I2C busses so that's 4 you can access - mix in a couple of other models (eg MMA7660) or hook them up via an I2C multiplexer and you can use 6. Digital is so much easier to work with, not least when it comes to running the wires - 4 (3V3, SCL, SDA, GND) is better than 4x3=12 for your analogs plus your 4 I2C wires for the others.

Zain Dar

unread,
Nov 9, 2013, 10:37:44 AM11/9/13
to beagl...@googlegroups.com
Your right, I can hook up the analog sensors to the analog pins and read them the normal way. The reason for analog is because when i was assigned this project, it was already made by other teams who worked on it 2 years ago. It's an R/D project from the college, but they haven't provided any info on it from those days, except mentioning that the brace works and the sensors are operational. I only had to order the BBB and make a program for it to read those sensors in real time. I chose Python for the sake of simplicity and i just learned how to make use of the board from it. Its no problem for those asking out of curiosity, questions are welcome. 
Now since there are 7 ADC pins on it, I have 12 wires for the Analog sensors, each of them with X, Y and Z axis. I'm not sure how I can fit all of them on the ADC. Is there a way I can use the GPIO pins for any extra wires left over? if so, then how can i make use of them? in a loop, or a if statement?

TI_University_Program

unread,
Nov 9, 2013, 12:30:09 PM11/9/13
to beagl...@googlegroups.com
Hello Zain, I'm no help on the coding, but would like to answer your question on resources for learning more about BeagleBone Black. 
Best place to start is the http://www.beagleboard.org/ getting started link.  Plug in your board first to see the tutorials.
 Both of these books are available via ebook download for low cost: Bad to the Bone: Crafting Electronic Systems with BeagleBone and BeagleBone Black
the second book does more with python.

in addition there are online resources from Prof Yoder  MPU Sitara BeagleboardXM: 32-Bit Embedded Linux Course

~Cathy

Zain Dar

unread,
Nov 9, 2013, 12:43:08 PM11/9/13
to beagl...@googlegroups.com
Thanks Cathy for the help, I have been using the beaglebone getting started link and have been trying out the examples, they have been a great help with the tutorials. As for the ebooks, il think about it, but thanks for referring them to me. Prof. Molloy's tutorials have also been helpful, I'll take a look at Prof Yoder's tutorials. Overall, thanks again for helping.
 


--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/Rkhvpaf8HHc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.

Mike Bremford

unread,
Nov 9, 2013, 4:48:33 PM11/9/13
to beagl...@googlegroups.com
Nice of the other team to leave you no documentation...

I guess if I was stuck with 12 analog inputs and only 7 pins to read them on I would use something like a 74HC4051 to multiplex the inputs - use 3 gpio pins to control which of the 8 inputs is connected to the ADC on the BBB. Or use an MCP3426 (or similar) - a 4-channel ADC that you can talk to over I2C. Either way I think if you want to get 12 into 7, you're going to need another chip.

Zain Dar

unread,
Nov 9, 2013, 5:30:47 PM11/9/13
to beagl...@googlegroups.com
I know, I felt really annoyed that the Prof who provided the brace was not so keen on how it was tested... yet provide at least a history report on it.
If the inputs of analog sensors require an extra chip, then I will need to look around for the chips mentioned in the previous post. Thanks alot for helping me out! I'll see what happens next.


You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/Rkhvpaf8HHc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.

Seth

unread,
Nov 11, 2013, 1:30:15 AM11/11/13
to beagl...@googlegroups.com
If you're looking for something quick & easy, try Sparkfun's Analog/Digital MUX Breakout at https://www.sparkfun.com/products/9056 . I haven't used it myself but it looks like something that could get you going quickly. Just don't forget the BBB's analog input voltage limit of 1.8v.!

Zain Dar

unread,
Nov 11, 2013, 1:43:18 AM11/11/13
to beagl...@googlegroups.com
Hi Seth! Thanks for the help, this will be a great part for the analog inputs! 


On Mon, Nov 11, 2013 at 1:30 AM, Seth <transis...@gmail.com> wrote:
If you're looking for something quick & easy, try Sparkfun's Analog/Digital MUX Breakout at https://www.sparkfun.com/products/9056 . I haven't used it myself but it looks like something that could get you going quickly. Just don't forget the BBB's analog input voltage limit of 1.8v.!

--

Zain Dar

unread,
Nov 12, 2013, 6:41:30 PM11/12/13
to beagl...@googlegroups.com
Oh yeah I also have another question: is it possible to create a waveform display of the analog sensors through python? Since I have the idea for reading voltages, I was wondering if its possible to create a sort of waveform with the x y and z axis. For that I think there should be a separate program for it or if i can combine it with the ADC setup. 


On Sat, Nov 9, 2013 at 4:48 PM, Mike Bremford <mi...@bfo.com> wrote:
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/Rkhvpaf8HHc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.

Zain Dar

unread,
Nov 12, 2013, 6:45:22 PM11/12/13
to beagl...@googlegroups.com
A quick question @Mike Bremford: since I have a code for reading the voltages from the accelerometers, is there a way to create the waveforms in python? I was just wondering if its possible to make a waveform, but i think that will be another program code for it. I'm just not sure how to do it. 


On Sat, Nov 9, 2013 at 4:48 PM, Mike Bremford <mi...@bfo.com> wrote:
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/Rkhvpaf8HHc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.

Tom King

unread,
Nov 12, 2013, 6:47:41 PM11/12/13
to beagl...@googlegroups.com
I'm a candidate for your Knee Brace...so I am interested

Tom


On Mon, Nov 4, 2013 at 8:52 PM, Zain Dar <zain...@gmail.com> wrote:
Hello, I'm working on a college project and my task is to develop a software code for a knee brace, that has 6 accelerometers planted on the frame (4 Analog Accelerometers and 2 Digital Accelerometers). The Analog accelerometers have 3 axis of dimensions, X, Y, & Z, whereas the Digital accelerometers have two interrupts (INT0 and INT1), an SDA, an SCL, a 3.3V ref and a GND. I need to program the BBB to turn on the designated pins on the expansion slots for the ref voltage (P8 & P9 respectively), and for the reading of the accelerometers on the computer screen. After that I need to store the data from the accelerometers to an SD card. The main issue for this is that I'm not very good at programming, especially for the BBB since I haven't worked on it before, so is there any examples or tutorials on how I can make the software code from scratch or by putting different kinds of code together to make it work? Or is there any one who knows how to turn on any pin on the BBB and read the accelerometers from the expansion slots? I appreciate anyone who helps me out on this as it is a challenging step for me in. Any advice is appreciated,

Thank you!

--

Zain Dar

unread,
Nov 12, 2013, 6:50:40 PM11/12/13
to beagl...@googlegroups.com
Hi Tom! thanks for the interest in my project! Do you have any experience with python and accelerometers? 


You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/Rkhvpaf8HHc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.

Zain Dar

unread,
Nov 12, 2013, 7:58:18 PM11/12/13
to beagl...@googlegroups.com
Quick Question  @Mike Bremford: Do you know how the digital accelerometers will be reading on the beaglebone black's I2C pins? I haven't had much luck finding any examples for a program code. 


On Sat, Nov 9, 2013 at 4:48 PM, Mike Bremford <mi...@bfo.com> wrote:
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/Rkhvpaf8HHc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.

Tom King

unread,
Nov 12, 2013, 9:18:29 PM11/12/13
to beagl...@googlegroups.com
some with python, only strain guages ....which accelerometers are you thinking about?

Zain Dar

unread,
Nov 12, 2013, 9:47:59 PM11/12/13
to beagl...@googlegroups.com
Well, I have 4 analog accelerometers (Sparkfun MMA7361L) and 2 digital (Sparkfun ADXL345).

Mike Bremford

unread,
Nov 13, 2013, 5:21:19 AM11/13/13
to beagl...@googlegroups.com
I wouldn't receommend asking me anything to do with analog or python :-) But the Linux I2C interface is easy, and Adafruit seems to be a good place to start: http://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/overview

Zain Dar

unread,
Nov 16, 2013, 1:46:20 AM11/16/13
to beagl...@googlegroups.com
Does anyone know how to make a code for measuring the digital accelerometers in i2c for the BBB? I've been looking for examples on making the X, Y, and Z axis work but I haven't had much luck and I'm running out of time since I need to check my progress on Mon. Any kind of hint will do fine, but it needs to involve measuring the waveforms for them too. Much appreciated.

Zain Dar

unread,
Nov 17, 2013, 6:21:25 PM11/17/13
to beagl...@googlegroups.com
I made a code that is able to make the z axis work but I need some help on how to make it work for the x and y as well.Anyone familiar with python? Please let me know how I can modify the code for the X and Y axis. Here's the sample code:

import smbus
import time
 
def main():
bus = smbus.SMBus(1)
 
# Power-on the accelerometer, enabling only the z-axis
bus.write_byte_data(0x18, 0x20, 0x24)
 
try:
while True:
# get z-axis acceleration
tilt = bus.read_byte_data(0x18, 0x2D)
 
# if it's supposed to be negative
if tilt > 127:
# then convert it to the absolute value of the negative value
tilt = 256 + ~tilt
positive = False
else:
positive = True
 
# format and print it
pos = tilt / 2
print str(tilt).rjust(6),
if positive:
print 65*' ' + '|' + (pos*'#').ljust(65)
else:
print (pos*'#').rjust(65) + '|' + 65*' '
# sleep
time.sleep(0.1)
except KeyboardInterrupt:
# restore default settings
bus.write_byte_data(0x18, 0x20, 0x07)
 
if __name__ == '__main__':
main()

Seth

unread,
Nov 18, 2013, 7:56:36 AM11/18/13
to beagl...@googlegroups.com
That code actually works with the ADXL345? You've tested it and it gives the right result?

Zain Dar

unread,
Nov 18, 2013, 9:11:45 AM11/18/13
to beagl...@googlegroups.com

I haven't tested it yet because the brace is currently with my team partner. I had some idea from a youtube video of someone testing their accelerometer with a raspberry pi. It was working and the person uploaded the code.

On Nov 18, 2013 7:56 AM, "Seth" <transis...@gmail.com> wrote:
That code actually works with the ADXL345? You've tested it and it gives the right result?

--

Seth

unread,
Nov 18, 2013, 7:18:42 PM11/18/13
to beagl...@googlegroups.com
I wouldn't try testing with that code - I found it here, and by the looks of the commenting it is meant to work with a LSM303DLH, not a ADXL345. I found this, however, which looks like demo code for the device you have, although it is written for Arduino and not in Python but it should get you on the right path.

Zain Dar

unread,
Nov 18, 2013, 9:04:12 PM11/18/13
to beagl...@googlegroups.com
Oh man, I thought that it would work. Thanks for showing me that it was the wrong one. I took a look at the arduino code: it seems to be the right one, not sure if it will work with the beaglebone, but I'll give it a try. Thanks for the help.


On Mon, Nov 18, 2013 at 7:18 PM, Seth <transis...@gmail.com> wrote:
I wouldn't try testing with that code - I found it here, and by the looks of the commenting it is meant to work with a LSM303DLH, not a ADXL345. I found this, however, which looks like demo code for the device you have, although it is written for Arduino and not in Python but it should get you on the right path.

--

Seth

unread,
Nov 19, 2013, 8:48:29 AM11/19/13
to beagl...@googlegroups.com
Have you seen this library?

Zain Dar

unread,
Nov 19, 2013, 3:41:30 PM11/19/13
to beagl...@googlegroups.com
Oh yeah I've seen this one but then I turned away from it since it worked with the raspberry pi. I'll give this one a try too, maybe it should work with it. 
I also have another question: I need to record or save the voltage readings into a file for the sd card of the beaglebone. What is the lines of code that I need to add and which part of the code I should add it in? 
Thanks for the help!


On Tue, Nov 19, 2013 at 8:48 AM, Seth <transis...@gmail.com> wrote:
Have you seen this library?

--

stk...@gmail.com

unread,
Feb 11, 2014, 11:21:08 AM2/11/14
to beagl...@googlegroups.com
It works for me, I'm now trying to make work with c++ :(
(PYTHON)
tilt = bus.read_byte_data(DEVICE_ADDRESS, DEVICE_REGISTER), that's all. All you need to do is find out the correct addresses at datasheet :) mine is: DEVICE_ADDRESS = 0x53 and DEVICE_REGISTER (DATA) = 0x32 to 0x37 (LSB,MSB), but you can use bus.read_word_data(DEVICE_ADDRESS, DEVICE_REGISTER) to read LSB and MSB together.

Good lucky
Reply all
Reply to author
Forward
0 new messages