Relay H-bridge controlled by an atmega 328 p-pu. Circuit does not work properly

Thread Starter

dancol94

Joined Mar 18, 2019
5
Hello. I'm working on a project. I'm using an dual relay module as an H-bridge. I want to control this with an atmega 328 p-pu. So here's my problem. I'm suppose to be able to control a 12V dc motor back/forwarth with this system, but it doesn't work very well. It work perfectly without load, but as soon I connect the motor, everything starts acting wierd.

The motor is supose to run a certain amount of time if I'm not stop it with help of an obstical sensor(Ir). Problem is when I attach the 12 dc motor. It starts but it shout down middle of nowhere. I'm able to start again and it might run for a few secounds, then turn of even though it shouldn't. The microcontroller count every time the button has been pressed. Even that might failure from time to time. (When the motor are attached to the circuit.)

I have done my best. but now I need your help. and excuse me if the grammer in my English ain't pefect. I will post the schematics of the circuit.
Please, tell me if you need more information. Maybe you guys will spot the problem in the schematics instantly. Otherwise I will be happy to tell you more.
 

Attachments

AlbertHall

Joined Jun 4, 2014
8,513
Your circuit seems to be short of decoupling capacitors.
Put 470uF and 100nF across the 12V where it connects to the motor relay.
Put 100uF and 100nF across VCC and GND close to the ATMEGA power pins.
 

Alec_t

Joined Sep 17, 2013
10,446
Welcome to AAC!
It sounds as though the motor is generating electrical interference which is being picked up by the MCU, or else the heavy motor current is affecting the +ve supply or the ground rail of the circuit.
Are you using a snubber across the motor terminals?
Do you have a star ground system?
 

Thread Starter

dancol94

Joined Mar 18, 2019
5
Welcome to AAC!
It sounds as though the motor is generating electrical interference which is being picked up by the MCU, or else the heavy motor current is affecting the +ve supply or the ground rail of the circuit.
Are you using a snubber across the motor terminals?
Do you have a star ground system?
First of all. Thanks! You made some good points that I'm definitely are going to try.
Secondly have I neither a star grounding point nor a snubbler.

I will add a snubbler in to the circuit. But I wonder what kind of capacitor I should use with the snubbler, and do I need a specific value of the cap and resistor? However. since this is a done pcb I can't change the ground system to a star ground system that easly, so I hope I can manage to make this work without it... With other words. I save that solution for later if needed.
 

Thread Starter

dancol94

Joined Mar 18, 2019
5
Your circuit seems to be short of decoupling capacitors.
Put 470uF and 100nF across the 12V where it connects to the motor relay.
Put 100uF and 100nF across VCC and GND close to the ATMEGA power pins.
Ofc thanks you! I'm definitely going to add those cap to smooth it all out. Let you know how it goes.
 

pmd34

Joined Feb 22, 2014
389
Hi Dan, there seems to be something a bit strange with pin 3 & 4 of your reset push button, these pins are connected together in the push button (at least according to the schematic). But this means your reset pin is connected to your crystal capacitors. (which should actually be connected to gnd).
 

Thread Starter

dancol94

Joined Mar 18, 2019
5
Hi Dan, there seems to be something a bit strange with pin 3 & 4 of your reset push button, these pins are connected together in the push button (at least according to the schematic). But this means your reset pin is connected to your crystal capacitors. (which should actually be connected to gnd).
Thanks. I guess I missed that. I will make those changes. However, I don't think that's the reason for the issues in this circuit.
 

Thread Starter

dancol94

Joined Mar 18, 2019
5
Thanks for all the help from all you guys. I have done all the changes to the circuit now and it works perfectly so far :)

I uploaded the new schematic so you are able to see the changes I've made.
I have made these changes since last time: Placed 2 caps between vcc and ground very close to the microchip. One at 100uF and an other at 0,1uF.
I did also put one big elc...cap... at 470uF between output 12V and gnd. and one smaller 0,1uF ceramic cap between the two poles at the motor.
I disconected the path from the reset pin from atmega chip to gnd on the reset btn and attch the crystal caps directly to gnd.
 

Attachments

Top