I've set up a system where I am controlling two motors using a closed feedback system with a PI controller. Here are the details:
Reference Value: This is set directly in the code.
System Output Measurement: I'm using an IR sensor to get the output value for the feedback loop.
Noise Reduction: I've implemented a simple low-pass filter to help with noise reduction.
Despite these implementations, one of the motor's readings either randomly drops or increases, which is unexpected. I've attached a figure below showing the random drop/increase.
Could be the code, intermittent wiring, malfunctioning speed sensor, inadequate power supply, etc.
For informed help, please take a few moments to read and follow the directions in the "How to get the best out of this forum" post, linked at the head of very forum category.
Thank you for your reply. I've reviewed the guidelines on "How to get the best out of this forum". Here's a summary of the hardware I'm working with:
2x BTS7960 drivers
2x 12v 775 motors
1x 12v lead acid battery powering both motors/drivers.
1x Arduino uno (ATMega328P) (not powered via the 12v battery, it's powered via the USB-B connected to the computer)
2x FC-51 infrared sensors
I don't think it's my code, as the problem is intermittent. Additionally, sometimes when I power motors, after updating the MCU code, there is either a massive overshoot in RPM or the motors run at max RPM and do not drop to the reference value set in the code. An example of this is shown in the below image where the reference value was set to 400RPM for motor 2 (black line), 600RPM for motor 1 (yellow line).
The schematic helps but it is not complete, as it does not show how 5V is derived.
Your description of the problem suggests that the Arduino power supply is not adequately decoupled (filtered) and/or that electrical noise from the motors is disrupting sensor data or Arduino operation.
Ground loops are also a possibility. Use "star grounding" and keep motor power leads and drivers well away from the Arduino and sensor wiring.
I implemented star grounding and this didn't help, unfortunately.
Going back to the first problem of the intermittent fluctuations at rpm2 readings, I tried swapping the sensors and motor wiring as shown in the drawing below, and rpm1 readings are now fluctuating intermittently. Does this mean it's a problem with motor driver 2?