I have what seems like a simple overlook on my part but I’ve been scratching my head over it for the last two days.
I have a teensy 4.1 reading and MPU6050 and setting the current (-9 to 9 amps) to the Odrive on both M0 and M1. The Teensy works great reading values and doing what it needs to do, until I plug in the Odrive. I can tell the Odrive is receiving commands for about 1-2 seconds before the Teensy shuts down. It is being powered over USB and using Serial to send data to the serial monitor and I am using Serial1 to transmit data to the Odrive. I have verified the TX/RX are plugged into the correct spots and I have tied the Odrive GND to the Teensy GND.
Right now I am using a 4S 1500mah lipo before I go over to my 36v battery. I have even limited the output commands to -1 to 1 amp as I thought perhaps the battery just wasn’t able to keep up with the demand but it was not successful. Nothing was different. Then I added the brake resistor believing that perhaps there was current being backfed to the Teensy and that also didn’t help.
What should I be looking at to diagnose and fix the problem?
Thank you all in advance for any help you can provide.
So, I think I have narrowed it down to a power issue. I have commented out the Serial1.begin and any commands going to the Odrive and yet still when I plug power in, the Teensy stops working. I get about 1 second worth of readings from my MPU after I plug power in and then it just sticks with the same reading in the serial monitor.
I’ll post my a picture of my setup and code later if y’all could be kind enough to check it out but at this point it feels like I’m getting noise in signal lines at power up of the Odrive. Going on 3 days with this issue, I’m starting to pull my hair out. Lol
I have considered that. I was looking into this last night. From what I’ve gathered a ground loop is created when two items share a power source (i.e. microcontroller and Odrive). My Odrive is powered via the 4s lipo and the microcontroller is powered via USB. Perhaps I read it wrong. Regardless, I did try adding 4k resistors to the signal wires as described in the documentation but it did not solve the problem. I am about to start from scratch and see if that helps. Do I need to be setting GPIO or the Teensy pins a particular way? All the sample code I have looked at did not but I drawing straws.
So for SNGs I decided to try this same code on a Mega2560 I had laying around. I get the exact same response so I can officially take any Teensy hardware concerns off the table. At this point I am convinced it is either code or something being backfed from the Odrive. Tomorrow I am going to go all the way back to basics and ensure I can get the Odrive sample code to run. If I can, it has to be my code. We shall see.
See if your problem goes away when you don’t start up in closed loop (it will probably come back when you enter closed loop though)
Do you know if the Teensy is actually resetting or maybe it’s going to some fault handler? Possibly related to i2c comms with your sensor.
I will certainly give that a shot and honestly that’s a really good question. And now that you mention it, it could be a fault in the i2c. I don’t know how I would check this though. While I look into this, do you have any recommendations for checking that?
I have yet to isolate the USB power and signal as my end goal would require this. This will likely be my last ditch effort to solve the problem when I’ve exhausted all other possibilities as it would force me to refigure the setup.
I setup the Teensy 4.1 on the breadboard with only the three required wires for RX/TX/GND (exactly how I had it before) and loaded the OdriveArduinoTest script. It ran perfectly. I was able to do the test move without error or anything going awry. I’ve never been able to get bus voltage through that code, but that’s another matter.
This leads me to believe that it is in fact my code. I will continue to reintroduce the mpu6050 and other items back into the system and see exactly where I went wrong.
Thank you for all the help and insight everyone has provided. I will update this thread as I get a more specific diagnosis of what was wrong.