Can a project box cause arduino to freeze?

Hi There

My project is a benchtop carbonation chamber, where i am using an arduino uno, a co2 meter BLG k33 CO2 sensor (UART connections), a 16x2 LCD dislplay (I2C), microSD card reader and 5V relay + 2 24V solenoids to keep a 5% CO2 level constant.

I have been successfully trialling it in prototype form (see image) where I was able to run it without any major problems for 3+ days at an end (at this point i assume any issues would have emerged).

However, because i am in a lab, open wiring isn't really liked so I moved everything inside a project box to tidy it all up. However, over the past two days when i have been running it, the arduino has frozen. Unfortunatley, it does this at the worst possible place in my code, essentially after switching both the solenoid on. This lets the CO2 into the chamber (it is supposed to be 10 or 20 second bursts) essentially filling it up. It shouldn't pressurise as the outlet opens before the inlet, but it does create a much greater CO2 atmosphere than desired + waste of gas.

As the issue never occured before I put it in the box, could it be a side effect of this? One thing, is that the solenoid valves are now much closer to the Arduino, so could they be possibly disrupting it? Another thing that came up when i had a look online was it could be memory related, but if it was this it should have presented before I put it in the box?

Any help would be greatly appreciated. I have just had a double check over my box and cannot see any obvious loose wires. I have also introduced a greater delay into the code between switching on the seperate solenoid, but have not had chance to test this, as I don't want to leave it over the weekend whilst it is having issues...

I've attahced a chopped down version of my code, as well as a schematic and images mentioned in the text. Thanks

Forum_Code.ino (5.11 KB)

Images from Original Post so we don't have to download them. See this Simple Image Guide

...R

It looks like a metal enclosure. Have you ensured that the underside of the PCBs cannot touch the metal?

Is it possible that there is a loose connection that is affected by being squashed into a smaller space?

...R

Thanks - the post about the images is really useful.

Yeah it is a steel project box.
The arduino is in a holder which is then secured with double sided sticky tape. The relay also has 3 bits of sticky tape on its underside to stop the pcbs from touching the box. The screen is in such a way that it shouldn't be touching but i will triple check this

It looked like a couple of the arduino breadboard wires were a bit taught, so i have relocated them on the breadboard so they are closer to the arduino.

This looks like a final enclosure. Why are you still using breadboard?

Convenience mostly (it hold the SD card reader in a useful position).
It is also my first project on an arduino so I am still picking stuff up

My money is on heat - and an overheating regulator.

I see you connect the Arduino through the socket - as there's no other power supply indicated I'm assuming you use 12V to power the Arduino.

This means your regulator has to drop 7V of the 12V to get to 5V.

Then you say your system freezes when the relay is switched on: that's an extra load. You power the relay using the Arduino's 5V output, so through that on-board regulator. That's a bad idea in itself. Even 50 mA for the relay coil means 350 mW of power dissipated in the regulator. Add to that what the rest of the system uses and you're easily at 600-700 mW, roughly the limit for this regulator. Now add a metal box so less air movement, less cooling, and you have an overheating regulator. Touch it when all is running - that regulator will be hot.

Solution: get a 12V to 5V buck converter, use that to power your Arduino and relays (best to keep the power lines to the relay separate from the Arduino).

Hi,
You possibly need to have back-EMF diodes on the two solenoids as show below.
Note the polarity.

Tom.... :slight_smile:

Cheers for the responses, I wasn't sure if the heat build up would be an issue. Just to check, i presume swapping to a 5V dc wall adaptor would have the same effect as stepping down from 12V to 5V. Also, I think you are suggesting splitting the power line so one line goes to the arduino and then the other goes the the jdvcc connection on the relay?

About the back EMF diodes are these a similar principle to a faraday cage?

Thanks for the responses, I'll try them both out and see how i get on..

Rabbel:
Cheers for the responses, I wasn't sure if the heat build up would be an issue. Just to check, i presume swapping to a 5V dc wall adaptor would have the same effect as stepping down from 12V to 5V.

Indeed. Whatever is more convenient - the point is that you do not use the Arduino's regulator (the 5V goes to the 5V/Vcc pin; not the RAW/Vin - actual markings vary between boards).

Also, I think you are suggesting splitting the power line so one line goes to the arduino and then the other goes the the jdvcc connection on the relay?

Yes.

About the back EMF diodes are these a similar principle to a faraday cage?

Also known as fly-back diodes or snubber diodes, those go over the relay coil in opposite direction, and are to be mounted as physically close as possible to the relay coil itself. When the relay coil switches off there's a reverse current spike due to the collapsing magnetic field; the diode shorts that out. Just about any diode will do, currents are not that big anyway for a relay; a Schottky type is best but a regular 1N4148 or even a 1N400x works as well.

adwsystems:
This looks like a final enclosure. Why are you still using breadboard?

I second the suggestion to lose the breadboard. The connections get flaky after awhile.

Plus, add the back-EMF diodes, of course.

As a quick update - I have tried a 5V DC wall power supply but unfortunately this isn't powerful enough to operate the arduino.

I tried splitting the power lines of my 12V power supply, however, this creates too much voltage for the relay ro handle I think. I think a 7V PSU may be the answer to this issue.

In terms of the diode i got some schottky ones but i am slightly confused as to where they go - from the diagram i think it is ground to +24V (from the solenoid - not the 24V from the power supply), is this correct?

One improvement i have successfully made is the inclusion of 2 fans to help with airflow inside the chamber.

Rabbel:
As a quick update - I have tried a 5V DC wall power supply but unfortunately this isn't powerful enough to operate the arduino.

Did you connect this to the 5V pin or the RAW/Vin pin? You have to use the first, bypassing the regulator, as otherwise there may not be enough voltage to run the ATmega processor at 16 MHz.

Ah no, I went through the barrel jack connector - I didn't realise it would need to be a different pin. Thanks for that i will give it a shot tomorrow morning

Then you lose 1.2-1.3V on the regulator, so have some 3.7V left for the Arduino. The barrel jack supply needs at least 6.5V.

Final update

The combination of using 5V directly into the arduino and back emf diodes seems to have worked - the chamber has now run over a weekend without freezing, so i am reasonably confident any issues would have presented by now.

Thanks for all your help!!

Excellent!
And thanks for coming back with the results.