Hi,
I have an ultimate GPS and an accelerometer LSM303 that I need to collect information from at the same time.
I am using Arduino UNO as my processor.
I can connect the LSM303 on its own and works fine.
I can also connect the GPS on its own and it works fine.
I can connect both and flick between sketches and they both work.
I’m only using the example code at the moment but I have noticed both devices work on different speeds within the Serial Console.
I know I need to add libraries to a sketch for both devices but how can I get info from them both when they work at different speeds?
If you change the speed on either the data is unreadable.
I will need to access them both from the same sketch so how will I manage this?
Any help would be most appreciated.
Phil
Ultimate GPS and LSM303 working in harmony
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
-
- Posts: 17
- Joined: Tue Jun 11, 2013 10:20 am
- adafruit_support_bill
- Posts: 88090
- Joined: Sat Feb 07, 2009 10:11 am
Re: Ultimate GPS and LSM303 working in harmony
The serial communication speed is set in the setup() function with the call to Serial.begin(). The serial speed used to communicate with the serial monitor has nothing to do with the speed of the device itself. But if it is too slow, you might start to miss some data from the GPS. When you combine the two sketches, just use the faster of the two serial speeds.
-
- Posts: 17
- Joined: Tue Jun 11, 2013 10:20 am
Re: Ultimate GPS and LSM303 working in harmony
So how can I get them both to show data at 11500 baud in the serial console.
Please see example screen shots and note the baud rates.
Wont let me do more than 3 images but any other baud rate other than 11500 on the serial monitor for GPS just shows a load of YYYY's
Please see example screen shots and note the baud rates.
Wont let me do more than 3 images but any other baud rate other than 11500 on the serial monitor for GPS just shows a load of YYYY's
- adafruit_support_bill
- Posts: 88090
- Joined: Sat Feb 07, 2009 10:11 am
Re: Ultimate GPS and LSM303 working in harmony
Make sure that both sketches set the speed to 115200 in Serial.begin():So how can I get them both to show data at 11500 baud in the serial console.
Code: Select all
Serial.begin(115200);
-
- Posts: 2
- Joined: Sun Sep 15, 2013 8:29 pm
Re: Ultimate GPS and LSM303 working in harmony
can you tell me the code that you calculate the acceleration from lsm303....i try to calculate the acceleration but i dont like my values ..thank you
- adafruit_support_bill
- Posts: 88090
- Joined: Sat Feb 07, 2009 10:11 am
Re: Ultimate GPS and LSM303 working in harmony
What library are you using? Our library returns results in SI units. https://github.com/adafruit/Adafruit_LSM303DLHCcan you tell me the code that you calculate the acceleration from lsm303
You can calibrate to the Gravity standard for more accuracy: http://learn.adafruit.com/lsm303-accele ... alibration
-
- Posts: 5
- Joined: Thu Jun 12, 2014 11:36 pm
Re: Ultimate GPS and LSM303 working in harmony
I believe zizi was also asking about calculating velocity, judging from the double post I went to first.
I would also like to know the best way to derive velocity from the accelerometers values ( I understand I have to account for gravity's values in the accelerometer, I am just trying to figure out how to get a relatively reliable instantaneous velocity value for each time step). I'm using the Adafruit data logger shield code added to the Adafruit 10DOF IMU code to get my accelerometer values. I am using a 50ms time step with a 500ms data log time step.
Thank you for your time,
Doug
UPDATE
Additionally, the project I will be using this for will be straight line, continuous orientation during recording.
I would also like to know the best way to derive velocity from the accelerometers values ( I understand I have to account for gravity's values in the accelerometer, I am just trying to figure out how to get a relatively reliable instantaneous velocity value for each time step). I'm using the Adafruit data logger shield code added to the Adafruit 10DOF IMU code to get my accelerometer values. I am using a 50ms time step with a 500ms data log time step.
Thank you for your time,
Doug
UPDATE
Additionally, the project I will be using this for will be straight line, continuous orientation during recording.
- adafruit_support_bill
- Posts: 88090
- Joined: Sat Feb 07, 2009 10:11 am
Re: Ultimate GPS and LSM303 working in harmony
An accelerometer can only measure acceleration forces. These may be due to gravity, and/or rotation and/or changes in velocity. If you can keep enough of those other factors constant, (e.g. straight-line travel on level ground) you can calculate a reasonably accurate instantaneous velocity.
Acceleration is a change in velocity and can be measured in meters per second per second. Assuming that you are starting at a known velocity, if you take readings at regular intervals, you can integrate these velocity change measurements over time to calculate your new velocity. For example, starting a 0 m/s, if you measure a 2 m/s acceleration for 1 - 50ms period, you can calculate your velocity as 0.1 m/s. If you get the same reading for the next 50ms period, your velocity will be 0.2m/s.
Using the Gyro and barometer on the IMU you can calculate forces due to rotation or change in elevation and subtract these from the accelerometer readings to further refine your results.
Acceleration is a change in velocity and can be measured in meters per second per second. Assuming that you are starting at a known velocity, if you take readings at regular intervals, you can integrate these velocity change measurements over time to calculate your new velocity. For example, starting a 0 m/s, if you measure a 2 m/s acceleration for 1 - 50ms period, you can calculate your velocity as 0.1 m/s. If you get the same reading for the next 50ms period, your velocity will be 0.2m/s.
Using the Gyro and barometer on the IMU you can calculate forces due to rotation or change in elevation and subtract these from the accelerometer readings to further refine your results.
-
- Posts: 5
- Joined: Thu Jun 12, 2014 11:36 pm
Re: Ultimate GPS and LSM303 working in harmony
Thanks for your fast reply.
Do you have any links to example code, or any forum postings about how to use the gyro and barometer to refine the accelerometer readings?
Do you have any links to example code, or any forum postings about how to use the gyro and barometer to refine the accelerometer readings?
- adafruit_support_bill
- Posts: 88090
- Joined: Sat Feb 07, 2009 10:11 am
Re: Ultimate GPS and LSM303 working in harmony
You might want to take a look at this tutorial and the associated source code: https://learn.adafruit.com/ahrs-for-ada ... fruit-ahrs
This shows how the outputs of the 3 sensors can be combined. I don't believe that the library calculates velocity though. For navigational uses, velocity is usually based on a combination of GPS and accelerometer data. (GPS is not good at instantaneous velocity, but it is not subject to drift as is the accelerometer).
For more on this topic, you might want to check out the forums at diydrones.com.
This shows how the outputs of the 3 sensors can be combined. I don't believe that the library calculates velocity though. For navigational uses, velocity is usually based on a combination of GPS and accelerometer data. (GPS is not good at instantaneous velocity, but it is not subject to drift as is the accelerometer).
For more on this topic, you might want to check out the forums at diydrones.com.
-
- Posts: 5
- Joined: Thu Jun 12, 2014 11:36 pm
Re: Ultimate GPS and LSM303 working in harmony
Perfect.
Thanks for all your help.
Thanks for all your help.
Please be positive and constructive with your questions and comments.