Arduino Project Suggestions - Measuring Angles Between Senso

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
Crimson1989
 
Posts: 35
Joined: Mon Oct 20, 2014 5:26 am

Arduino Project Suggestions - Measuring Angles Between Senso

Post by Crimson1989 »

Dear all,

I'm currently doing a project in which I have to calculate the angles (and later the distance) between two sensors (see attachment), and I have no good idea on how to approach this.
I have some experience with Arduino programming/software/hardware, but still consider myself to be a beginner (compared to the awesome projects on the interwebs).

Image

My first objective for the project is to measure the side angle of patients dealing with neck problems, with two different sensors (see image). As it will be a wearable, I'm thinking about using a Lilypad Arduino, conductive thread, and different sensors (accelerometers ADXL3**, or possibly IMU's http://www.adafruit.com/products/1714 as they will be far more accurate and convenient with onboard calculations if I'm right).

Imagine that people can move their head forwards keeping their body still, thus, changing the angle their neck makes. I have to be able to measure and map the position of the neck (first only from the side, later maybe also from the back, to make sure the neck spine is held straight as well). But when the entire angle of the body moves, I still have to know the angle that the two sensors make.

What would be the best way to approach this project? What and how many sensors do I need in order to have accurate readings? How does this work with calibration? Are there any suggestions?

Thanks for your help!

Gr Crimson
Attachments
Screen Shot 2014-10-20 at 11.29.13.png
Screen Shot 2014-10-20 at 11.29.13.png (22 KiB) Viewed 1475 times

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Arduino Project Suggestions - Measuring Angles Between S

Post by adafruit_support_bill »

Inertial sensors such as the accelerometers and gyros in an IMU can measure only instantaneous inertial forces. Integrated over time they can estimate relative position, but this is subject to drift and I don't know of any way to keep multiple independent units in sync.

Since gravity is a constant acceleration force, an accelerometer can be used to measure tilt when it is stationary. But to measure the angle as in your diagram, it would need to be mounted on the neck itself.

User avatar
Crimson1989
 
Posts: 35
Joined: Mon Oct 20, 2014 5:26 am

Re: Arduino Project Suggestions - Measuring Angles Between S

Post by Crimson1989 »

Thanks for your reply!

Hmm, are there others ways to measure the angles? Are there flexible strain sensors that change resistance dependent on the angle they are bend in?

If calibration needs to happen every once in a while, it is no problem, but then it would need a button that needs to manually be pressed when people are in a 'right' neck position.

Are IMU 's my best option?

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Arduino Project Suggestions - Measuring Angles Between S

Post by adafruit_support_bill »

Is this to be used in a controlled environment? If so, imaging systems such as a Kinect or similar 3d imaging system could be used.

If not, I suspect you will need some combination of sensors for best results. As mentioned, IMUs are good at precisely measuring instantaneous relative motion, but position calculations will tend to drift. A flex or stretch sensor will give you a more stable absolute reading - albeit with rather low precision. There are a few optical positioning techniques that could be applicable here, but they would require clear line-of-sight between the sensors, which might be difficult to guarantee in a wearable context.

User avatar
Crimson1989
 
Posts: 35
Joined: Mon Oct 20, 2014 5:26 am

Re: Arduino Project Suggestions - Measuring Angles Between S

Post by Crimson1989 »

@adafruit_support_bill Thanks for your reply!

Unfortunately it is not to be used in a controlled environment. It is to be used as a wearable, at home, the office, etc. A kinect could indeed do the job, but it is quite inconvenient for the purpose of the project.
So I guess experimenting with IMU's will be my best option. But I do want to look into flex or stretch sensors, which ones could do the job? Thanks for your advice and help so far!
Any idea on which sensors I should order, considering I want to use an Arduino Lilypad? I'd highly prefer only using 1 arduino for this project, but I also need to send data wirelessly, preferably through Bluetooth.

If someone happens to have other suggestions or projects that have done similar, please let me know.

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Arduino Project Suggestions - Measuring Angles Between S

Post by adafruit_support_bill »

We have this cord for stretch sensing:
https://www.adafruit.com/products/519
Although much more precise devices are available:
http://celesco.com/m150/
http://www.firstmarkcontrols.com/

We also stock both long and short bend sensors:
https://www.adafruit.com/products/182
https://www.adafruit.com/products/1070
Any idea on which sensors I should order, considering I want to use an Arduino Lilypad? I'd highly prefer only using 1 arduino for this project
For a processor, I'd recommend the Flora. https://www.adafruit.com/products/659
It is a bit of an upgrade from the Lilypad with no protruding pins to stab you and more available memory.

And there is a compatible Flora IMU: https://www.adafruit.com/products/2020

One issue with most of the IMUs on the market is that you can only have one per i2c bus - and all the wearable Arduinos only have just one i2c bus. There are various ways to deal with that in hardware and/or software. But that may be deeper than you want to go at this time. For the purpose of prototyping and characterizing the sensor output, it would probably be easier to have a processor per IMU and stream the raw data back to a computer for analysis.

