ATMEGA 328P Odd noise problem

Go To Last Post
15 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

First off I'm a total noob of average intelligence so assume you are talking to a five year old.

 

I have an ATMEGA 328p soldered onto a prototyping board (16k oscillator version) along with an rtc module. I also have two pins hooked into a relay. The grounds and power pins are all attached to bars on each end of the board. It is all powered by a 110 to 5vdc module here - (https://www.amazon.com/gp/produc...). Most of the components are sweatshop material Arduino knockoffs. The thing is supposed to run a water pump and heat lamp for a terrarium.  My problem is when I hook up the power rail and ground rail to the power module the code goes off the rails and nothing works right. I can hook a UNO board to the RX and TX pin and in the serial monitor what is supposed to be displayed is just jumbled robot code (not sure what its called). The strange thing is when I disconnect the power module and just pin the power/ground rails to the 5v and gnd pins on the UNO board everything works perfectly. I added two 100nf caps between the 328 gnd and vcc pins on the bottom of the prototype board, not sure if done right but it didn't change anything. If I connect the reset pin to the 328 reset it makes the serial monitor show a little of the code it is supposed to but it is still mixed with the enigmatic robo code. It also won't upload code through the RX and TX pins on the power module power but works flawlessly when powered through the UNO pins. I have some pictures that may help.

 

Thanks for your time.

Attachment(s): 

This topic has a solution.
Last Edited: Sat. Jun 27, 2020 - 09:04 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Add the required 100nf bypass caps as close to the VCC/GND pin pair and the AVCC/GND pin pair, using as short a leads as possible, you do have power on AVCC pin correct?

 

Jim

edit: added short leads

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

Last Edited: Fri. Jun 26, 2020 - 08:42 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Have you measured the output of the power supply, is it 5v?

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Welcome to Freaks.

 

So, I think what you are saying is that your board works correctly when powered from the Uno, and does not work when powered from the 5V power supply.

Is that correct?

 

In addition tot he above:

Are you familiar with the AVR "Fuses", and have you reset them to use the external crystal instead of the internal RC Oscillator within the micro?

Have you un-set the Divide by 8 Fuse on the micro?

 

Does the relay have a reverse biased diode across the coil?

 

Have you drawn a complete schematic of your project, with all of the components and connections shown?

(And can you post it?)

 

JC

 

Edit:

I see now that this is an Arduino project, so perhaps one of the Arduino experts can make a comment regarding the factory new AVR Fuse settings and whether or not the Arduino code will automatically set them correctly or not.

 

JC

Last Edited: Fri. Jun 26, 2020 - 10:32 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 I also have two pins hooked into a relay.

The word relay in the context of micro is synonymous with transients, resets, inductive coupling, current surges, and supply dropouts, blown driver, just to name a few.  The good new is this is often easily solvable (ah, before you lay out a pcb). 

 

Please post a detailed schematic of your module hookups & relay module link.

 

As a quick diagnosis, your supply loos fairly beefy & you can see 3 somewhat beefy robust output caps (to help supply relay surge)...however, the blue supply terminals should go direct to your relay board and be short (length)....don't send that high current surge through your AVR board.

The AVR also goes to the supply, on its own wires, it just sends its little weak control signals to the relay board.   It would be nice to have some beefy caps at the realy board, especially if the wires from power supply to relay board are long (inductive).  Having a small series resistance (say 100 ohm-1k) & small caps on those wires might be a good idea (caps at AVR), but GET the power wires fixed first...that may be all you need.

 

Please don't rest the power supply on your hand, while it is plugged in...(hint...mount in a cigar box, & be safe).

 

 

 

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sat. Jun 27, 2020 - 12:59 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry for taking so long to respond, the COVID is messing up my work schedule. Thanks for all the replies and advice while I have been gone.

 

I drew a basic schematic attached below, I have never made one or used the software so I apologize if I made a mess of it and am happy to add clarity if it is hard to understand.

 

ki0bk - I added the 100nf bypass caps as pictured in the attached photo above picturing the bottom of the proto board, they are directly to the respective pins. Not sure if that should work or not but it didn't for me. My multi-meter reads 5.1 volts from the power supply which is exactly what it reads from the Arduino UNO boards 5v pin, that's what I find odd about it working from the UNO but not the power supply.

 

DocJC  - I am unaware of AVR fuses and haven't set anything different than when I programmed it via USB-to-serial convertor (FTDI chip) on an Arduino board. I'll look into it though.

 

avrcandies  - Not 100% sure what you mean by " the blue supply terminals should go direct to your relay board and be short (length)....don't send that high current surge through your AVR board.". I can be a bit obtuse. The only current going into the AVR board that I know of is the 5v supply. Any time I handle the power supply I make sure it is in a safe spot where nothing on the bottom can conduct, I don't know if the capacitors store enough to shock me or how long they hold charge but I even try to stay away from touching them for a while after disconnecting.

 

Again thanks so much for the help, let me know if the schematic is garbage and I need to learn how to use Eagle or something different. Also excuse any grammatical errors, unfortunately I'm always in a hurry.

 

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

WeenyMinotaur69 wrote:

The only current going into the AVR board that I know of is the 5v supply. ...

 

And where does that current return via?

 

All current flowing in to a component, or along a track, have to return somewhere. As my signature says " #3 All grounds are not created equal". One of the biggest mistakes you can make is assuming that just because your schematic labels it 0V, or GND, that it is at that potential everywhere.

 

All wires, and connections, and breadboards, have a finite resistance. And where you have resistance and current flow you have voltage drop.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not 100% sure what you mean by " the blue supply terminals should go direct to your relay board and be short (length)..

I'm not sure how that is unclear --did you read carefully?  Do you have beefy wires GOING DIRECTLY FROM YOUR POWER SUPPLY TO YOUR RELAY BOARD? Do you also have wires going from your  power supply to your AVR board?

 

Here it is again, with emphasis:

 the blue supply terminals should go direct to your relay board and be short (length)....don't send that high current surge through your AVR board.

The AVR also goes to the supply, on its own wires, it just sends its little weak control signals to the relay board.   It would be nice to have some beefy caps at the realy board, especially if the wires from power supply to relay board are long (inductive).  Having a small series resistance (say 100 ohm-1k) & small caps on those wires might be a good idea (caps at AVR), but GET the power wires fixed first...that may be all you need.

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sat. Jun 27, 2020 - 05:28 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just like in the pictures and diagram the power wires come into the ground bar and the power bar and then go to the AVR and relay respectively. I totally disconnected the relay board to rule the possibility of it being a problem and nothing changed. I can have the board connected to the UNO pinouts (TX, RX and Reset) and have it powered by the converter and the problem persists and the serial monitor displays jumble. If during that time I touch either a ground or 5v from the UNO board to the hot or ground rail on the prototype board the code clears up instantly. I don't have to connect the UNO ground and hot just one or the other and the problem goes away.

 

Ill try caps at the AVR next.

 

Last Edited: Sat. Jun 27, 2020 - 06:55 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 I can hook a UNO board to the RX and TX pin and in the serial monitor what is supposed to be displayed is just jumble

I just noticed you mention the uart, since I was concentrating on the relays--- a common source of surge trouble.

 

Also, I see your "schematic"..where is the uart ???  Note you did not provide a schematic, you've provided more of an assembly view/drawing.   

 

Again, you want to run the relays off their OWN power wires, NO relay coil current should run through wires going to your AVR board.  
This is the safest & best hookup...any surges of coil current inductive voltage drops will be in only the relay wires, and not appear at the AVR.  Of course, in many board designs such a connection is not possible & a lot of headaches are needed to work around it. 

You are very lucky,  since you can easily make the optimal connection, just by hooking up wires.

That is not to say it won't work if you ignore this advice, it's like claiming don't worry, you won't fall while standing on the mountain ledge. 

Many factors:wiring gauge, relay coil current, switching time, wire length, filter caps, AVR noise suppression, local regulator, etc... 

 

AT ALL times do you have a gnd wire connecting your AVR circut & uno serial boardIt will not work without a gnd wire between them. You do not mention gnd here: I can hook a UNO board to the RX and TX pin and in the serial....what about gnd?

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sat. Jun 27, 2020 - 07:37 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮w⸮⸮⸮⸮⸮_w⸮⸮⸮⸮׮׿⸮⸮⸮ͭ⸮⸮⸮⸮⸮⸮u鳻⸮⸮⸮⸮⸮⸮ͥݿ}⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮0 hour(s), 31 minute(s)27 second(s)
0 hour(s), 31 minute(s)28 second(s)
0 hour(s), 31 minute(s)29 second(s)
0 hour(s), 31 minute(s)30 second(s)
⸮߷W⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮w-⸮ݽ⸮⸮⸮u⸮o⸮⸮߯m⸮3g⸮⸮⸮⸮5⸮߯ݥ⸮⸮⸮⸮⸮⸮⸮ݩ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮׽⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮߷}⸮⸮ե⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮ݵןW⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮w⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮ٟ⸮⸮⸮⸮u⸮⸮u⸮⸮6⸮w⸮⸮⸮⸮ߪ⸮{=⸮⸮⸮*⸮⸮w⸮⸮0 hour(s), 31 minute(s)50 second(s)
0 hour(s), 31 minute(s)51 second(s)
0 hour(s), 31 minute(s)52 second(s)
0 hour(s), 31 minute(s)53 second(s)
0 hour(s), 31 minute(s)54 second(s)
0 hour(s), 31 minute(s)55 second(s)
0 hour(s), 31 minute(s)56 second(s)
0 hour(s), 31 minute(s)57 second(s)
0 hour(s), 31 minute(s)58 second(s)
0 hour(s), 31 minute(s)59 second(s)
⸮߿⸮⸮w⸮}⸮⸮⸮խ⸮⸮⸮⸮⸮⸮⸮o⸮⸮ݧ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮o⸮⸮?s⸮⸮⸮⸮⸮w⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮w⸮⸮⸮Wݭ⸮w⸮٩⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮W׿⸮⸮⸮ݵ⸮⸮⸮5׫⸮⸮⸮⸮⸮g⸮m⸮n⸮=ݷ⸮ٹ⸮⸮5⸮⸮⸮⸮⸮o⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮]⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮뫭⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮_⸮⸮Օ⸮⸮⸮⸮⸮⸮⸮⸮⸮u⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮պ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮nv⸮w⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮=⸮⸮⸮⸮⸮⸮⸮⸮⸮]⸮⸮m⸮⸮⸮⸮⸮߻ݵ⸮|⸮⸮⸮⸮⸮⸮6߫⸮⸮⸮⸮}s⸮&⸮⸮⸮⸮_⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮ݿ⸮ɗ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮W⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮ͷ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮{⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮뗯⸮ծWW⸮⸮⸮⸮}⸮⸮⸮⸮⸮⸮⸮5⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮m⸮⸮⸮t⸮⸮⸮׿⸮uwo⸮~}w⸮⸮⸮⸮v⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮ӓmou⸮_⸮t⸮~o⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮o⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮5⸮⸮⸮⸮⸮⸮⸮⸮ݫ⸮⸮⸮⸮ͥ⸮⸮⸮⸮⸮⸮⸮⸮w}⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮}⸮⸮⸮⸮ݽ⸮⸮⸮s⸮⸮߾w⸮⸮⸮⸮⸮}⸮⸮⸮ͥ⸮⸮⸮{⸮⸮⸮⸮⸮⸮]W}O⸮⸮⸮⸮i⸮⸮⸮߯⸮⸮{⸮⸮⸮⸮⸮}⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮?⸮⸮տ~⸮⸮⸮⸮⸮⸮⸮⸮&m⸮⸮⸮ן⸮}⸮⸮

 

This is what the serial monitor looks like, the breaks where the display is clean (hrs, mins, secs) is from me plugging in either a ground or 5v into the breadboard pictured below. I disconnected the AVR VCC, grounds and AVCC from the prototype board and plugged them into a breadboard so I could experiment with caps and getting direct current etc. Ill put a pic below. Nothing works besides just using the UNO as the supply unit, which makes the proto board and power supply pointless. Should I consider a different power source maybe??

 

Just saw your post - I didn't know the gnd had to be going to the uno board for the serial monitor to work, I'll do some tests if that is the case and maybe the AVR will execute commands on its own now. That said even if there is no GND connected to the UNO all I have to do is connect the 5v from the UNO for the serial monitor to start working.

 

Thanks for your help

 

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I didn't know the gnd had to be going to the uno board for the serial monitor to work,

What do you mean?  Do you hook up an led to only one wire and no gnd? Using the led signal by itself would leave one led pin hanging in the air!

 

When you use the TX signal how do you know if it is high or low? If you hook up your multimeter to the TX signal, do you just throw your other meter lead on the floor? 

Same thing when the uno wants to monitor the TX signal without gnd: how would it measure what the voltage level is? 

 

Obviously you cannot use your uno to power the AVR board without a gnd connection...just like you can't provide power from a battery with one terminal connected to nothing..

