LowPowerLab Forum

Hardware support => Projects => Topic started by: TomWS on February 17, 2015, 05:38:01 PM

Title: reMote for the DC Controller
Post by: TomWS on February 17, 2015, 05:38:01 PM
As promised, here is the DC Remote I developed for the Dust Collection Controller I referenced in https://lowpowerlab.com/forum/index.php/topic,918.0.html.   This Remote monitors the current at each piece of equipment attached to the dust collection system.  If the current exceeds some threshold then the remote signals the DC Controller to turn on a specific blast gate and start the Dust Collector.

As with all of my Motes, the mote, when first deployed, simply knows what network it's on (LANDSCAPE, HOUSE, WORKSHOP, etc).  It does not know any gateway IDs or even have its own ID assigned (it starts with a default 'unassigned' ID).  The first step, then, on power up is to find a gateway.  The mote does this by broadcasting a message announcing that it is seeking a Gateway class device. Nearby gateways see this message and simply reply with their own device Descriptor, which includes, among other things, its deviceClass. The Mote records the gateway id with the highest RSSI and then begins the registration process, which, ultimately leads to the device getting assigned a permanent ID.

Once the DC Remote has a permanent ID, it then uses the same process to look for a DC_Controller Class device, the two connect and then the only thing left is to configure the DC Remote with the number of the blast gate it is attached to...  It's all very simple   8)

There are 5 variants of the DC Remote:
1. This one, shown, is a single duplex, 115V, 20A outlet.
2. A quad outlet version of the same thing (I need one of these at the sanding station to handle all the sanders I have at that station).
3. A single 230V 20A version for the heavy equipment.
4. A dual zone version of #3.  This will cover the table saw and jointer which plug into the same outlet but have two different blast gate branches.
5. A version similar to the dual zone version, but doesn't talk to the DC Controller.  It records current transitions on two different electrical branches in my service panel and reports this information to my home server.  My Well Pump is on one branch and septic pump is on the other.  These are two critical pieces of equipment in the home and I NEED to know if they're working properly (ie, the water sprung a leak and the well pump is going wild or, maybe worse, the septic pump just isn't running at all!)

So, one Mote, does it all.  Photos here, code and eagle files in the next posting...

Tom
Title: Re: reMote for the DC Controller
Post by: TomWS on February 17, 2015, 05:41:29 PM
Here are the eagle files and some code I used to test the Current Sensors.  I've also included a photo of machining the opening for the plug to plug the whole box into a standard outlet.

Enjoy...
Tom
UPDATE: I realized that some people don't have Eagle so I'm including a PDF of the schematic...
Title: Re: reMote for the DC Controller
Post by: Felix on February 17, 2015, 11:59:36 PM
Hats off, nice toys, sticky worthy :)
As a side note - two new versions of SwitchMote are coming. One will support 30A loads 8)
Title: Re: reMote for the DC Controller
Post by: TomWS on February 18, 2015, 09:13:53 AM
I thought it might be useful to those new to analog circuits and Micro A/D converters to provide some comments on the design of the DC Remote.  I've included the PDF of the schematic here for your reference.

The current sensor used in the DC Remote is a very common one, the Allegro ACS712.  You can find a TON of these on breakout boards without too much trouble.   This design uses the chip mounted directly on the PCB but also includes a 3 pin header that just so happens to match the pinout of some of the breakout boards.  This allows me to add a second current sensor to a remote - this is used when the remote needs to support two zones.

The ACS712 is a 5V only part.  The Moteino (with its radio and flash chip) is a 3.3V only part.  There are lots of ways to get these two to safely 'talk' to each other (level shifting with an operational amplifier, relying on the fact that the quiescent output of the ACS712 is 2.5V, mid range on the power supply, and simply clamp the output if it goes above 3.3V, or, as I have done, use a simple resistor divider).  The first two methods would keep the amount of voltage/Amp the same as the ACS712 output (nominally 100mV/A) while the resistor divider will scale this down (approximately 67mV/A).  But, another factor to keep in mind, is that '0' Amps is set to the midpoint of the power supply and measured current swings the voltage above or below this midpoint. 

