Motor controller help! - Page 1
Forum section: electronics / beginners

author: ManlishPotato
author_rank: Regular Contributor
timestamp: May 01, 2019, 01:21:23 pm
content: Hi!I've been ripping my hair of trying to get this project to work, but seemingly no matter what i do i haven't been able to make it work reliably.It's real simple really, just a atmega328 (non p) -pu + SN754410NE (essentially a l293 quad half-bridge).The motor is a small 3-6 volt 100mA dc motor. The motor and micro-controller are driven by separate voltage, 6v@500mA and 5v@100mA respectively.What happens is that i'll connect high or 5v from atmega to the motor controller, the motor spin from 1sec to at best 1min, when suddenly the 5v from atmega will collapse to 0v, and will remain like that until i reboot it.My instinct was at first to directly connect atmega to motor controller without resistor pulled to ground like i did when prototyping with uno. But that didn't work at all with a raw atmega. At this point i have no idea as to why this isn't working.Schematic and picture:https://drive.google.com/drive/folders/1f7N4JG-nSVDko5vl9TXt3NpuTDINw7SS?usp=sharingI'm not sure if this is a incredibly stupid question, but any answers are appreciated!Thanks in advance!ManlishPotato

author: Psi
author_rank: Super Contributor
timestamp: May 01, 2019, 01:44:13 pm
content: The first thing i see looking at your schematic is that you've not grounded both of the ATMega's ground pins.Pin 8 is missing a ground.Both Pin 22 and Pin 8 must be grounded externally.Also you seem to have 3 power rails VCC , 5V and 6VShould that 5V on pin 16 of SN754410NE actually be VCC ?

author: ManlishPotato
author_rank: Regular Contributor
timestamp: May 01, 2019, 01:48:09 pm
content: Whoops! That was a schematic errror. In the real world pin 8 is grounded, i should also note that the two separate voltages are connected via ground.

author: Psi
author_rank: Super Contributor
timestamp: May 01, 2019, 01:49:55 pm
content: Another thing is that you need some supply rail decoupling capacitors.Put a 100nF cap between VCC and GND on each IC, as close as possible to the ICs two power pins.Also put one between V6 and GND right at the SN754410So 3x 100nF caps in total.If you dont have any 100nF (0.1uF) caps you can use 1000nF (1uF) or anything in betweenWithout these the inductive spikes from the motor maybe getting onto the supply rail and crashing the ATMegaAlso, breadboard connections suck for reliability.

author: ManlishPotato
author_rank: Regular Contributor
timestamp: May 01, 2019, 01:54:57 pm
content: Oh! sorry! There are to voltage rails, 5v and 6v (these have a common ground) 5v in the schematic is the same as vcc. 6v is only used once and that's for pin 8 on motor controller, I.E this this for powering the motors.i'll uppdate the schematic

author: Psi
author_rank: Super Contributor
timestamp: May 01, 2019, 01:55:54 pm
content: Yep, add some caps like in my previous post and see if that helps.

author: ManlishPotato
author_rank: Regular Contributor
timestamp: May 01, 2019, 02:09:03 pm
content: hmmm, i think the SN754410 has isolated logic and motor supply and also has a internal clamp diode, but i'll try it though.I tried with 100R instead of 220R resistors on the input pins of the SN754410, and this did make it work continuously, yet it draws about 37mA witch is right at the 40mA absolute limit.I think i'll try what you said + some higher resistors like 200-500R what do you think?

author: Manx
author_rank: Contributor
timestamp: May 01, 2019, 02:59:08 pm
content: Does it hang when you don't connect the motor?How exactly do you supply power for the logic and for the motor? Is arduino supply regulated?

author: ManlishPotato
author_rank: Regular Contributor
timestamp: May 01, 2019, 03:04:21 pm
content: It does not "hang" or float which i think is what your trying to say. The supply is a linear bench power supply.

author: Manx
author_rank: Contributor
timestamp: May 01, 2019, 03:13:22 pm
content: What I meant is that I understood that the atmega crashes after some seconds of operation. I was curious if it crashes without the motor actually connected.I asked about the power supply since I'm wondering if the motor can somehow cause a voltage drop for Atmega. On Uno it has it's own regulator. I'm wondering how do you make 5V and 6V from one supply. Maybe there could a source of voltage drop, if any exists.To add do the list of my questions: Do you have firm ground connection between atmega and SN754410, both are firmly connected to the power supply rails, so the power is not supplied by their I/O pins? These breadboards and jumpers can be very fiddly.

author: ManlishPotato
author_rank: Regular Contributor
timestamp: May 01, 2019, 03:49:50 pm
content: To answer your questions:It does not crash without the motor connected.The voltages are created via the two channels of my lab power supply.Vcc and GND are supplied via each pin like in the schematic, i have tested all the connections and they are solid.With that said i finally made it work with the help of Psi! The solution was smoothing capacitors and 1k resistors pulling the input to gnd.

author: ManlishPotato
author_rank: Regular Contributor
timestamp: May 01, 2019, 03:55:43 pm
content: Yaaaaaas! Finally got it working!Thanks to Manx and especially Psi for helping me!Here is a video of it working:https://drive.google.com/file/d/103jWOH9mpPur37N9i3-5pMfdRGwpzIQK/view?usp=sharing

author: Manx
author_rank: Contributor
timestamp: May 01, 2019, 04:06:01 pm
content: Congrats!