Read GY-951 module data (Linux)

Source: Internet
Author: User

Reference: Https://github.com/Razor-AHRS/razor-9dof-ahrs/wiki/Tutorial#sensor-calibration

The hardware used in the link is SparkFun "9DOF Razor IMU", This article uses the GY-951, the same applies.

Hardware Connection method:

GY-951 module + Mini FT232RL (USB to serial port module)

Setup software:

Download and unzip the Razor AHRS firmware from the Https://github.com/Razor-AHRS/razor-9dof-ahrs/tree/master.

Download install Arduino software, unzip and enter the folder, open Terminal input./install.sh

  • from the downloaded Razor ahrs Firmware in the package Arduino/Razor_AHRS/Razor_AHRS.ino Use Arduino Open the file .
  • In the arduino :
    • See Razor_AHRS.ino At The top of the file , it contains useful information about the firmware.
    • In addition there is a part of the standard "USER SETUP AREA" There are places where you can set the firmware default values.
      • You must select the hardware "HARDWARE OPTIONS" you are using ! (Remove # define # Hw__version_code 10736 before comment)
    • go to "Tools""Board" and select "Arduino Pro or Pro Mini 处理器选(3.3v, 8mhz) w/ATmega328" .
    • go to "Tools""Serial Port" and select Port (/dev/ttyusb0).
    • go to "File" and hit "Upload to I/O Board" . after a short period of time at the bottom of the Arduino Code window "Done uploading" .
  • Turn on the Arduino serial monitor and set the baud rate to 57600.

If a permission error occurred while uploading

avrdude: ser_open(): can‘t open device "/dev/ttyUSB0": Permission denied

可在终端输入
sudo usermod -a -G dialout 用户名
sudo chmod a+rw /dev/ttyUSB0

Sensor calibration

a few minutes before the calibration give Chip the power supply may be good and the sensor can be warmed up. calibrating the sensor for the first time may be a bit tricky, but let's take a look:

  • Arduino/Razor_AHRS/Razor_AHRS.inoUse Arduino Open and find a section "USER SETUP AREA""SENSOR CALIBRATION" . This is where you place the calibration values later.

  • will be GY-951 Connect to your computer, in Arduino Set the correct serial port and open Serial Monitor .

  • If you do not change the firmware defaults, you should see a lot of such output:

      #YPR=-155.73,-76.48,-129.51
  • by sending a string the firmware Output Mode set to Calibration #oc . You should now see this output:

      accel x,y,z (min/max) = -5.00/-1.00  25.00/29.00  225.00/232.00

  1. calibrating the Accelerometer:
    • we will try to find the minimum and maximum output values of the Earth's gravity on each axis. when you move the board, move it slowly, so the smaller the acceleration of the board you apply, the better. We just want the sheer gravity!
    • pick up the circuit board and point vertically at the x-axis. When you do this, you can see that X-maximum (the second value) is getting bigger.
    • Keep the board stationary, then resend the Reset measurement #oc .
    • Now carefully tilt the board a little bit in each direction until the value is no longer large and write down the X maximum value.
    • do the same thing for the other side (x-axis up) to get the X minimum: move it to the position, send #oc Reset The measured value, find the x minimum and write it down.
    • Do the same thing for the z-axis (up and up) and y-axis (right and left).
      • If you think that the measurement results become too confusing by shaking or moving the board, you can reset #oc it at any time by sending .
    • You should now have all the minimum/maximum values. put them in Razor_AHRS.ino . (Razor_AHRS.ino的第245行开始的代码有详细校正方法)
    • Note : You must be very careful when doing this! Even tapping the circuit board with your fingers can make the measurement difficult and lead to incorrect calibration. #oc frequent use and careful examination of your min/max values)
  2. calibrating the magnetometer:
    • This time, you can shake as many boards as possible, but keep away from the electronic devices that have magnetic fields to avoid interference.

    • we still it's an accelerometer. Calibration Mode . send #on , move the calibration to the next sensor, the magnetometer.

    • Note: This section is for informational purposes only, but you should use the newer "extended magnetometer calibration (see the reference link for details) because it can produce better results!" You can skip this step and continue using the gyroscope.

    • we will try to find the minimum and maximum output values for the Earth's magnetic field on each axis. This basically works like calibrating an accelerometer, except that the Earth's magnetic field does not drop straight. Depending on where you are on the planet, it points at a certain angle to the northern hemisphere (southern hemisphere) or the northern Hemisphere (northern hemisphere). This angle is called the inclination . In addition, the real geography of the Arctic may have a slight deviation, which is called the red latitude . The following description assumes that you are calibrating a magnetometer in the northern hemisphere.

    • Place the board like the x-axis on the compass (remember: X-axis = forward, pointing to the connector hole) is pointing north. then start rotating the chessboard around the east-west axis so that it starts facing down. observing The x maximum in the serial monitor (the second value), you will notice when you turn the x-axis of the board to the Earth's magnetic field against the playhead. Stop the rotation, and then tilt slightly in each direction until the value is no longer larger.

    • Do the same thing for the opposite side to get the X minimum: the first point northward, then down.

    • for magnetometers, we don't need to be two times #oc to reset between measurements .

    • Do the same thing for the z-axis (up/down) and y-axis (left/right).

      • Note: Circuit board around the rotation of the axis to be measured is not important, but it points in the right direction. For example, when you start measuring the z-axis, the x-axis does not matter either up or down or to the left or right.
    • you should be here now . in the serial monitor There's something like this :

        magn x,y,z (min/max) = -564.00/656.00  -585.00/635.00  -550.00/564.00

      put these values into the Razor_AHRS.ino .

  3. calibrating the gyroscope:
      • still place Board on the table.

      • We still is a magnetometer Calibration mode . send #on , which moves the calibration to next The sensor, the gyroscope.

      • Wait 10 seconds, do not move Board . It collects and averages all three axes of noise on the gyroscope.

      • You should now have this output:

          gyro x, Y, z (current/average) = -29.00/-27.98 102.00/100.51-5.00/-5.85  
        • If you think you've messed up the measurement by shaking or moving the board, you can reset by sending it #oc .
      • Take the second value of each pair and put it in Razor_ahrs.ino .

    • Complete:)


Linux C + + Interface

into the C + + file

To compile the test program :

g++ Example.cpp RazorAHRS.cpp -Wall -D_REENTRANT -lpthread -o example

Perform:
./example



若出现报错:Did you set your serial port in Example.cpp?
先在Example.cpp中将串口名改为 “/dev/ttyUSB0”

再在终端输入:
sudo usermod -a -G dialout 用户名
sudo chmod a+rw /dev/ttyUSB0
(https://vps123.info/ubuntu-arduino-ide-err-open-device-permission-denied/)






也可参考:http://www.corvin.cn/428.html


欢迎交流。

Read GY-951 module data (Linux)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.