This is important as all calculations for current, must be based on deviation from this '0' or midpoint value, not an absolute voltage.  If I had used the operational amplifier, then I'd had to precisely set the offset so that the midpoint was known by the micro.  There are techniques to do this, especially if you have the wealth of analog inputs that the Moteino has (you bring your offset voltage into a spare analog input and measure it!), but, for me, given that the Moteino only has 10bits of A/D resolution AND has its AREF pin available on the board makes me less concerned about losing voltage resolution with the divider.

What does the AREF pin have to do with it?  Quite simply, the Moteino A/D converter measures an analog signal proportional to the AREF - ALWAYS.  By default AREF is tied internally to VDD so it's common to think in terms of the voltage being measured with respect to VDD, but, technically that is not the case - the VDD is switched to the AREF and the AREF controls the 'gain' of the ADC.  This is why you need to be careful when you supply a voltage to AREF, if ANY internal source is selected on the ADC, the AREF will try to drive this voltage on its pin.

With AREF literally as the voltage reference to the ADC, then if you sample a voltage on A0, for example, that is equal to AREF, you'll get an ADC value of 1023.  If you read a voltage that is exactly half of AREF, you'll get 511 (+/- 1/2bit) and so on.  So, given this, if I divide the ACS712 output by 2/3 AND supply an AREF signal that is 2/3 of 5V, then the midpoint of the ACS712 will supply EXACTLY the midpoint of the ADC.  Cute huh?

Now, if you look at the schematic, you'll notice two things:
1. the divider isn't exactly 2/3.  It is 2.2/(2.2+4.3) or 2.2/6.5.  So will this introduce an error in the calculations?  No.  Why? Because the AREF is driven by exactly the same ratio.  4.3K is a more common resistor than a 4.4K is (unless I used 2 2.2Ks in series) and, as I've shown, it doesn't matter as long as the two ratios are the same.

2. while the ACS712 output is divided by 2.2K & 4.3K ohm divider, the AREF pin has 220 & 430 ohm resistors.   The ratio is the same, why the different values?  The specs on the two ICs dictate what resistance is proper.  The ACS712 doesn't want a load greater than 4.7K so this is why those values are chosen (total is 6.5K).  The ATMega328P AREF pin, on the other hand, has an input resistance of approximately 35-36K ohms.  This would introduce an error in the ratio of the divider as it would put 35K in parallel with the 4.3K ohm divider.  That's a pretty big error.  I could adjust the value of the resistor so that the equivalent resistance is 4.3K or, as I have done, I simply dropped the resistor values by a factor of ten, which, in turn reduces the error within acceptable quality limits.  Note that this is a lot of current by Moteino standards but is ok in this case BECAUSE the DC Remote is AC powered.  That solution is NOT a good one if the Mote was battery powered.  I have another Mote where I'll show how to deal with this...

So, given this circuit, I get an accurate rendering of the ACS712 output, centered on 512, and covering the full range of current measured by the device.  If you look at the code I provided you'll see how I calculate a noise filtered and 'quasi'RMS current from the input.  The code provided, with the radioCheck() code included in the loop, provides about 8800 samples with a one second sample window.

I hope you've found this useful...