We have a few wireless options. For Bluetooth, there is the EZ-Link: https://www.adafruit.com/products/1588
And we also have a BlueTooth LE (Low Energy) board for easy communication with smart-phones. https://www.adafruit.com/products/1697

User avatar
Crimson1989
 
Posts: 35
Joined: Mon Oct 20, 2014 5:26 am

Re: Arduino Project Suggestions - Measuring Angles Between S

Post by Crimson1989 »

Once again! Thanks for your great help!
As soon as I've figured out what is the best way to go for me (considering costs as well ;) ), I will place my order here on adafruit.

Thanks

User avatar
Crimson1989
 
Posts: 35
Joined: Mon Oct 20, 2014 5:26 am

Re: Arduino Project Suggestions - Measuring Angles Between S

Post by Crimson1989 »

adafruit_support_bill wrote:We have this cord for stretch sensing:
https://www.adafruit.com/products/519
Although much more precise devices are available:
http://celesco.com/m150/
http://www.firstmarkcontrols.com/

We also stock both long and short bend sensors:
https://www.adafruit.com/products/182
https://www.adafruit.com/products/1070
Any idea on which sensors I should order, considering I want to use an Arduino Lilypad? I'd highly prefer only using 1 arduino for this project
For a processor, I'd recommend the Flora. https://www.adafruit.com/products/659
It is a bit of an upgrade from the Lilypad with no protruding pins to stab you and more available memory.

And there is a compatible Flora IMU: https://www.adafruit.com/products/2020

One issue with most of the IMUs on the market is that you can only have one per i2c bus - and all the wearable Arduinos only have just one i2c bus. There are various ways to deal with that in hardware and/or software. But that may be deeper than you want to go at this time. For the purpose of prototyping and characterizing the sensor output, it would probably be easier to have a processor per IMU and stream the raw data back to a computer for analysis.

We have a few wireless options. For Bluetooth, there is the EZ-Link: https://www.adafruit.com/products/1588
And we also have a BlueTooth LE (Low Energy) board for easy communication with smart-phones. https://www.adafruit.com/products/1697
I just came across the FLORA 9-DOF. https://www.adafruit.com/products/2020
Is there a reason why you didn't mention them, are they not suitable for my project?

And, do you have any information on the delivery time? I'm ordering from the Netherlands

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Arduino Project Suggestions - Measuring Angles Between S

Post by adafruit_support_bill »

I just came across the FLORA 9-DOF. https://www.adafruit.com/products/2020
Is there a reason why you didn't mention them, are they not suitable for my project?
That is the one I recommended in this post: http://forums.adafruit.com/posting.php? ... 5#pr313343
And, do you have any information on the delivery time? I'm ordering from the Netherlands
Shipping options for your location - including expedited shipping - will be shown at checkout. However, customs delays can be unpredictable at times.

We do have several European distributors that may be able to get it to you quicker: http://www.adafruit.com/distributors/

User avatar
Crimson1989
 
Posts: 35
Joined: Mon Oct 20, 2014 5:26 am

Re: Arduino Project Suggestions - Measuring Angles Between S

Post by Crimson1989 »

How did I miss that!? I feel stupid.. Thanks!
I'm placing my order today, and will start experimenting asap!

User avatar
Crimson1989
 
Posts: 35
Joined: Mon Oct 20, 2014 5:26 am

Re: Arduino Project Suggestions - Measuring Angles Between S

Post by Crimson1989 »

So I've done some research towards i2c, to discover what it is, how it works and how to connect/read/write to multiple slaves on the master.
If I understand correctly, the IMU's have a fixed address to which they respond on the bus, so if I have two of the same IMU's connected to the bus and ask for data, both will respond. And I won't be able to distinguish one from the other.

So I would need two i2c busses, or use some sort of switcher (I've briefly read about the PCA9646, but can't find any (beginner) information on how to use it).
I've also read a suggestion on using the ATmega328 chip, and somehow connect it to the Arduino and use its i2c bus for a second IMU, but this is probably beyond my level.
Do I understand correctly that if I were to order two different IMU's, that have different addresses, I can read from both IMU's on request without any problems? If so, this is probably the best and easiest solution.

If not, I'm hoping for some good suggestions. In a worst case scenario, I will use two Lilypads, send data from one to the other over serial, do calculations and send it to my Bluetooth device. But, as the BLE Shield and the IMU will need SCL/SDA pins, I won't be able to connect both to one arduino? I guess in this case, I'll need three Lilypads ;(.

Or are there other options I can consider?

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Arduino Project Suggestions - Measuring Angles Between S

Post by adafruit_support_bill »

There are a few techniques for connecting two i2c devices with the same address to one Arduino. But all are somewhat advanced. Finding devices with different addresses or a multiple processor solution will likely be an easier way to go.

There are processors with multiple i2c busses like the Arduino Due or the Raspberry Pi. But these are not so practical for a wearable device.
But, as the BLE Shield and the IMU will need SCL/SDA pins, I won't be able to connect both to one arduino?
As long as the i2c BLE and IMU addresses do not conflict, they can share these pins.

