The first thing is about Xbee which is so important is to consider that:
1) XBEE ZNET 2.5 used to be call " 2 series "
2) 802.15.4 used to be call " 1 series "
Version 2 is better because of following:
1) energy saving
2) range (It is too much difference, I loved my series 2 because of its amazing range)
3) being more complicated and therefore more application on bigger networks
Each of the group mentioned above has two type:
1)Pro
2) normal one
As far as I know the Pro version can support longer distance.
Now, I do recommend you to use Series 1 if you are not familiar with Xbee and I think you are not or else you would not read this :D
Keep in mind that your Xbee's serial communication is at 3.3 volt and not 5. Although mine works with both. The data sheet asks for 3.3 volts.
Xbee comes in different type of antenna and power output, make sure you use the one which meets your needs. I can't give you any opinion how to pick the right one because I have 2 different types of them.
Fact: it is really hard to burn a Xbee, I have tried many different things and I was never successful :D
I finally burnt one. :) It receives data when there is no other Xbee around.
I do recommend you buy a break out with FTDI like this or this
It is good to have something like this too. Although, it does not do much.
If you but series 1 this is how you can simply use them, Here.
If for some reasons you have 2 series, do not worry, just read this.
I made this blog to share some of what I experienced.It is mostly about my quad. which you can see in the picture.
Thursday, 2 February 2012
How to test Xbee Series 2 (s2)?
Well, I assume you have one of your Xbee is connected to the computer using a breakout and FTDI 232. something like this or this. (many other company are making the similar ones) The other one has something like this and Rx and Tx (in the case of sparkfun Din and Dout) are connected to each other/ which means that whatever will be send will be received too.
Make sure you have download X-CTU from digi website.
Run the program and you have to connect the serial port which is connected to FTDI, when I tried the name was "COME XX". Go to the modem configuration tab and click on read, if it asked for reset, just connect Xbee's pin 5 to Xbee's pin 10. Check the DH and DL. Keep the number somewhere.
This is the easiest way I found to test my Xbees 2 series.
1) make one as a coordinator AT (AT and API is well explained in Data sheet provided by Digi)
2) make sure that you use DH and DL of your other Xbee.
3) change packetization time to zero (this will send any data available for sending if you choose any other number it will wait for that period and if they were any other data coming, it will send them in one packet)
4) take the other one and program it as router/end device AT
5) make sure that you use DH and DL of your other Xbee.
6) change packetization time to zero (this will send any data available for sending if you choose any other number it will wait for that period and if they were any other data coming, it will send them in one packet)
now you can go to the terminal tab and see if you get whatever you type in red or not, if you do that means everything is working, if not there is still one hope. Change all possible values in networking and address to the same value in the other one. Read the description about each value, if it could be a reason then change them first and try. If it was not still working read the God damn Data sheet. :D
Hint: do not give up easily, one does not simply burn a Xbee. :)
Make sure you have download X-CTU from digi website.
Run the program and you have to connect the serial port which is connected to FTDI, when I tried the name was "COME XX". Go to the modem configuration tab and click on read, if it asked for reset, just connect Xbee's pin 5 to Xbee's pin 10. Check the DH and DL. Keep the number somewhere.
This is the easiest way I found to test my Xbees 2 series.
1) make one as a coordinator AT (AT and API is well explained in Data sheet provided by Digi)
2) make sure that you use DH and DL of your other Xbee.
3) change packetization time to zero (this will send any data available for sending if you choose any other number it will wait for that period and if they were any other data coming, it will send them in one packet)
4) take the other one and program it as router/end device AT
5) make sure that you use DH and DL of your other Xbee.
6) change packetization time to zero (this will send any data available for sending if you choose any other number it will wait for that period and if they were any other data coming, it will send them in one packet)
now you can go to the terminal tab and see if you get whatever you type in red or not, if you do that means everything is working, if not there is still one hope. Change all possible values in networking and address to the same value in the other one. Read the description about each value, if it could be a reason then change them first and try. If it was not still working read the God damn Data sheet. :D
Hint: do not give up easily, one does not simply burn a Xbee. :)
How to test Xbee series 1 (s1)?
Well, I assume you have one of your Xbee is connected to the computer using a breakout and FTDI 232. something like this or this. (many other company are making the similar ones) The other one has something like this and Rx and Tx (in the case of sparkfun Din and Dout) are connected to each other/ which means that whatever will be send will be received too.
Make sure you have download X-CTU from digi website.
Run the program and you have to connect the serial port which is connected to FTDI, when I tried the name was "COME XX". now you can go to the terminal tab and see if you get whatever you type in red or not, if you do that means everything is working, if you don't then click on modem configuration and click on read. If it asked to reset your Xbee, connect pin 5 of Xbee to pin 10. After that write the original version of your Xbee on it. Try the same thing with the other Xbee. Try again and you should be fine, if not just ask me. I am not that used to Xbee myself yet but I guess now you can be happy that your Xbees work fine. You may go to range test tap and play around with it.
Make sure you have download X-CTU from digi website.
Run the program and you have to connect the serial port which is connected to FTDI, when I tried the name was "COME XX". now you can go to the terminal tab and see if you get whatever you type in red or not, if you do that means everything is working, if you don't then click on modem configuration and click on read. If it asked to reset your Xbee, connect pin 5 of Xbee to pin 10. After that write the original version of your Xbee on it. Try the same thing with the other Xbee. Try again and you should be fine, if not just ask me. I am not that used to Xbee myself yet but I guess now you can be happy that your Xbees work fine. You may go to range test tap and play around with it.
Monday, 16 January 2012
How to read the output from accelerometer?
Your sensor may have any kind of output, the one that I know are either I2C or analog.
In the data sheet of your sensor you can find this variable (g / data_output), using this variable is actually waste of time. If you use the method I explained here, you just need to make sure your readings are in same units. Units will cancel each other.
If you want to show the data on your PC screen and in terms of g then do the calculation on your PC not in micro because that will take time form your PC and not your weaker controller on vehicle.
The only thing, I did missed the first time; I was using it was wasting time for finding the readings in g which is not important and keep in mind that I2C and analog outputs are integer and not float so all future calculation becomes much faster for the controller.
You may want to calibrate your accelerometer, this is not actually hard. all you need to do is to rotate the sensor and see the maximum reading in each axis, then multiply the variable (g / data_output) to your reading and you have to get something around 1. Do not be so picky if your reading is not exactly one since most of the sensors with cheap price are not that accurate and keep in mind that soldering and environment may change the accuracy of the sensor or the variable (g / data_output) slightly.
here I explained how to test your accelerometer. (http://asafdari.blogspot.com/2012/01/how-to-test-gyroscope-accelerometer-and.html)
There will be one other variable that you will need for using in what I explained here (Using three axis accelerometer with three axis gyroscope). This variable is called gravity.
Gravity is basically g in your sensor measurement, without changing units.
Using Pythagorean theorem we know that:
Acceleration_resultant = sqrt ( Acceleration_x^2 + Acceleration_y^2 + Acceleration^2 )
Now, consider the situation where the only acceleration applied on sensor is gravity, then:
Gravity = = sqrt ( Acceleration_x^2 + Acceleration_y^2 + Acceleration^2 )
Finding gravity is necessary and you don't need to measure it every time you turn on your vehicle, you can measure it once and use it as a constant. But it is good to once in a while you measure it again to make sure that your sensor is not affected by environment and even if it is, then just use the new value. I would calculate Gracity 100 times while my sensor is at rest and I would get its average and use it as a constant. Just one more thing, usually the output will be something more than a few hundred (despondent on your sensor and resolution of our reading) so ignore the decimal point and just round it and keep it as an integer so it will be faster for controller to do calculation with integers.
Usually the vehicles start from rest, so you may calculate Gravity every time you turn on your vehicle. Just make sure you are not relying on one reading.
In the data sheet of your sensor you can find this variable (g / data_output), using this variable is actually waste of time. If you use the method I explained here, you just need to make sure your readings are in same units. Units will cancel each other.
If you want to show the data on your PC screen and in terms of g then do the calculation on your PC not in micro because that will take time form your PC and not your weaker controller on vehicle.
The only thing, I did missed the first time; I was using it was wasting time for finding the readings in g which is not important and keep in mind that I2C and analog outputs are integer and not float so all future calculation becomes much faster for the controller.
You may want to calibrate your accelerometer, this is not actually hard. all you need to do is to rotate the sensor and see the maximum reading in each axis, then multiply the variable (g / data_output) to your reading and you have to get something around 1. Do not be so picky if your reading is not exactly one since most of the sensors with cheap price are not that accurate and keep in mind that soldering and environment may change the accuracy of the sensor or the variable (g / data_output) slightly.
here I explained how to test your accelerometer. (http://asafdari.blogspot.com/2012/01/how-to-test-gyroscope-accelerometer-and.html)
There will be one other variable that you will need for using in what I explained here (Using three axis accelerometer with three axis gyroscope). This variable is called gravity.
Gravity is basically g in your sensor measurement, without changing units.
Using Pythagorean theorem we know that:
Acceleration_resultant = sqrt ( Acceleration_x^2 + Acceleration_y^2 + Acceleration^2 )
Now, consider the situation where the only acceleration applied on sensor is gravity, then:
Gravity = = sqrt ( Acceleration_x^2 + Acceleration_y^2 + Acceleration^2 )
Finding gravity is necessary and you don't need to measure it every time you turn on your vehicle, you can measure it once and use it as a constant. But it is good to once in a while you measure it again to make sure that your sensor is not affected by environment and even if it is, then just use the new value. I would calculate Gracity 100 times while my sensor is at rest and I would get its average and use it as a constant. Just one more thing, usually the output will be something more than a few hundred (despondent on your sensor and resolution of our reading) so ignore the decimal point and just round it and keep it as an integer so it will be faster for controller to do calculation with integers.
Usually the vehicles start from rest, so you may calculate Gravity every time you turn on your vehicle. Just make sure you are not relying on one reading.
How to test gyroscope, accelerometer and filter?
You may rotary index. I took one from university's workshop and it helps a lot. It helps you to see the accuracy of the gyroscope, accelerometer and your filter. I have to say that it does not help with raw data from gyroscope it helps with the angle output base on gyroscope alone. you can use the following formula and test your gyroscope, just make sure that initial value for previous_angle is equal to zero and then angle change is reading from gyro and it gives you the angle. you have to keep the reading from rotary index and consider it as a zero at the time that you first turn on your sensor. This will even give you the idea that how gyro is drifting. If you rotate it at a faster, it will drift faster too.
angle = previous_angle + angle_change
For accelerometer the reading from sensor should be equal to rotary index.
For filter output, the reading rotary index should be equal to filter output.
angle = previous_angle + angle_change
For accelerometer the reading from sensor should be equal to rotary index.
For filter output, the reading rotary index should be equal to filter output.
Wednesday, 11 January 2012
All the projects I have done (MIT, please read this) ((there is no technical information in this post))
I have applied to MIT. There was an empty text box for blog address so I decided to fill it up by my blog address. Then I was like let’s explain whatever I did back in high school and afterward. So if they come here, they may read it. I can also make sure if they have checked my blog by a high chance. (My blog is not that famous and I don't have a lot of audience from USA.) Anyway let's get to the point.
The first project that I did comes back to my secondary school time, when I was 14. I made bridges models. At the time I did not know anything about hydrophilic systems. Once I was in our school lab and I notice that glass made syringes are so frictionless that gravity can move their piston. I wanted to make few bridges with moving part, so I thought that I can pump water inside the syringes and then it gives me movement in one direction. Then I did a short research and I used cars water pump (the one for cleaning front glass). We were one of the best projects in the exhibition that year although they did not give us any certificate. We had few bridges with moving parts.
I have done tones of small project with my LEGO RCX and NXT (LEGO MINDSTORMS). I made line follower, automatic car, automatic gear shifting (I made manual gearbox of old LEGO Technics and I made it automatic) and a lot more which I can’t even think of it now.
The other major project I spent a lot of time for it was my junior soccer player robot. I worked on it for few years and happily I have the pictures of my robots. (http://imageshack.us/g/259/cimg0921.jpg/) and ( http://imageshack.us/g/267/cimg2661.jpg/ )
The other project that I did was a system which could produce distilled water, petrochemical and electricity. The inputs of the systems were sunshine, wave energy and ocean water. I chose a place in southern part of my country and I did a lot of calculation to prove that it is possible to bring the project to reality. You can see its pictures here (http://imageshack.us/g/593/cimg1534x.jpg/).
Then there was a gap till the point that I entered Taylor’s University. I started a quad with 8 amazing friends. We have done a lot of research about PID control system, filters and we learned a lot of things. I was in the lab at all the time. They used to say that lab is my first house and sometimes I go to my second house to take shower and personal stuff like that. At first we had some difficulties but after a short while the dean of engineering Associate Professor Dr. Mushtak Al-Atabi and deputy dean Dr. Edwin Chung Chin Yau were supporting us in all ways. Meanwhile we were contacting Prof Dr. Benjamin Koo and he was supporting us and he helped with our trip to China and our preparation for presenting our project in CDIO conference.
We went to CDIO conference. (http://www.taylors.edu.my/download/dl_thankyou.php?src=newsletter/blue_print/TAYLORS_SOE_Blue_Print_2011_May.zip&title=Blue%20Print%20Newsletter%202011%20May%20Issue)
It was an amazing experience with all my friends in china and pressure of presenting our project in front of professors from different parts of the world.
After CDIO conference we started working again and we developed the project to this point:
We attended the engineering fair at Taylors university and we won following awards:
1) 1) The Best Research Project Award (Year 1) by Fibertex Personal Care Sdn. Bhd.
2) 2) The Most Needed Project Award (Year 1) by Rhombus Castors Malaysia Sdn. Bhd./ University of Western Australia
3) 3) The Most Technologically Advanced Project Award (Year 1) by National Instrument Malaysia Sdn. Bhd.
4) 4) Joint Winner of The Best CAD/CAM Design Project Award by University of Birmingham
Now, I am working on new quad, and that is the main reason I have this blog. I will post more pictures of my new quad soon.
Thank you for your time. (there is no technical information in this post)
Tuesday, 6 September 2011
Using three axis accelerometer with three axis gyroscope
here I would like to tell you how to use the output from sensors to measure the angle that you are looking for.
Firstly, lets see what we exactly want.
we want to sense the rotation of our sensor in three axis. this three axis can be considered as X, Y and Z or pitch, roll and yaw. I prefer X, Y and Z orientation since it is more mathematically represented.
now lets consider that we want to find the angular rotation over each axis using accelerometer. Well, we can find just two angles using accelerometer (if you don't know why don't worry you will see understand soon).
Now lets find the angle for one of the axis:
before we start, you should be agree that gravity is always perpendicular to the surface of earth. I know that the vehicle will have some acceleration to some directions, but compare to g, they are significant, so we can ignore it.
This is the diagram. As you can see, we assumed that gravity is always perpendicular to the earth surface.We know that our readings from accelerometer comes from three different axis. In this case we consider the X and Z axis readings.Now, we have to understand something which is really important in, when we have three axes the vector addition of acceleration in X and Z axis is not equal to gravity. However, in the diagram it may seem that it will be equal.
I talk about how to read your accelerometer here.
now lets say we have the reading in any unit. We call them, X_acceleration, Y_acceleration and Z_acceleration.
We have one variable which is called Gravity, recall from here ( How to read the output from accelerometer? ).
Now we find the angle theta which is equal to Y_angle. (it is rotation over the Y axis of sensor)
from the diagram, you can see that Y_angle = theta =cos-1( X_acceleration / Gravity )
(think of the triangle, I tried but I can't explain in words :( sorry )
we know that cos-1 has a range [0,180], but we may need to have a range from [0,360], in this case we use the Z axis reading. For my quad I used the range equal to [-90,90], this makes it easy for PID control, and much easier to understand.
now, we have Y_angle, in any form that we want from accelerometer.
For the case of gyroscope we need to use what I explained here. (How to use gyroscope?)
Y_angle can be obtain by Y_angle = previous_Y_angle + angle_change_y
previous_Y_angle is the last Y_angle we found which was measured at the last time that loop was repeated.
angle_change_Y is the out put of gyro in Y axis.
Now we have measured Y_angle using gyroscope.
Now, if you think you will notice that we do not have previous_Y_angle for the first time that we start the vehicle. They are two different approach, 1) always start the vehicle when it is flat so the previous_Y_angle is zero 2) using accelerometer to find previous_Y_angle and counting on accelerometer reading. These are the ways comes to my mind and I don't think there is any other way. You may use average or any filter in order to read the data from accelerometer, because as you know accelerometer has a lot of fluctuation. You will read that in detail in Shane's PDF later.
They are many ways to combine these values which are explained here:
http://web.mit.edu/scolton/www/filter.pdf
I have used the complimentary filter, it works fine.
this does not contain the Kalman filter, which I did not understand it myself, but you may understand it from this website: (they are some other parts that they have explained, but I think I have explained better ;) )
http://www.starlino.com/imu_guide.html
I never understood this. It is just so hard.
I think Shane has explained everything in that PDF and everyone will understand it.
The last obvious part is that after that filtering is done you have to do this:
previous_Y_angle = Y_angle_output_from_filter ;
this is necessary for gyroscope future readings.
Now, if you want to test your filter output read this.
Firstly, lets see what we exactly want.
we want to sense the rotation of our sensor in three axis. this three axis can be considered as X, Y and Z or pitch, roll and yaw. I prefer X, Y and Z orientation since it is more mathematically represented.
now lets consider that we want to find the angular rotation over each axis using accelerometer. Well, we can find just two angles using accelerometer (if you don't know why don't worry you will see understand soon).
Now lets find the angle for one of the axis:
before we start, you should be agree that gravity is always perpendicular to the surface of earth. I know that the vehicle will have some acceleration to some directions, but compare to g, they are significant, so we can ignore it.
This is the diagram. As you can see, we assumed that gravity is always perpendicular to the earth surface.We know that our readings from accelerometer comes from three different axis. In this case we consider the X and Z axis readings.Now, we have to understand something which is really important in, when we have three axes the vector addition of acceleration in X and Z axis is not equal to gravity. However, in the diagram it may seem that it will be equal.
I talk about how to read your accelerometer here.
now lets say we have the reading in any unit. We call them, X_acceleration, Y_acceleration and Z_acceleration.
We have one variable which is called Gravity, recall from here ( How to read the output from accelerometer? ).
Now we find the angle theta which is equal to Y_angle. (it is rotation over the Y axis of sensor)
from the diagram, you can see that Y_angle = theta =cos-1( X_acceleration / Gravity )
(think of the triangle, I tried but I can't explain in words :( sorry )
we know that cos-1 has a range [0,180], but we may need to have a range from [0,360], in this case we use the Z axis reading. For my quad I used the range equal to [-90,90], this makes it easy for PID control, and much easier to understand.
now, we have Y_angle, in any form that we want from accelerometer.
For the case of gyroscope we need to use what I explained here. (How to use gyroscope?)
Y_angle can be obtain by Y_angle = previous_Y_angle + angle_change_y
previous_Y_angle is the last Y_angle we found which was measured at the last time that loop was repeated.
angle_change_Y is the out put of gyro in Y axis.
Now we have measured Y_angle using gyroscope.
Now, if you think you will notice that we do not have previous_Y_angle for the first time that we start the vehicle. They are two different approach, 1) always start the vehicle when it is flat so the previous_Y_angle is zero 2) using accelerometer to find previous_Y_angle and counting on accelerometer reading. These are the ways comes to my mind and I don't think there is any other way. You may use average or any filter in order to read the data from accelerometer, because as you know accelerometer has a lot of fluctuation. You will read that in detail in Shane's PDF later.
They are many ways to combine these values which are explained here:
http://web.mit.edu/scolton/www/filter.pdf
I have used the complimentary filter, it works fine.
this does not contain the Kalman filter, which I did not understand it myself, but you may understand it from this website: (they are some other parts that they have explained, but I think I have explained better ;) )
http://www.starlino.com/imu_guide.html
I never understood this. It is just so hard.
I think Shane has explained everything in that PDF and everyone will understand it.
The last obvious part is that after that filtering is done you have to do this:
previous_Y_angle = Y_angle_output_from_filter ;
this is necessary for gyroscope future readings.
Now, if you want to test your filter output read this.
Subscribe to:
Posts (Atom)