Current Sensor locking up arduino

Interfacing hardware, sensors, output drivers, chips.
Post Reply
wiki
Posts: 4
Joined: Tue Jan 07, 2014 5:56 pm

Current Sensor locking up arduino

Post by wiki » Tue Jan 07, 2014 6:07 pm

I'm testing the current sensor before I put it into production and noticed something odd. I hooked it onto a portable electric heater and I'm using the AnalogSerialRead example code to see values coming from it. For the most part it works just fine.

Unfortunately, if I power off the heater rapidly (it has several settings, fan only, low heat, med heat, high heat) the arduino will lock up and stop printing data to the serial port. I have to reseat the USB cable to bring it back to life; not even a watchdog would reset it.

The schematic is as simple as can be: Arduino UNO, 5V, gnd and Analog0 going to the sensor. The sensor was placed within 1-2" of the heater. The Analog read example code was used unmodified (except for the pin number).

I've played with the gain pot, but it was more of "turn it one way and see if it helps, nope, go the other way now, nope".

paul
Site Admin
Posts: 706
Joined: Mon May 12, 2008 4:19 pm

Re: Current Sensor locking up arduino

Post by paul » Fri Jan 10, 2014 2:09 pm

wiki,

hmm - definitely haven't seen this before. Some different things do come to mind that are slightly tricky.
Was the desktop or laptop plugged into the same AC line as the heater?
Here is one thing I am thinking - when you switch off the heater this is definitely going to trigger a spike of some kind on the power line. So what you are seeing may be the spike generated from the power line, coming through the other side and resetting the Arduino.

If so you could do a little experiment by unplugging the power adapter for the laptop, if you were using a laptop. If not, you could repeat the experiment with an (unplugged) laptop.

The current sensor itself is purely analog, with no inductors or switching elements so it should not be able to generate pulses that would affect the Arduino in a negative way - meaning that you should just see 0-1024 input on the Serial line.

Try that and let me know. You probably don't have an oscilloscope but I would that would get to the bottom of the mystery pretty quickly.

Please do post your results and I'll try to get to back to you in a timely manner.

wiki
Posts: 4
Joined: Tue Jan 07, 2014 5:56 pm

Re: Current Sensor locking up arduino

Post by wiki » Fri Jan 10, 2014 6:41 pm

Thanks for the suggestion Paul.

Here are the things that I have tried but I'm still able to lock it up.

* laptop (unplugged). Was trying desktop previously.
* used a jeenode with same sketch, in addition to the Uno previously
* Increased delay in the main loop to 1s

I do have access to an oscilloscope, but it may take a few days to get in front of it. I plan on putting this onto my dryer, which is a higher current draw than this little heater, so I suspect similar problems in production.

wiki
Posts: 4
Joined: Tue Jan 07, 2014 5:56 pm

Re: Current Sensor locking up arduino

Post by wiki » Fri Jan 10, 2014 8:34 pm

Here are the things that I've tried, but none of them worked (as in, I'm still able to lock-up the arduino).

* Used an unplugged laptop (was using desktop previously)
* Used a jeenode with same sketch
* increased delay in the AnalogRead example sketch to 1s (up from 10ms).
* tried 5v and 3.3v VCC (on the Uno)
* used different Analog pin (on Uno)

I do have access to an oscilloscope, but it will take a few days to get to it. What do I want to be looking for? Voltage spikes on the input pin?
The final project will be detecting when the washer or dryer are done, which uses considerably more current than this small heater. I'd rather ensure I have the bugs worked out now than in production.

wiki
Posts: 4
Joined: Tue Jan 07, 2014 5:56 pm

Re: Current Sensor locking up arduino

Post by wiki » Tue Jan 14, 2014 9:26 am

My apologies if I've double-posted the last entry.

With some more testing, I'm seeing that the arduino *isn't* locking up and the sketch continues to run, however the serial interface to my laptop is what is locking up. This happens on both the Uno and the Jeenode with an FTDI connector.

I'm going to put the unit into place soon and will monitor.

paul
Site Admin
Posts: 706
Joined: Mon May 12, 2008 4:19 pm

Re: Current Sensor locking up arduino

Post by paul » Mon Jan 20, 2014 6:05 pm

wiki,

I was thinking about this and there really is no model for "locking up Arduino"

Unless you have something like the exit command in your code, or an endless loop - the Arduino chip is going to run the program.
When an Arduino with a bootloader starts after power cycle or reset, it basically has two missions.

1) Check the serial port for a download coming down the line
2) Enter the program loop and run the program (including on running setup() first)

It might be possible for some noise on the bootloader line to maybe lock the processor into the bootloader (and I'm uncertain about whether this is even possible) Other than that, I'm clueless about what "locking up an Arduino" means. One possible scenario might be that the current sensor has some kind of hidden fault that could latch the sensor into a high current mode. Then the sensor drags VCC down to low to let the Arduino run. You can confirm this just with a voltmeter on the Arduino +5V power lines.

Putting a scope on the reset line, and RX & TX (you don't have to do them all at the same time but if you have two channels it would be informative to see what happens at "crash" time.

Michaelchase
Posts: 7
Joined: Tue Sep 19, 2017 4:04 am

Current Sensor locking up arduino

Post by Michaelchase » Thu Oct 12, 2017 3:55 am

The current for half will be 40milli amps and the other 10milli amps. The original ac current was around 160milli amps. The CT had a ratio of 1/5. Successfully attached the image this time. Many thanks.

Post Reply