Tom
Title: Re: reMote for the DC Controller
Post by: Felix on February 18, 2015, 09:57:33 AM
Nicely explained, very useful.
I recently read this blog post about using the ACS756 current sensor (http://corgitronics.com/2014/06/30/acs756-current-measurement-tests/) and the results were not quite super accurate. It's hard to believe you can drive 20A (they also have a 30A version) through two pairs of pins of a SOIC8 package, or I'm totally missing something, but that's what appears to be the case according to the datasheet, the entire load goes through the ACS chip for hall analog sensing. That's a bit crazy :)
Title: Re: reMote for the DC Controller
Post by: TomWS on February 18, 2015, 10:18:57 AM
Nicely explained, very useful.
I recently read this blog post about using the ACS756 current sensor (http://corgitronics.com/2014/06/30/acs756-current-measurement-tests/) and the results were not quite super accurate. It's hard to believe you can drive 20A (they also have a 30A version) through two pairs of pins of a SOIC8 package, or I'm totally missing something, but that's what appears to be the case according to the datasheet, the entire load goes through the ACS chip for hall analog sensing. That's a bit crazy :)
You are correct, the entire load does go through the SOIC pins.   If you look at the eagle file you'll see that there is a very heavy duty set of PCB traces from the wire pads to the ACS pins.  I use the 20A variety and my layout is at least as good as the breakout boards  ;)  Time will tell if these are sufficient.  The good news is that I have no equipment yet that draws the max (I usually wire for 230 if I have a choice).  I believe they have a different package on the newer designs, but those go up to 50A!!! 

Thanks for the link, I'll check it out.

Tom
Title: Re: reMote for the DC Controller
Post by: TomWS on February 18, 2015, 10:31:38 AM
Nicely explained, very useful.
I recently read this blog post about using the ACS756 current sensor (http://corgitronics.com/2014/06/30/acs756-current-measurement-tests/) and the results were not quite super accurate. It's hard to believe you can drive 20A (they also have a 30A version) through two pairs of pins of a SOIC8 package, or I'm totally missing something, but that's what appears to be the case according to the datasheet, the entire load goes through the ACS chip for hall analog sensing. That's a bit crazy :)
I looked at the article and see why he was getting such poor readings.  You can not take a single sample and expect that to be representative of an alternating (or even DC) current load.  Loads and lines have noise and AC is, well, AC!  You have to average with lots of samples (to filter noise) using an absolute value function centered on the midpoint.  Even in my case, I really should sync to zero crossing and only take samples for an integral number of cycles, so I'll get some small random error based on when the samples begin.  I won't claim I'm measuring TRUE RMS, I don't need that, but it's in the 'not bad' category and certainly meets AQL...

Tom
Title: Re: reMote for the DC Controller
Post by: Felix on February 18, 2015, 10:44:03 AM
Did your PCBs have standard 1oz copper thickness for the heavy duty 20A loads?
Do you think that is sufficient? Do you have traces only on 1 side of the PCB?
Title: Re: reMote for the DC Controller
Post by: TomWS on February 18, 2015, 12:00:12 PM
Did your PCBs have standard 1oz copper thickness for the heavy duty 20A loads?
Do you think that is sufficient? Do you have traces only on 1 side of the PCB?
Yes, standard 1oz cu, but very wide traces, both sides, and LOTS of vias (not to mention a 12Ga wire soldered on both sides of the wirepad)!  See attached.

Tom
Title: Re: reMote for the DC Controller
Post by: Felix on February 18, 2015, 01:50:08 PM
Nice. Seeing that detail my guess is there is far less "wire" inside the SOIC8 chip.
I made some new SwitchMotes that can carry 30A of current, they will come with 2oz copper, and routed slots between the mains traces :)
Title: Re: reMote for the DC Controller
Post by: TomWS on February 19, 2015, 05:11:46 PM
DC Remote #2 is deployed.  This one is the 'dually'.  It monitors current on two 230V outlets and independently controls two blast gates.  The circuit worked without change (other than adding the second ACS712 via a breakout board), however the breakout board (of dubious source) was much noisier than the on-board ACS712 (30mA vs 8mA after gain scaling).  Fortunately it's on a 2HP circuit so I've got plenty of margin to increase the threshold if need be.

That pretty much shakes out the code, circuit, and comms with the DC Controller so the rest of the units should deploy fairly easily (and silently  ;)

A couple of parting photos are attached.

Tom
PS: Felix, I took your concern to heart and, when I soldered the ACS712 SOIC, I used plenty of solder on the two pairs of current sensing pins, bridging the adjacent pins with globs of solder.  They'll definitely handle 20A now!!!