I have attached code to share for using a NI myRIO to interface with an InvenSense MPU-9250 9-axis IMU. I have used this great IMU as part of the control effort for a two wheel balancing robot called a "Segbot". Please note that the offset registers for the IMU will vary for each specific IMU.
Thanks for sharing! Another great place to upload code would be in the NI Community Examples. Here users can upload and make their content searchable for other LabVIEW users in the community. Follow the link below and click Upload Example Program.
This is a great example for using MPU-9250. I have a some question about hardware connection between MPU-9250 & myRIO. There are 10 pins on 9250(VCC, GND, SCL, SDA, EDA,ECL,ADO,INT, NCS,FSYNC). if i want to use SPI interface to receive data, which pins i need to connect to myRIO?
Thanks for your help. I still can't get any data. This is my connection
vcc --> pin 33
gnd --> pin 30
sclk --> pin 21
sdi --> pin 23
sdo --> pin 25
ncs --> pin 13 (?)
In the eaxmple vi, there is a DIO(pin 13). So i am not sure it should connect to ncs.
Does i make a wrong connection ?
I was also playing with the code recently. Thank you OP for posting this code available!
I figured out that the sdi and sdo need to be swapped in Andy's wiring setup to get the reading. This is because myRIO by default can only work as a master, so pin 25 is MOSI which corresponds to SDI on 9250, whereas, pin 23 is MISO which should be connected to SDO on 9250.
Andy's understanding of nCS is right, nCS needs to be low when communicating thru SPI. For the case we only have one 9250, nCS can also be directly connected to ground. For the case multiple slaves are on the line, each slave needs its own Digital IO nCS control when communicating.
Sorry, I made a mistake in my previous post, the nCS pin needs to be connected to a DIO for data transmission control, it needs to be low (active) at start and high (inactive) at the end. Only connecting it to ground will not work.