Skip to content
Snippets Groups Projects
Commit 24887f03 authored by Neil Gershenfeld's avatar Neil Gershenfeld
Browse files

wip

parent 188c78f7
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
input_devices/imu/6050/hello.MPU-6050.RP2040.holes.png

8.4 KiB

input_devices/imu/6050/hello.MPU-6050.RP2040.interior.png

7.83 KiB

input_devices/imu/6050/hello.MPU-6050.RP2040.jpg

937 KiB

File added
input_devices/imu/6050/hello.MPU-6050.RP2040.png

20.7 KiB

input_devices/imu/6050/hello.MPU-6050.RP2040.top.png

10 KiB

//
// hello.MPU-6050.ino
//
// MPU-6050 IMU hello-world
// based on https://github.com/ElectronicCats/imu6050/blob/master/examples/MPU6050_DMP6/MPU6050_DMP6.ino
//
// Neil Gershenfeld 10/20/24
//
// This work may be reproduced, modified, distributed,
// performed, and displayed for any purpose, but must
// acknowledge this project. Copyright is retained and
// must be preserved. The work is provided as is; no
// warranty is provided, and users accept all liability.
//
#include "MPU6050_6Axis_MotionApps20.h"
MPU6050 imu;
uint8_t status;
uint16_t size;
uint8_t buffer[64];
Quaternion q;
VectorInt16 accel;
VectorInt16 realaccel;
VectorInt16 gyro;
VectorFloat gravity;
float angles[3];
void setup() {
Wire.begin();
Wire.setClock(400000);
Serial.begin(115200);
while (!Serial);
Serial.println(F("initialize IMU"));
imu.initialize();
Serial.println(F("test connection"));
if (imu.testConnection() == false){
Serial.println("connection failed");
while(true);
}
else {
Serial.println("connection successful");
}
Serial.println(F("initialize DMP"));
status = imu.dmpInitialize();
imu.setXGyroOffset(0);
imu.setYGyroOffset(0);
imu.setZGyroOffset(0);
imu.setXAccelOffset(0);
imu.setYAccelOffset(0);
imu.setZAccelOffset(0);
if (status == 0) {
imu.CalibrateAccel(6);
imu.CalibrateGyro(6);
Serial.println(F("active offsets: "));
imu.PrintActiveOffsets();
Serial.println(F("enable DMP"));
imu.setDMPEnabled(true);
Serial.println(F("DMP ready"));
size = imu.dmpGetFIFOPacketSize();
}
else {
Serial.print(F("DMP initialization failed (code "));
Serial.print(status);
Serial.println(F(")"));
}
}
void loop() {
if (imu.dmpGetCurrentFIFOPacket(buffer)) {
imu.dmpGetQuaternion(&q,buffer);
imu.dmpGetGravity(&gravity,&q);
imu.dmpGetYawPitchRoll(angles,&q,&gravity);
imu.dmpGetAccel(&accel,buffer);
imu.dmpGetLinearAccel(&realaccel,&accel,&gravity);
Serial.print(angles[0]*180/M_PI);
Serial.print(",");
Serial.print(angles[1]*180/M_PI);
Serial.print(",");
Serial.print(angles[2]*180/M_PI);
Serial.print(",");
Serial.print(realaccel.x);
Serial.print(",");
Serial.print(realaccel.y);
Serial.print(",");
Serial.println(realaccel.z);
}
}
\ No newline at end of file
#
# hello.MPU-6050.py
#
# MPU-6050 IMU hello-world
#
# Neil Gershenfeld 10/20/24
#
# This work may be reproduced, modified, distributed,
# performed, and displayed for any purpose, but must
# acknowledge this project. Copyright is retained and
# must be preserved. The work is provided as is; no
# warranty is provided, and users accept all liability.
#
from tkinter import *
import serial,sys
WINDOW = 1000 # window size
def idle(parent,canvas):
roll = pitch= yaw = ax = ay = az = 0
#
# read data
#
s = ser.readline().decode('utf-8')
try:
yaw = float(s.split(',')[0])
pitch = float(s.split(',')[1])
roll = float(s.split(',')[2])
ax = float(s.split(',')[3])
ay = float(s.split(',')[4])
az = float(s.split(',')[5])
except:
pass
#
#
# plot
#
canvas.itemconfigure("roll",text=f"roll: {roll:.1f}")
x = int(.3*WINDOW + (.9-.3)*WINDOW*(0.5+0.5*roll/180))
canvas.coords('roll1',.3*WINDOW,.05*WINDOW,x,.2*WINDOW)
canvas.coords('roll2',x,.05*WINDOW,.9*WINDOW,.2*WINDOW)
canvas.itemconfigure("pitch",text=f"pitch: {pitch:.1f}")
x = int(.3*WINDOW + (.9-.3)*WINDOW*(0.5+0.5*pitch/180))
canvas.coords('pitch1',.3*WINDOW,.25*WINDOW,x,.4*WINDOW)
canvas.coords('pitch2',x,.25*WINDOW,.9*WINDOW,.4*WINDOW)
canvas.itemconfigure("yaw",text=f"yaw: {yaw:.1f}")
x = int(.3*WINDOW + (.9-.3)*WINDOW*(0.5+0.5*yaw/180))
canvas.coords('yaw1',.3*WINDOW,.45*WINDOW,x,.6*WINDOW)
canvas.coords('yaw2',x,.45*WINDOW,.9*WINDOW,.6*WINDOW)
canvas.itemconfigure("ax",text=f"ax: {ax:.0f}")
x = int(.3*WINDOW + (.9-.3)*WINDOW*(0.5+0.5*ax/12000))
canvas.coords('ax1',.3*WINDOW,.65*WINDOW,x,.8*WINDOW)
canvas.coords('ax2',x,.65*WINDOW,.9*WINDOW,.8*WINDOW)
canvas.itemconfigure("ay",text=f"ay: {ay:.0f}")
x = int(.3*WINDOW + (.9-.3)*WINDOW*(0.5+0.5*ay/12000))
canvas.coords('ay1',.3*WINDOW,.85*WINDOW,x,1*WINDOW)
canvas.coords('ay2',x,.85*WINDOW,.9*WINDOW,1*WINDOW)
canvas.itemconfigure("az",text=f"az: {az:.0f}")
x = int(.3*WINDOW + (.9-.3)*WINDOW*(0.5+0.5*az/12000))
canvas.coords('az1',.3*WINDOW,1.05*WINDOW,x,1.2*WINDOW)
canvas.coords('az2',x,1.05*WINDOW,.9*WINDOW,1.2*WINDOW)
#
# update
#
canvas.update()
parent.after_idle(idle,parent,canvas)
#
# check command line arguments
#
if (len(sys.argv) != 2):
print("command line: hello.MPU-6050.py serial_port")
sys.exit()
port = sys.argv[1]
#
# open serial port
#
ser = serial.Serial(port,115200)
#
# set up GUI
#
root = Tk()
root.title('hello.MPU-6050.py (q to exit)')
root.bind('q','exit')
canvas = Canvas(root,width=WINDOW,height=1.25*WINDOW,background='white')
#
canvas.create_text(.025*WINDOW,.125*WINDOW,text="1",font=("Helvetica",28),tags="roll",fill="#0000b0",anchor=SW)
canvas.create_rectangle(.3*WINDOW,.05*WINDOW,.4*WINDOW,.2*WINDOW,tags='roll1', fill='#b00000')
canvas.create_rectangle(.4*WINDOW,.05*WINDOW,.9*WINDOW,.2*WINDOW,tags='roll2', fill='#0000b0')
#
canvas.create_text(.025*WINDOW,.325*WINDOW,text="1",font=("Helvetica",28),tags="pitch",fill="#0000b0",anchor=SW)
canvas.create_rectangle(.3*WINDOW,.25*WINDOW,.4*WINDOW,.4*WINDOW,tags='pitch1', fill='#b00000')
canvas.create_rectangle(.4*WINDOW,.25*WINDOW,.9*WINDOW,.4*WINDOW,tags='pitch2', fill='#0000b0')
#
canvas.create_text(.025*WINDOW,.525*WINDOW,text="1",font=("Helvetica",28),tags="yaw",fill="#0000b0",anchor=SW)
canvas.create_rectangle(.3*WINDOW,.45*WINDOW,.4*WINDOW,.6*WINDOW,tags='yaw1', fill='#b00000')
canvas.create_rectangle(.4*WINDOW,.45*WINDOW,.9*WINDOW,.6*WINDOW,tags='yaw2', fill='#0000b0')
#
canvas.create_text(.025*WINDOW,.725*WINDOW,text="1",font=("Helvetica",28),tags="ax",fill="#0000b0",anchor=SW)
canvas.create_rectangle(.3*WINDOW,.65*WINDOW,.4*WINDOW,.8*WINDOW,tags='ax1', fill='#b00000')
canvas.create_rectangle(.4*WINDOW,.65*WINDOW,.9*WINDOW,.8*WINDOW,tags='ax2', fill='#0000b0')
#
canvas.create_text(.025*WINDOW,.925*WINDOW,text="1",font=("Helvetica",28),tags="ay",fill="#0000b0",anchor=SW)
canvas.create_rectangle(.3*WINDOW,.85*WINDOW,.4*WINDOW,1*WINDOW,tags='ay1', fill='#b00000')
canvas.create_rectangle(.4*WINDOW,.85*WINDOW,.9*WINDOW,1*WINDOW,tags='ay2', fill='#0000b0')
#
canvas.create_text(.025*WINDOW,1.125*WINDOW,text="1",font=("Helvetica",28),tags="az",fill="#0000b0",anchor=SW)
canvas.create_rectangle(.3*WINDOW,1.05*WINDOW,.4*WINDOW,1.2*WINDOW,tags='az1', fill='#b00000')
canvas.create_rectangle(.4*WINDOW,1.05*WINDOW,.9*WINDOW,1.2*WINDOW,tags='az2', fill='#0000b0')
#
canvas.pack()
#
# start idle loop
#
root.after(100,idle,root,canvas)
root.mainloop()
......@@ -114,7 +114,6 @@
<a href=tof/hello.VL53L1X.t1614>hello.VL53L1X.t1614</a> <a href=tof/hello.VL53L1X.t1614.png>board</a> <a href=tof/hello.VL53L1X.t1614.jpg>components</a> <a href=tof/hello.VL53L1X.t1614.traces.png>traces</a> <a href=tof/hello.VL53L1X.t1614.traces_exterior.png>traces+exterior</a> <a href=tof/hello.VL53L1X.t1614.interior.png>interior</a>
<a href=tof/hello.VL53L1X.ino>hello.VL53L1X.ino</a> <a href=tof/hello.VL53L1X.py>hello.VL53L1X.py</a> <a href=tof/hello.VL53L1X.mp4>video</a>
<a href=https://www.digikey.com/en/products/detail/stmicroelectronics/VL53L5CXV0GC-1/14552424>VL53L5CX</a> <a href=https://www.pololu.com/product/3417>module</a>
coming
<a href=http://www.amazon.com/SunFounder-Ultrasonic-Distance-Mega2560-Duemilanove/dp/B00E0NXTJW>sonar</a>
<A href=sonar/hello.HC-SR04>hello.HC-SR04</A> <A href=sonar/hello.HC-SR04.png>board</A> <A href=sonar/hello.HC-SR04.jpg>components</A> <a href=sonar/hello.HC-SR04.traces.png>traces</a> <a href=sonar/hello.HC-SR04.traces_exterior.png>traces+exterior</a> <a href=sonar/hello.HC-SR04.interior.png>interior</a>
<A href=sonar/hello.HC-SR04.c>hello.HC-SR04.c</A> <A href=sonar/hello.HC-SR04.make>makefile</A>
......@@ -126,30 +125,29 @@
<a href=GPS/hello.GPS.t1614>hello.GPS.t1614</a> <a href=GPS/hello.GPS.t1614.png>board</a> <a href=GPS/hello.GPS.t1614.jpg>components</a> <a href=GPS/hello.GPS.t1614.traces.png>traces</a> <a href=GPS/hello.GPS.t1614.traces_exterior.png>traces+exterior</a> <a href=GPS/hello.GPS.t1614.interior.png>interior</a>
<a href=GPS/hello.GPS.t1614.ino>hello.GPS.t1614.ino</a> <a href=GPS/hello.GPS.t1614.mp4>video</a>
<b>acceleration, orientation, rotation</b>
<a href=https://www.digikey.com/en/products/detail/ceva-technologies-inc/BNO085/9445940>9 axis accelerometer+gyroscope+magnetometer</a> <a href=https://www.adafruit.com/product/4754>module</a>
<a href=https://learn.adafruit.com/adafruit-9-dof-orientation-imu-fusion-breakout-bno085/overview>RVC serial</a>
<a href=imu/hello.4754.RP2040>hello.4754.RP2040</a> <a href=imu/hello.4754.RP2040.png>board</a> <a href=imu/hello.4754.RP2040.jpg>components</a> <a href=imu/hello.4754.RP2040.top.png>traces</a> <a href=imu/hello.4754.RP2040.holes.png>holes</a> <a href=imu/hello.4754.RP2040.interior.png>interior</a>
<a href=imu/hello.4754.RP2040.py>hello.4754.RP2040.py</a> <a href=imu/hello.4754.RP2040.html>hello.4754.RP2040.html</a> <a href=imu/hello.4754.RP2040.mp4>video</a>
<a href=https://www.ceva-ip.com/wp-content/uploads/2019/10/SH-2-Reference-Manual.pdf>SH2</a> <a href=https://github.com/ceva-dsp/sh2>library</a> <a href=https://github.com/sparkfun/SparkFun_BNO08x_Arduino_Library>I2C</a>
coming
<a href=https://www.digikey.com/en/products/detail/stmicroelectronics/LSM6DS33TR/5452393>6 axis accelerometer+gyroscope</a>
<a href=https://www.digikey.com/en/products/detail/pololu-corporation/2736/10451119>module</a> <a href=https://github.com/pololu/lsm6-arduino>library</a>
<a href=accelgyro/hello.LSM6DS33.t1614>hello.LSM6DS33.t1614</a> <a href=accelgyro/hello.LSM6DS33.t1614.png>board</a> <a href=accelgyro/hello.LSM6DS33.jpg>components</a> <a href=accelgyro/hello.LSM6DS33.t1614.traces.png>traces</a> <a href=accelgyro/hello.LSM6DS33.t1614.traces_exterior.png>traces+exterior</a> <a href=accelgyro/hello.LSM6DS33.t1614.interior.png>interior</a>
<a href=accelgyro/hello.LSM6DS33.ino>hello.LSM6DS33.ino</a> <a href=accelgyro/hello.LSM6DS33.py>hello.LSM6DS33.py</a> <a href=accelgyro/hello.LSM6DS33.mp4>video</a>
<a href=https://www.amazon.com/HiLetgo-MPU-6050-Accelerometer-Gyroscope-Converter/dp/B00LP25V1A/?th=1>module</a>
coming
<a href=https://www.digikey.com/en/products/detail/analog-devices-inc/ADXL343BCCZ/3542918>3 axis accelerometer</a>
<b>acceleration, rotation, orientation, IMU</b>
3 axis accelerometer
<a href=https://www.digikey.com/en/products/detail/analog-devices-inc/ADXL343BCCZ/3542918>ADXL343</a>
<A href=accel/hello.ADXL343>hello.ADXL343</A> <A href=accel/hello.ADXL343.png>board</A> <A href=accel/hello.ADXL343.jpg>components</A> <a href=accel/hello.ADXL343.reflow.jpg>reflow</a> <a href=accel/hello.ADXL343.traces.png>traces</a> <a href=accel/hello.ADXL343.traces_exterior.png>traces+exterior</a> <a href=accel/hello.ADXL343.interior.png>interior</a>
<A href=accel/hello.ADXL343.c>hello.ADXL343.c</A> <A href=accel/hello.ADXL343.make>makefile</A> <a href=http://www.analog.com/media/en/technical-documentation/data-sheets/ADXL343.pdf>calibration</a>
<A href=accel/hello.ADXL343.py>hello.ADXL343.py</A> <A href=accel/hello.ADXL343.mp4>video</A>
6 axis accelerometer+gyroscope
<a href=https://invensense.tdk.com/products/motion-tracking/6-axis/mpu-6050>MPU-6050</a> <a href=https://www.amazon.com/HiLetgo-MPU-6050-Accelerometer-Gyroscope-Converter/dp/B00LP25V1A>module</a> <a href=https://invensense.tdk.com/products/motion-tracking/6-axis/icm-20609>ICM-20609</a>
<a href=imu/6050/hello.MPU-6050.RP2040>hello.MPU-6050.RP2040</a> <a href=imu/6050/hello.MPU-6050.RP2040.png>board</a> <a href=imu/6050/hello.MPU-6050.RP2040.jpg>components</a> <a href=imu/6050/hello.MPU-6050.RP2040.top.png>top</a> <a href=imu/6050/hello.MPU-6050.RP2040.holes.png>holes</a> <a href=imu/6050/hello.MPU-6050.RP2040.interior.png>interior</a>
<a href=imu/6050/hello.MPU-6050.ino>hello.MPU-6050.ino</a> <a href=imu/6050/hello.MPU-6050.py>hello.MPU-6050.py</a> <a href=imu/6050/hello.MPU-6050.RP2040.mp4>video</a>
9 axis accelerometer+gyroscope+magnetometer
<a href=https://www.digikey.com/en/products/detail/ceva-technologies-inc/BNO085/9445940>BNO085</a> <a href=https://www.adafruit.com/product/4754>module</a> <a href=https://www.digikey.com/en/products/detail/ceva-technologies-inc/BNO086/14114190>BNO086</a>
<a href=https://learn.adafruit.com/adafruit-9-dof-orientation-imu-fusion-breakout-bno085?view=all>RVC serial</a>
<a href=imu/hello.4754.RP2040>hello.4754.RP2040</a> <a href=imu/hello.4754.RP2040.png>board</a> <a href=imu/hello.4754.RP2040.jpg>components</a> <a href=imu/hello.4754.RP2040.top.png>traces</a> <a href=imu/hello.4754.RP2040.holes.png>holes</a> <a href=imu/hello.4754.RP2040.interior.png>interior</a>
<a href=imu/hello.4754.RP2040.py>hello.4754.RP2040.py</a> <a href=imu/hello.4754.RP2040.html>hello.4754.RP2040.html</a> <a href=imu/hello.4754.RP2040.mp4>video</a>
<a href=https://www.ceva-ip.com/wp-content/uploads/2019/10/SH-2-Reference-Manual.pdf>SH2</a> <a href=https://github.com/ceva-dsp/sh2>library</a> <a href=https://github.com/sparkfun/SparkFun_BNO08x_Arduino_Library>I2C</a>
<a href=https://invensense.tdk.com/products/motion-tracking/9-axis/mpu-9250>MPU-9250</a> <a href=https://invensense.tdk.com/products/motion-tracking/9-axis/icm-20948/>ICM-20948</a> <a href=https://www.adafruit.com/product/4554>module</a>
<b>sound</b>
MEMS
digital
<a href=https://www.sparkfun.com/datasheets/BreakoutBoards/I2SBUS.pdf>I2S</a> <a href=https://www.arduino.cc/en/Reference/I2S>Arduino</a> <a href=https://docs.micropython.org/en/latest/library/machine.I2S.html>MicroPython</a>
<a href=https://www.digikey.com/en/products/detail/knowles/SPH0645LM4H-B/5332440>bottom port</a>
coming
<a href=https://www.digikey.com/en/products/detail/cui-devices/CMM-4030D-261-I2S-TR/13164051>top port</a>
<a href=mic/hello.CMM-4030D-261-I2S-TR.t1614>hello.CMM-4030D-261-I2S-TR.t1614</a> <a href=mic/hello.CMM-4030D-261-I2S-TR.t1614.png>board</a> <a href=mic/hello.CMM-4030D-261-I2S-TR.jpg>components</a> <a href=mic/hello.CMM-4030D-261-I2S-TR.t1614.traces.png>traces</a> <a href=mic/hello.CMM-4030D-261-I2S-TR.t1614.traces_exterior.png>traces+exterior</a> <a href=mic/hello.CMM-4030D-261-I2S-TR.t1614.interior.png>interior</a>
<a href=mic/hello.CMM-4030D-261-I2S-TR.ino>hello.CMM-4030D-261-I2S-TR.ino</a> <a href=mic/hello.CMM-4030D-261-I2S-TR.py>hello.CMM-4030D-261-I2S-TR.py</a> <a href=mic/hello.CMM-4030D-261-I2S-TR.mp4>video</a>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment