Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Powering a Mega 2560
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Powering a Mega 2560

by somewhereinusa on Wed Mar 11, 2020 5:38 pm

I have a project that uses 4 DS18B20 temperature sensors. When powered using USB from my desktop it works perfectly. Very rarely one of the temp readings drops to -196.6°F, I can live with that. If I power it any other way. Power jack with 12V in, VIN pin with 11.6 or 7.6 V, Laptop USB both on battery or USB powered by a battery, I get random bad temp readings, -196.6°F, on all sensors. Sometimes many reads in a row. Results on test from data log here.

https://docs.google.com/spreadsheets/d/1cw_n4e79CKj3QIHOALospYrdrdIbT-_el-MODswooGs/edit?usp=sharing

I have also tried using different sketches that ONLY read from the four sensors using both sensor address or by index. Using my phone via bluetooth to see the readings when not using a computer for serial, I get the same results. The ONLY way I get reliable results is powering the Mega with the desk top PC. Second place came from a powered USB hub plugged into the same computer.

If I power using the computer USB it will happily plod along for hours with no dropped readings. Even dropping the read times to 50mills only gets an occasional dropped reading.

somewhereinusa
 
Posts: 61
Joined: Thu Nov 21, 2013 11:42 am

Re: Powering a Mega 2560

by adafruit_support_bill on Wed Mar 11, 2020 8:15 pm

The Mega 2560 is a 5v processor. Powering from USB via your desktop, it will get a reliable 5v. And no further regulation is required.

Powering via the DC jack, the on-board 5v regulator is used. This is a linear regulator which basically 'burns off' the excess voltage as heat. With a 12v power source, it needs to dissipate about 60% of the input power as heat. That is not an issue for the Mega itself. But if you have much circuitry attached to the 5v rail, it may have trouble regulating the voltage.

adafruit_support_bill
 
Posts: 79109
Joined: Sat Feb 07, 2009 10:11 am

Re: Powering a Mega 2560

by somewhereinusa on Wed Mar 11, 2020 11:14 pm

The problem is it has to be stand alone. I've tried putting 5V in at the USB port as well as 5V, and 7.5V to VIN all with same results.

somewhereinusa
 
Posts: 61
Joined: Thu Nov 21, 2013 11:42 am

Re: Powering a Mega 2560

by adafruit_support_bill on Thu Mar 12, 2020 6:03 am

I've tried putting 5V in at the USB port as well as 5V, and 7.5V to VIN all with same results.

5v to the VIN is not going to work - since the regulator needs a couple of volts of headroom for stable regulation. But 7.5 to the VIN should be OK. The USB input assumes regulated 5v and bypasses the on-board regulator.

Looking at the DS18B20 voltages in your spreadsheet, they seem rather low. They should all be much closer to 5v. If you post some photos showing your overall setup, we can take a look and try to spot any problems.

adafruit_support_bill
 
Posts: 79109
Joined: Sat Feb 07, 2009 10:11 am

Re: Powering a Mega 2560

by somewhereinusa on Thu Mar 12, 2020 11:23 am

Thank you for your quick reply. I've included wiring diagram and pictures of overall project. I can supply code but I don't really think it has anything to do with it since problem occurs with even the barest temp reading sketch.

Looking at the DS18B20 voltages in your spreadsheet, they seem rather low. They should all be much closer to 5v. If you post some photos showing your overall setup, we can take a look and try to spot any problems.


I thought that too but, the one that works has the lowest voltage. I have also tried taking the supply voltage to the secondary board off of the Mega and supplying it with 5V thinking the board and relays might be drawing too much current for the Mega. Results are the same. Data sheet shows voltage operating range of 3.3 to 5.5 V. I also don't understand why power in at the USB port of the Mega only works with one power option, the voltage is pretty much the same with all, I don't have any way to measure current on the USB but, I can't imagine they would be that much different. I would think that 7.5 VIN with second board powered from external source would be the best option.

Wiring diagram.

Image

Diagram of secondary board.

Image

Image

Overall project. Temp sensor wires were not coiled for testing.

Image

Image

Image

somewhereinusa
 
Posts: 61
Joined: Thu Nov 21, 2013 11:42 am

Re: Powering a Mega 2560

by adafruit_support_bill on Thu Mar 12, 2020 12:01 pm

How are you measuring that voltage? The issue may not be so much the absolute value of the voltage reading - but how stable the power and/or ground rails are.

The 5v output of the Mega is typically within a few hundredths of 5.0V and you are half a volt or more below that. It is not clear what is pulling it down. But whatever it is may be introducing some noise as well. If you have access to an oscilloscope, I'd probe the power and ground rails to see how steady they are.

adafruit_support_bill
 
Posts: 79109
Joined: Sat Feb 07, 2009 10:11 am

Re: Powering a Mega 2560

by somewhereinusa on Fri Mar 13, 2020 6:03 pm

Did some more testing, bought an oscilloscope, one of the cheap mini digital ones. I really can't see any discernible difference in noise between any of the methods of input. I was taking the voltage measurements from the built in voltage sensing so I could get it in the log. I had forgotten that leg two, the one I used, is consistently .2 V lower than reality. The other two are spot on. Further testing, measuring with a volt meter, shows that voltage at 5V pin on Mega is exactly the same as the 5V bus on the secondary board.

Thinking on this further while I would like to find out why the different inputs have different results. These readings are happening every 5 seconds. It's really not all that critical that things get acted on that fast. Could I add something in to the code to not act on temperature that is -196.6? That is always the error. If I slow it down much more than 10 seconds when I look at the readings on my phone 10 seconds seems like a long time to wait for the data to appear.

I feel stupid now. Just ran a test for a few minutes at 10 seconds with 7.5VIN and got no errors. I'll do an overnight test. I think I've been at this project too long.

I'd still like to know your thoughts on not acting on the -196.6 though.

somewhereinusa
 
Posts: 61
Joined: Thu Nov 21, 2013 11:42 am

Re: Powering a Mega 2560

by kcl1s on Fri Mar 13, 2020 7:26 pm

I am a fellow hobbyist so take this for what it is worth. From the schematic it looks like you are using the regulated 5 volt pin to power the relay coils. Depending on what the coil ratings are I don't think that is a good idea with 4 relays. Wiring the relay coils separately to VIN would be better. But another (possibly bigger) problem is the wiring I circled on your drawing below. It does not look right to me. It looks like you have 5v going to all relay coils through the 340 ohm resistors all the time and your mosfets are not controlling the coils. Am I wrong here? Also you do not have flyback diodes on the coils to prevent voltage spikes.

How you are getting the desktop PC USB to power this is strange. It might make sense if you are going through a powered hub.

forum.jpg
forum.jpg (854.76 KiB) Viewed 74 times


Keith

kcl1s
 
Posts: 1511
Joined: Tue Aug 30, 2016 12:06 pm

Re: Powering a Mega 2560

by somewhereinusa on Fri Mar 13, 2020 11:00 pm

Keith, they aren't mechanical relays, no coils involved. I'm pretty sure the wiring is right. Everything does operate correctly. Just the temp readings are a bit flaky. There will be a flyback diode on relay 1, it's the only one that controls a coil, the large mechanical relay. Thanks for looking, I always welcome input from others.

somewhereinusa
 
Posts: 61
Joined: Thu Nov 21, 2013 11:42 am

Re: Powering a Mega 2560

by kcl1s on Sat Mar 14, 2020 5:58 am

I thought they looked like SSRs but then why the mosfets? I can control an SSR right from an Arduino pin. I believe the trigger current is less than 10 mA. I still don't think the wiring looks right. I would test to see if the SSRs are energized all the time. Also on a high signal from the Arduino pin I believe your mosfets only short 5v to gnd through the 340 ohm resistor.

I have given my 2 cents worth twice, so I will shut up now.

Keith

kcl1s
 
Posts: 1511
Joined: Tue Aug 30, 2016 12:06 pm

Re: Powering a Mega 2560

by adafruit_support_bill on Sat Mar 14, 2020 6:55 am

Could I add something in to the code to not act on temperature that is -196.6?

Yes. That is a pretty common strategy in control systems Especially in industrial controls which often operate in electrically noisy environments. The usual rule is to ignore the occasional spurious readings and continue with the 'last known good' value. Only if there is a extended series of suspect readings would you shut down the process.

Just ran a test for a few minutes at 10 seconds with 7.5VIN and got no errors.

The DS18b20 is an extremely slow sensor. That is generally not a problem since most temperature control processes have enough thermal mass that they don't change that rapidly. I have seen bad readings when polling them too fast. Although I don't know why the power source would have any effect on that.

I can control an SSR right from an Arduino pin. I believe the trigger current is less than 10 mA.

There are some SSRs that are optimized for low-voltage/low-current control. But plenty more out there that are not. Many are designed for 12v or 24v control signals from PLCs.

adafruit_support_bill
 
Posts: 79109
Joined: Sat Feb 07, 2009 10:11 am

Re: Powering a Mega 2560

by somewhereinusa on Sat Mar 14, 2020 7:54 am

Kieth, woke up in the middle of the night thinking about it, I think you are right. Just because it works doesn't mean it's right. It has always looked wrong to me, the resistor is taking the amperage. Mosfets confuse me. I was originally trying to use a Grand Central but, it's only 3.3V not enough to control the SSRs. I put the mosfets in because of the voltage requirements. I switched to a Nano to get the voltage higher, my favorite, but ran out of memory. I left the mosfets in thinking it would be safer for the Mega. The SSRs switch at 3V and draw 10mA. Right now the whole thing is running at about 180 mA.

Any and all help is appreciated. I've been working on this all winter and am getting frustrated. Everything I do is self taught so forgive my mistakes. I've found much good info on line but, as I sure you are aware, there is also much bad or confusing info too. I was a professional auto mechanic, pre computer, and before that Naval air ground support electrician. I've reached out to local high school hoping to maybe find some help there and got no response. The few times I have asked questions on any forum I usually get answers like do you homework or the answer is way over my head.

Anyway thanks for the input.
Dick

somewhereinusa
 
Posts: 61
Joined: Thu Nov 21, 2013 11:42 am

Re: Powering a Mega 2560

by kcl1s on Sat Mar 14, 2020 8:27 am

Mosfets work like a switch breaking the circuit between S and D. I do not believe your circuit does that for the relays. This is a good tutorial on mosfets as a switch https://www.electronics-tutorials.ws/transistor/tran_7.html

Keith

kcl1s
 
Posts: 1511
Joined: Tue Aug 30, 2016 12:06 pm

Re: Powering a Mega 2560

by adafruit_support_bill on Sat Mar 14, 2020 8:39 am

If your SSRs are drawing 10mA on the control inputs, you will be seeing a 3.4v drop across the 340 ohm resistor. That leaves only 1.6v, which is probably not enough to turn on the SSR. The MOSFETs themselves are not a problem. But I'd expect the resistors would interfere with their operation..

adafruit_support_bill
 
Posts: 79109
Joined: Sat Feb 07, 2009 10:11 am

Re: Powering a Mega 2560

by somewhereinusa on Sat Mar 14, 2020 12:08 pm

Does this look better for the switching circuit?


Image

somewhereinusa
 
Posts: 61
Joined: Thu Nov 21, 2013 11:42 am

Please be positive and constructive with your questions and comments.