User avatar
Crimson1989
 
Posts: 35
Joined: Mon Oct 20, 2014 5:26 am

Re: Arduino Project Suggestions - Measuring Angles Between S

Post by Crimson1989 »

After half a day of trying to figure out why my experimental wearable (currently just using one IMU), is often crashing, I'm hoping to find some help here.

I've got my the 9-dof Flora IMU hooked up to my Flora Arduino with conductive thread, i'm printing my data over serial, but if I start moving my wearable around it will sometimes crash as if I'm creating a short circuit (although sometimes I move the wearable so little that I'm pretty sure I'm not).

For debugging purposes I'm printing an increasing Integer each 100ms (see code), if I comment out the getOrientation() if-statement, I can move the wearable around like a maniac, and it will not crash. However, with the if statement, when it crashes, it won't even print my integer anymore.

Code: Select all

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_LSM9DS0.h>
#include <Adafruit_Simple_AHRS.h>

int number;

// Create LSM9DS0 board instance.
Adafruit_LSM9DS0     lsm(1000);  // Use I2C, ID #1000

// Create simple AHRS algorithm using the LSM9DS0 instance's accelerometer and magnetometer.
Adafruit_Simple_AHRS ahrs(&lsm.getAccel(), &lsm.getMag());

// Function to configure the sensors on the LSM9DS0 board.
// You don't need to change anything here, but have the option to select different
// range and gain values.
void configureLSM9DS0(void)
{
  // 1.) Set the accelerometer range
  //lsm.setupAccel(lsm.LSM9DS0_ACCELRANGE_2G);
  //lsm.setupAccel(lsm.LSM9DS0_ACCELRANGE_4G);
  //lsm.setupAccel(lsm.LSM9DS0_ACCELRANGE_6G);
  //lsm.setupAccel(lsm.LSM9DS0_ACCELRANGE_8G);
  lsm.setupAccel(lsm.LSM9DS0_ACCELRANGE_16G);
  
  // 2.) Set the magnetometer sensitivity
  //lsm.setupMag(lsm.LSM9DS0_MAGGAIN_2GAUSS);
  //lsm.setupMag(lsm.LSM9DS0_MAGGAIN_4GAUSS);
  //lsm.setupMag(lsm.LSM9DS0_MAGGAIN_8GAUSS);
  lsm.setupMag(lsm.LSM9DS0_MAGGAIN_12GAUSS);

  // 3.) Setup the gyroscope
  //lsm.setupGyro(lsm.LSM9DS0_GYROSCALE_245DPS);
  //lsm.setupGyro(lsm.LSM9DS0_GYROSCALE_500DPS);
  lsm.setupGyro(lsm.LSM9DS0_GYROSCALE_2000DPS);
}

void setup(void) 
{
  Serial.begin(115200);
  Serial.println(F("Adafruit LSM9DS0 9 DOF Board AHRS Example")); Serial.println("");
  
  // Initialise the LSM9DS0 board.
  if(!lsm.begin())
  {
    // There was a problem detecting the LSM9DS0 ... check your connections
    Serial.print(F("Ooops, no LSM9DS0 detected ... Check your wiring or I2C ADDR!"));
    while(1);
  }
  
  // Setup the sensor gain and integration time.
  configureLSM9DS0();
}

void loop(void) 
{
  sensors_vec_t   orientation;

  // Use the simple AHRS function to get the current orientation.
 //IF I COMMENT OUT THE IF STATEMENT BELOW, I CAN HARDLY SUCCEED IN LETTING IT CRASH
 if (ahrs.getOrientation(&orientation))
  {
    /* 'orientation' should have valid .roll and .pitch fields */
    Serial.print(F("Orientation: "));
    Serial.print(orientation.roll);
    Serial.print(F(" "));
    Serial.print(orientation.pitch);
    Serial.print(F(" "));
    Serial.print(orientation.heading);
    Serial.println(F(""));
  }
   Serial.println(number++);
  delay(100);
}
My questions, what happens if I am indeed creating a short circuit at the sensor? Will the Arduino totally crash and stop printing any data?

PS. In the rare case that it doesn't crash, I've made considerable progress, I'm sending my data to Processing and am rotating a human head model in 3d, based on the IMU values.

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Arduino Project Suggestions - Measuring Angles Between S

Post by adafruit_support_bill »

Using conductive thread, any looseness can result in an intermittent connection. An intermittent connection on the i2c bus could cause the processor to hang.

Try doubling up your connections using alligator clips and see if the reliability improves.

User avatar
Crimson1989
 
Posts: 35
Joined: Mon Oct 20, 2014 5:26 am

Re: Arduino Project Suggestions - Measuring Angles Between S

Post by Crimson1989 »

Yeah, some more testing, and I'm pretty sure it's a wiring issue, though it looks rather sturdy. Unfortunately I don't have any alligator clips, so I guess I'll redo my conductive thread.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”