I am using linear potentiometer to control the speed of a DC motor. I am using the following schematic.
An ATmega328P receives the value from linear potentiometer via analog read. This ATmega328P transmits the value via CAN. Other ATmega328P receives it and analog writes the values via optocoupler (4N35) to the motor controller (Kelly's KDH14601E). The motor controller uses this value to control a 110V DC motor (lynch LEM 200 D135 RAGS). The High voltage and low voltage sides are completely isolated in the motor controller.
When the motor is disconnected or is in no load condition, everything works fine. But when there is load on the motor, both the microcontrollers stop responding. They basically freeze and the motor rotates at a constant speed. Sometimes the value fed to motor controller is corresponding to the last read value and sometimes a value which is not possible according to the code of microcontroller. I made some changes in the setup and have achieved following results-
Initially I was not using the optocoupler and the microcontrollers were hanging in no load condition also.
If I use a different LV (Low Voltage) supply for motor controller and optocoupler, everything works fine but I cannot do this in my final setup (I must use only 1 LV battery). In this case, both low voltage sources are completely isolated.
If I use a different LV (Low Voltage) supply for motor controller and optocoupler and connect the ground of both Low Voltage batteries, everything works almost fine. Sometimes the microcontroller reads a value which is not practically possible, but there is no hanging of microcontrollers.
I put a diode in the path which connects optocoupler output to motor controller, but observed no change.
Please help me out with this.
P.S.: The motor controller manual states that a potentiometer should be used to feed the controllers, but I cannot directly feed the value of linear potentiometer as I have to make certain modifications to the values.