Note To Staff
There is no need for help here; I just wanted to share this with others, since it was useful to me. As far as I'm concerned (have power to say?), this code, text, graphics, and attachments are all public domain (preferably with attribution). If there is a specific area or protocol for these sorts of things, I haven't seen it. This post and contents could be stickied, moved, and otherwise used as the powers that be see fit. If there is something wrong, something that needs changed, or something the needs clarified, feel free. /Note To Staff
Hello all. I have a small gift for anyone that wants it.
The following is working javascript for GY-521 breakout boards, which holds the venerable InvenSense MPU-6050 6 axis IMU chips.
// -UNOFFICIAL SCRIPT- -AS IS- -NOT ENDORSED BY DIGILENT- -USE AT OWN RISK-// Author: Charles Scoville//// GY-521 breakout board: InvenSense MPU-6050 i2C Gryo + accelerometer// Set clock = 400kHz: Rate up to 400Hz (more may work): Itterations ~1kconst adr =0x68;// 0x69 is an alternate address.function initialize(){if(Clear()!=true)return"I2C bus error. Check the pull-ups.";if(Write(adr)!=true)return"Device NAK";//if(Read(adr, 0x75, 1) != 0x68) return "Device ID mismatch"; *FIXME* Read() bug? Does NOT actually return 0x68if(Write(adr,0x6B,0x03)!=0)return"Communication error";// REG: PWR_MGMT_1 (Z gyro as clock source)if(Write(adr,0x23,0x78)!=0)return"Communication error";// REG: FIFO_EN (FIFO only for Gyros and accelerometer)if(Write(adr,0x6A,0x45)!=0)return"Communication error";// REG: USER_CTRL (Reset FIFO and signal paths for all sensors)if(!FileWriteLine("~/Desktop/default.csv",["temp","ACCEL_XOUT","ACCEL_YOUT","ACCEL_ZOUT","GYRO_XOUT","GYRO_YOUT","GYRO_ZOUT"]))return"File write failed - init";returntrue;}function loop(){var rg =Read(adr,0x3B,14);// DATAvar xa =((rg[0]<<24)|(rg[1]<<16))/256/256;var ya =((rg[2]<<24)|(rg[3]<<16))/256/256;var za =((rg[4]<<24)|(rg[5]<<16))/256/256;// NOTE: REG 0x23 must be written as 0xF8 for temp to be bufferedvar tmp =((rg[6]<<24)|(rg[7]<<16))/256/256/340+36.53;//temp (deg C)//tmp = tmp * 1.8 + 32; //temp (deg F)var xg =((rg[8]<<24)|(rg[9]<<16))/256/256;var yg =((rg[10]<<24)|(rg[11]<<16))/256/256;var zg =((rg[12]<<24)|(rg[13]<<16))/256/256;if(!FileAppendLine("~/Desktop/default.csv",[tmp, xa, ya, za, xg, yg, zg]))return"File write failed - loop";returntrue;}function finish(){return"done";}
This script is to be used in the "protocol>i2c>sensor" section of the WaveForms application. I have only run this on the Electronics Explorer, I have no idea if it even applies to anything else. The results when run (with a GY-521 attached, of course!) are a CSV file on your desktop, just as with the PMOD gyro or accelerator example code it was based on.
For this data capture to make much sense, you will most likely want to graph the columns in the resulting file. I did so for the accelerometer and gyrometer as independent groups, as that provides the most informative and expected form for the data.
The following are some graphs of a couple of my more interesting captures, as examples. They were made with LibreOffice 6.0 directly from the CSV files. The ods files are also attached. (Embedded malware is thoroughly unlikely, but you still open at your own risk.)
This one was just me picking it up and turning it all around. It's a nice shot because it's pretty obvious when I picked it up, and what exactly I did.
This one was of me lifting the board up onto one corner, rapidly twisting it back and forth, then just setting it down. This one clearly has more samples too.
Anyway, thanks for reading. I hope this post has value to you.
Question
CharlesS
Note To Staff
There is no need for help here; I just wanted to share this with others, since it was useful to me. As far as I'm concerned (have power to say?), this code, text, graphics, and attachments are all public domain (preferably with attribution). If there is a specific area or protocol for these sorts of things, I haven't seen it. This post and contents could be stickied, moved, and otherwise used as the powers that be see fit. If there is something wrong, something that needs changed, or something the needs clarified, feel free.
/Note To Staff
Hello all. I have a small gift for anyone that wants it.
The following is working javascript for GY-521 breakout boards, which holds the venerable InvenSense MPU-6050 6 axis IMU chips.
This script is to be used in the "protocol>i2c>sensor" section of the WaveForms application. I have only run this on the Electronics Explorer, I have no idea if it even applies to anything else. The results when run (with a GY-521 attached, of course!) are a CSV file on your desktop, just as with the PMOD gyro or accelerator example code it was based on.
For this data capture to make much sense, you will most likely want to graph the columns in the resulting file. I did so for the accelerometer and gyrometer as independent groups, as that provides the most informative and expected form for the data.
The following are some graphs of a couple of my more interesting captures, as examples. They were made with LibreOffice 6.0 directly from the CSV files. The ods files are also attached. (Embedded malware is thoroughly unlikely, but you still open at your own risk.)
This one was just me picking it up and turning it all around. It's a nice shot because it's pretty obvious when I picked it up, and what exactly I did.
This one was of me lifting the board up onto one corner, rapidly twisting it back and forth, then just setting it down. This one clearly has more samples too.
Anyway, thanks for reading. I hope this post has value to you.
MPU-6050 readout1.ods
MPU-6050 readout2.ods
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.