I am using a MPU6050 gyroscope plugged into the I2C ports of the robot_hat. When the motors are not running it works great however as soon as I turn them on the power draw turns off the device and sometimes turns of the pi. My plan to fix this is to add a second battery to power the pi directly to reduce the overall pull on the system or to add more battery’s in parallel with the first two. Any advice would be greatly appreciated.
The method you mentioned is not feasible. The HAT is only compatible with a single set of two 18650 batteries and does not support additional battery connections in series.
I recommend using the MPU6050 gyro and motors while ensuring you have sufficient battery charge. It would also be helpful if you could provide us with a video of the issue you are experiencing.
Additionally, you might try connecting an external power supply to the Raspberry Pi to see if the device continues to shut down.
If you have any further questions, feel free to ask.
after looking further into the issue I it was a mix of the sensor I added turning off when I turned the motors on (I think this part is still a power issue but not a priority) and the motors not turning off properly making it look like the pi failed to send the correct commands. I have everything backed up to a GitHub repo so I fully reflashed the pi and installed everything following the instructions here. Even when running the default calibration script the motors will only turn on and off 2-4 times before refusing to do anything. The only workaround I have found is to create a new picarx object every time I need to turn off the motors. This solution is not ideal and causes other issues.
@app.route('/motor')
def control_motors():
global px
status = request.args.get('status')
if(status == 'on'):
px.set_motor_speed(0, -MOTOR_SPEED)
px.set_motor_speed(1, MOTOR_SPEED)
#px.forward(MOTOR_SPEED)
else:
#px.forward(0)
#px.stop()
px = Picarx() #works for turning off the motors but causes other issues
#px.set_motor_speed(0, 0)
#px.set_motor_speed(1, 0)
return '<h1> car is turning motor {} </h1>'.format(status)
After more testing the full issue is that with the MPU6050 connected to the I2C pins on the motor hat the motors on receiving the stop command will sometimes but no always go to full power in the wrong direction. After this error occurs all subsequent start/stop commands will only change the direction of the motor not the speed and all servos stop responding. this error occurs as long as I have the sensor plugged in on either I2C 1 or 0. receiving data from the sensor seems to make the error more common but its not a considerable difference. The address of the MPU6050 is 0x68 which has no overlap with any other I2C device on the car.
We are unsure if the code you are running has been modified.
Currently, we need to confirm whether the issue is related to the software or hardware. Can you run our example code to see if the hardware modules work properly?
Additionally, if there are any abnormalities after running the code, we suggest providing a video of the issue. This will help us analyze and resolve the problem more effectively.
I ran the second example with all default hardware. here is the video
Thank you for sharing the video link. However, it seems the current settings restrict access. To help us review the issue promptly, could you kindly update the sharing permissions to:
“Anyone with the link can view”
access has been updated
From your video, it seems that controlling the Picar-X car’s motors is out of control; even when you release the stop button, it still operates. Is this the issue?
We tested it to verify, and everything worked normally, so we can conclude that it shouldn’t be a software problem.
What version of the Picar-X do you have? Is it the version without a battery?
Have you reinstalled the new Raspberry Pi system and then installed all the software codes? Are you still experiencing the same problem?
What specifications does the battery you are currently using have? Please let us know.
it appears you may have the older version of PiCar-X. To better assist you, could you kindly share:
When you purchased the kit and the full picture of the car.