... Are you running your gnd current through your serial connection wires as some sort of horrific gnd?

 

This is why your first step is to always have a clear schematic & these things will be much more obvious.

 

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Right I just thought since the whole thing was still hooked to the power supply that would ground it. I really have no idea how RX and TX work at all, I have only been messing with arduinos for two weeks so when I put the code in (which I only have a rudimentary understanding of) it's all still magic and pixie dust to me.  As for horrific GND I guess that's what you would call it. Maybe I haven't been clear, my fault. What I was trying to do was power the AVR with the AC/DC step down converter and then connect the RX and TX to the Arduino to hopefully figure out why my code wasn't working. That is when I got the funny readings on the serial monitor. Honestly I am probably just going to stick a new ATMEGA238 into the UNO and just power it with said power source, I am ready to move on to other projects.

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I uploaded a sketch and uncoupled the ARDUINO UNO and the AVR seems to be working fine. avrcandies thanks for the help, I had no idea the ground on the power supply wouldn't be enough for the serial monitor to work via the TX pin. Per usual the only problem was with the 180lb dummy putting the whole thing together.

 

Thanks for the help

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Right I just thought since the whole thing was still hooked to the power supply that would ground it. 

Do you mean the uno also gets its power from the supply too?  Then, yes you have a common gnd.   However, your varying descriptions and lack of a schematic leave too much to the imagination.

 

 EVERY single item in the entire system must share a gnd connection....what do you have---laptop, uno, relay board, avr board, sensor, other stuff? 

 Are you saying all of these things have a wire or path to the same gnd through cabling or connections?

 

