Also with the processing development environment, we will make some practical applications using the sensors first let’s briefly explain how each of these micro, electromechanical systems or MEMS sensor work. We will start with the accelerometer it measures acceleration by measuring change in capacitance. Its microstructure looks something like this: it has a mass attached to a screen which is confined to move along one direction and fixed outer plates. So when an acceleration in the particular direction will be applied, the mass will move and the capacitance between the plates and the mass will change. This change in capacitance will be measured process and it will correspond to a particular acceleration value. Next is the gyroscope which measures angular rate using the Coriolis effect when a mass is moving in a particular direction, with a particular velocity and when an external angular rate will be applied, as shown with the green arrow, a force will occur, as shown with the blue Arrow, which will cause perpendicular displacement of the mass so similar to the accelerometer. This displacement will cause change in capacitance, which will be measured process and it will correspond to a particular angular rate. The microstructure of the gyroscope looks something like this: a mass that is constantly moving or oscillating and when an external angular rate will be applied, a flexible part of the mass would move and make the perpendicular displacement. Okay, now let’s explain how the magnetometer works. It measures the earth magnetic field by using Hall FA or magnet or resistive effect.
Actually, almost 90 percent of the sensors on the market use the Hall effect and here’s how it works. If we have a conductive plate like this, and we set current to flow to it, the electrons would flow straight from one to the other side of the plate. Now, if we bring some magnetic field near the play, we will disturb the straight flow and the electrons will deflect to one side of the plate and positive poles to the other side of the plate. This means that if we put a mirror now between these two sides, we will get some voltage, which depends from the magnetic field, strength and its direction. The other ten percents of the sensors on the market use the magnet or resistive effect. These sensors use materials that are sensitive to magnetic field, usually composed of iron and nickel. So when these materials are exposed to magnetic field, they change their resistance. Okay, now let’s connect these scissors to the Arduino board and make some use of them. As an example, I will use the G Yad, breakout board, which has the following: sensors: a DXL 345 Q, axis accelerometer, LG, g4, 200 D, 3 axis gyroscope, MC 588, 3, L, 3, axis magnetometer, and also a barometer and a thermometer which we won’t use in this Tutorial first let’s hook up the board to the Arduino. This board used the I Square C communication protocol, which means that we can use all the sensors with just 2 wires.
So, in order to make the communication between the Arduino and the sensors, we need to know their unique device addresses and their internal register addresses for getting the data out of them. These addresses can be found from the datasheet of the sensor and I have attached links to each of them on my website for more details, how this communication works. You can check my I square C communication tutorial. Ok, now let’s see the code for getting the data from the sensors. We will start with the accelerometer first, we need to include the arduino wire library and define the registers addresses of the sensor in the setup section. We need to initiate the wire library and start the serial communication, as we will use the serial monitor for showing the results. Also. Here we need to activate the sensor or enable the measurement, by sending appropriate bye to the power control register and here’s. How we do that using the wire dot begin transmission function, we leg two, which sensor we will talk the three axis accelerometer in this case, then, using the wire dot write function we tale to which internal register we will talk. After this, we will send the appropriate by for enabling the measurement using the wire dot in transmission function. We will end the transmission and that will transmit the data to the registers. Now, in the loop section, we need to read the data for each axis. We will start with the x axis, so first we will select which registers we will talk.
The two x axis internal registers. In this case, then, using the wire dot request from function. We will request the transmitted data or the two bytes from the two registers. The wire dot available function will return the number of bytes available for retrieval and if that number match, with our requested bytes in our case two bytes using the wired dot read function, we will read the bytes from the two registers of the x axis: the output Data from the two registers is two’s complement with x0 as the least significant byte and x1 as the most significant byte. Using this expressions here, we can convert these bytes in to float values from minus one to plus one, depending on the direction of the x axis. Relative to the earth acceleration or the gravity, we will repeat this procedure for the two other axis and at the end we will print these values on. The serial monitor here is how they appear. Okay, now for getting the data from the gyroscope, we will have a similar code as the previous one. So first we have to define the register, addresses and sign variables for the data. In the setup section, we have to wake up and put the sensor in normal mode, using the control register one and also select the sensitivity of the sensor. For this example, I will select the 2000 DPS or degrees per second sensitivity mode. In the loop section similar to the accelerometer, we will read the data for the x yampz axis now.
The raw data has to be converted into angle values from the data sheet of the sensor. We can see that for the 2000 DPS or degrees per second sensitivity mode corresponds a 70 mil it agrees per second or digit unit. This means that we have to multiply the row output data by zero point: zero, seven in order to get the angular rate in degrees per second. Now, if we multiply the angular rate by time, it will give us the angle value. So we need to calculate the time interval of each loop section and we can do that by using the moolies function at the top and the bottom of the loop section, and we will store it value into this DT variable. So for each executed loop, we will calculate the angle and add it to the final angle value. We will do the same for the two other axes and at the end we will print. The results on the serial monitor here is how they appear. The pen shows the x axis of the sensor, so if I rotate the sensor around that axis, we can see the change of the angle on the serial monitor, keep in mind that the gyro result are not stable because they drift as the time goes. So, in order to get accurate angles, we have to combine it with the accelerometer here’s, an example of that combining the gyro and the accelerometer data, as well as the complimentary filter for smoothing the results.
So the data from the sensors and the Arduino board are sent to the processing development and they are used for controlling the orientation of the 3d object. You can find more details and the source codes for this example on my website. What’S left now is to see how to get the data from the magnetometer again. We will use a similar technique to the previous one. First, we need to define the registers addresses and in the setup section set the sensor in continuous measurement mode in the loop section. We will get the raw data for each axis with the same method as for the previous sensors. Now we need to convert the raw data into magnetic field, value or gauss units. From the data sheet of the sensor, we can see that the default sensitivity mode is 0.92 milli, Gauss per digit. This means that we need to multiply the row data by zero point: zero: zero, zero 92 in order to get the earth magnetic field in Gauss units. At the end, we will print the values on the serial monitor. Here I have marked the North Pole on the paper and pen shows the y axis of the sensor. Now, if I point the y axis to the North Pole and fill the sensor around 45 degrees, I will get the maximum value of around zero point six cows. The tilt angle, depends on your location. For example, if you are at the equator, you don’t have to tilt the sensor, because the inclination at that location is zero or if you are at the North Pole, you will have to tell the sensor 90 degrees.
Here is a cool looking application of the sensor.
arduino gyroscope Video
arduino gyroscope news
Posted on Thursday September 19, 2019Spartan Edge Accelerator Arduino Compatible Board Combines ESP32 & Spartan-7 FPGA CNX Software … Continue Reading »
Posted on Wednesday September 25, 2019ESPcopter: A Fully Customizable Drone Hackaday … Continue Reading »
Posted on Wednesday September 25, 201925 | September | 2019 Hackaday … Continue Reading »
arduino gyroscope Social
🔬 Now that you’ve gotten your feet wet, dive into the kit and enjoy all nine experiments. Order yours today: http://bit.ly/2MnQ7fr
#arduino #robot #technology #electronics #robotocs #gyroscope #youtube #subscribe
Originally posted 2015-11-03 01:04:45.