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-

  1. Initially I was not using the optocoupler and the microcontrollers were hanging in no load condition also.

  2. 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.

  3. 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.

  4. I put a diode in the path which connects optocoupler output to motor controller, but observed no change.

schematic

Please help me out with this.

I am adding further details about connections around ATMEGA 328P in the new attachment

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.

Thanks.

  • 2
    Show the circuit you built around the ATMEGA 328P. That's most likely where the problem lies. That in combination with powering the 328 from the same source as the motor. – JRE Nov 7 at 18:16
  • 1
    This may not be related to your current problem, but supplying a PWM signal to a device designed for an analog voltage may not work correctly. Unless the controller is designed to support a PWM input, you may be better off using a low-pass filter on the PWM or using a DAC to supply a DC voltage. – ajb Nov 7 at 18:41
  • @JRE I have added new details about connections around ATMEGA 328P as well as the power suppies to both controllers. Thank You – Parimeya Ranadive Nov 8 at 13:37
  • @ajb I will try installing a DAC. I was trying to avoid it because when I was using different power supplies the motor controller was working fine with PWM also. Thank You – Parimeya Ranadive Nov 8 at 13:37
  • There's your problem. No decoupling capacitor for the 328. No time to write up a goid answer. Maybe some one else will explain it in detail. – JRE Nov 8 at 14:24

If your sketch is to be trusted, you haven't included a decoupling capacitor for the ATmega328P.

That's most likely the cause of your problems - especially since you mention it working correctly if you power the ATmega328P and the motor driver from seperate power supplies.

There are tons of questions and answers on this site about what decoupling capacitors are and how to use them.

You probably need at least a 100nF capacitor from ground to each Vcc pin on the ATmega328P.

Since you show two Vcc pins, you will need two capacitors. Place each capacitor as close as possible to the Vcc pin it serves.

You may also need a single, larger capacitor on the board with the ATmega328P. Say, like, 1 to 10uF.

Try that out, and read up on decoupling capacitors. You will encounter them often in pretty much all kinds of circuits.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.