edit:

 

OK seem like your lack of gnd was  important!

 

As a tip---

110V outlet power supplies (say a 12V DC supply) have outputs that are either grounded or not (floating) from AC Earth gnd .   

If it is a 2 prong wall plug, outputs are definitely floating from AC (otherwise electrocution hazard)

If it is a 3 prong wall plug, outputs may or may not be floating from the AC Earth gnd (often are connected).

 

If you have 2 of these supplies:

Connect a light bulb to +12V on one supply and gnd to the other supply.

The bulb can only light if both supplies are NOT floating from AC Earth gnd.   The gnd loop is flowing through the house wiring (which is bad, since it can pick up noise & voltage drops)...such a "ground loop" connection should be avoided at all cost.

Avoid it (mostly) by wiring both supplies gnd's together to semi-circumvent the described looping. 

This is not perfect, since a supply AC Earth gnd in one side of the room might "fight it out" with a supply AC Earth gnd in a different part of the room, down the hall,etc where the voltages are a bit different.

And whenever you have current flowing in a wire loop you have formed one coil of a transformer (or loop antenna)---which can be picked up by loops within your circuitry!  Have you ever heard hum pickup in an amplifier/radio?

So tying the supplies together can create it's own gnd loop, which is not good--but you can plug them in the same outlet to greatly alleviate trouble.

This is also why all your equipment (specifically non-floating output equipment) should be plugged into the same workbench--minimize voltage differences!

 

If either supply is floating from AC Earth gnd, the bulb won't light since there is no possible gnd path between the supplies.  That is why you MUST add a wire to tie them together. 

Otherwise, circuits powered by supply A, can't react to circuits supplied by supply B.

The advantage, of course, is that if either supply floats from AC Earth gnd, no fighting can take place, so the tie you add between them is not stressed by the house wiring drops.

 

Now to make things a bit more complicated, supplies never 100% float due to capacitance to all of the AC line prongs...so at higher frequencies there is coupling to gnd, which can affect sensitive circuits.  

Medical grade transformers ($$) are made to minimize such effects....keeps the current flowing through your liver to a minimum.  

  

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sun. Jun 28, 2020 - 01:19 AM