PAW7 - Mainslog_Sensor

A place to document your own projects.

PAW7 - Mainslog_Sensor

Postby matseng » Mon Jan 21, 2013 11:02 pm

As mentioned in an earlier post I'll try to do one small PCB project every week and then send for PCB's of it every Monday.

Last week I did the PAW6 Game Of Life -board (viewtopic.php?f=56&t=5034) plus an extra PAW X1 breakout/utility board (viewtopic.php?f=56&t=5053) since Seeedstudio gave out vouchers for a free PCB order during the weekend.

This week I'll just finalize and order a board that I started on earlier. It's the sensor board for the mains (wall power) logger that will collect statistics about voltages and exact frequencies over a period of time.

The project will be split up to two pcb's. The first board is this PAW - the sensor board that makes the actual measurements and sends the data to the second board. The second board that I'll do in a later PAW will handle the storing, calculation and display of the received data.

The sensor unit will be built on a SoB DP5050 boards and will be powered by the mains using a transformerless power supply. Since this means that the entire board will have dangerous voltages on it so the data will be sent over an optocoupler so the second board will be isolated and safe from the mains power.

The schematic is rather simple:

To the left is the capacitive-style transformerless powersupply that is able to deliver up to about 30 mA.

D5,R2,R3,R8 is a half wave rectifier and voltage divider to scale down the 230 volt RMS to a voltage that the microcontroller can read with its ADC1 -input.

R4 and R7 is limiting the current into the frequency sense input pin. The internal clamping diodes in the microcontroller can safely clamp 230 volts to 5 volts as long as the current is below 1 mA.

And to the right the optocoupler is connected in series with an indicator led that will flash at each data transmission.

The firmware will measure the peak voltage during 50 or 60 cycles and then transmit the value over the optocoupler to the logging board. Since there are no variable timings or evil operating system that will disturb the timing the second board can use the beginning of each transmission as a 1-PPS (One Pulse Per Second) to accurately measure the mains frequency - the second board must have a very stable reference clock to do this, but that is another problem for another day.
Attachments
Schematic_Mainslog-Sensor.jpg
Last edited by matseng on Tue Jan 22, 2013 3:15 am, edited 1 time in total.
User avatar
matseng
Hero Member
Hero Member
 
Posts: 876
Joined: Sat Oct 15, 2011 12:29 pm
Location: Kuala Lumpur, Malaysia

Re: PAW7 - Mainslog_Sensor

Postby Sjaak » Tue Jan 22, 2013 2:02 am

Make sure every component is on the backside of the pcb if you going to stack them. The distance would be enough to insolate the voltages.
User avatar
Sjaak
Fellow
Fellow
 
Posts: 3027
Joined: Sun Jan 03, 2010 2:45 pm
Location: Hiero

Re: PAW7 - Mainslog_Sensor

Postby matseng » Tue Jan 22, 2013 3:52 am

Interesting idea... If I use a small LCD instead of four rows with six 7-segment displays on the second board I might be able to fit it on another 5x5 pcb... I kinda like it....
User avatar
matseng
Hero Member
Hero Member
 
Posts: 876
Joined: Sat Oct 15, 2011 12:29 pm
Location: Kuala Lumpur, Malaysia

Re: PAW7 - Mainslog_Sensor

Postby presslab » Sun Jan 27, 2013 7:51 pm

I always like to see these transformer-less offline supplies. It's like cheating, but in a good way.
presslab
Newbie
Newbie
 
Posts: 37
Joined: Sun Dec 16, 2012 7:33 pm
Location: British Columbia

Re: PAW7 - Mainslog_Sensor

Postby matseng » Mon Jan 28, 2013 1:25 am

Gebers sent to Seeedstudio.

I ended up with a resistive transformerless powersupply and some extra protection diodes and resistors as well after discussions with sleepwalker3 who had a lot of good input and design tips.

The sesor board is routed on a DP8049 with wide margins at the sides and also decent isolation distances internally. I plan to mount this in a SoB DP100100 case.

Schematic_Loggrid-Sensor2.png


Top_Loggrid-Sensor2.png
The component values are not correct! Don't use 270 ohm resistors in the PSU, 27K is more reasonable there.
User avatar
matseng
Hero Member
Hero Member
 
Posts: 876
Joined: Sat Oct 15, 2011 12:29 pm
Location: Kuala Lumpur, Malaysia

Re: PAW7 - Mainslog_Sensor

Postby Sleepwalker3 » Mon Jan 28, 2013 6:36 am

A couple more points Mats

1. The dotted line doesn't correctly indicate the isolated area. ALL of the circuit must be considered to be at Mains potential, all of it, except for the opposite side of the Opto.

2. The 'GND' points should be changed to a different name, as they are not Ground points. Some people may argue that the Neutral is tied to Earth back at the switchboard, but this isn't always true and in any case it is not uncommon to find that the Active and Neutral wires have been transposed (I even found this is some places in my home and with some old double-adaptors), so what is marked as GND may actually be the 'Live' Active wire (via a diode).

3. It is ABSOLUTELY MANDATORY that nobody *EVER* connects up their programmer to this unit whilst it's plugged into the mains. If the A & N are transposed, it would destroy their programmer and likely parts of their computer too, possibly cause a fire, but worse still, could electrocute them. You need to include some sort of big warning thing about this or make the programming port isolated also.

As you know, I'm not at all a fan of the transformerless supply, but in any of this gear, the whole thing must be considered live, as it very likely could be, so the dotted line should be moved over to the right of the PCB to the Opto.

Not trying to be a Negative Nancy, just that I've seen some really dangerous (no DP pun intended) crap in my time and on a few occasions have been on the receiving end of somebody else stupidity.
User avatar
Sleepwalker3
Hero Member
Hero Member
 
Posts: 539
Joined: Mon Jan 16, 2012 4:12 am
Location: Down Under

Re: PAW7 - Mainslog_Sensor

Postby presslab » Mon Jan 28, 2013 10:59 am

Haha, yes, now this is a Dangerous Prototype!

Using the capacitive reactance to drop voltage is a cool thing, although a bit harder to design for. What's the thought behind removing the capacitor in the supply? Here's an interesting app note on the design of each type of transformer-less supply:
http://ww1.microchip.com/downloads/en/appnotes/00954A.pdf

Without any isolation, debugging these circuits is more Dangerous. I'd recommend that anyone working on mains referenced circuits use an isolation transformer on the power input. And get a good one! Last week we had one go up in smoke in our building, with nothing plugged into the output. The fire engines came and everything, quite a circus. I agree with Sleepwalker3, a healthy fear of the mains is a good thing.

With the full-wave rectification the "GND" will be at -5.8V peak (to earth/neutral) if the neutral is properly connected.
presslab
Newbie
Newbie
 
Posts: 37
Joined: Sun Dec 16, 2012 7:33 pm
Location: British Columbia

Re: PAW7 - Mainslog_Sensor

Postby Sleepwalker3 » Tue Jan 29, 2013 12:27 am

Mats and I did discuss the Cap side of things, I'm not against the cap, but as you say, it's harder to design for and there are things that many don't realise about using that setup. I was very critical of another Microchip application note (about using small micro's direct with a transformerless setup) featured some time back on DP, where the Engineer clearly didn't have experience in 'real life' applications. This one I haven't looked at in any great detail.

Yes a good quality Isolation transformer is highly recommended for the bench work, but most hobbyists wouldn't have one, indeed most professionals I know don't have one. I wouldn't be without one with the stuff I deal with, but you still have to play it safe, they don't automatically exclude any risk of getting a hefty belt.

One big problem with these sort of things is that so many hobbyists (and for that matter some 'pros') will get it into their head that the micro is only running 5V and so it's fine. When the local electronics mag has done things like this, they've almost always had letter from people saying something like that and have had to go through and explain that they whole thing must be treated as if it's live - as it may well be!
User avatar
Sleepwalker3
Hero Member
Hero Member
 
Posts: 539
Joined: Mon Jan 16, 2012 4:12 am
Location: Down Under

Re: PAW7 - Mainslog_Sensor

Postby matseng » Tue Jan 29, 2013 1:04 am

The dotted line will as you say a false impression of a secure (isolated) and a non-secure part of the board. I'll make sure to remove that for the next revision. As it is today is only shows where there's a low respective a high voltage potential between adjacent parts/tracks on the board. The entire board should be considered lethal.

Regarding going from capacitive to resistive current limiter it will be safer to put any random type of 27K resistors in the limiter compared to put any type of 0.22 uF capacitor. Unless you have a properly rated X2-typed capacitor there the capacitive version is a very bad idea. And then there's the problem with initial inrush currents and things like that.

The resistive version will emit a lot of more heat, but it's not an unreasonable amount so I think it might be fine anyways.

The GND markings... Well, it's true that they are not "Earth Ground", but rather a local "ground-volage" relative the to vcc there. Maybe 0 (zero) would be a better name for it?

I debugged the firmware of my prototype without an 230-230 isolation transformer, I used a 28 volt AC transformer from a broken pc 5+1 sound system. I just paralelled the dropping resistors with resistances calculated for that voltage.

But I also used my Digilent Analog Discovery unit in scope mode when I had the board connected to live mains. But then the DAD was connected to a laptop running on batteries and a wireless mouse and I did the "Keep one hand in the pocket"-trick that I learned from my granddad when I was like 10 years old.

With one hand on the pocket you're quite safe for mains power unless you're standing barefoot in a puddle of water.

And yes, a big warning notice on the icsp port might be a very good idea.
User avatar
matseng
Hero Member
Hero Member
 
Posts: 876
Joined: Sat Oct 15, 2011 12:29 pm
Location: Kuala Lumpur, Malaysia

Re: PAW7 - Mainslog_Sensor

Postby Sleepwalker3 » Tue Jan 29, 2013 10:24 am

Yeah you can't really call it Neutral, as it's not. 0V is an industry standard, but as this could (and probably will) be built by hobbyists, it's a bit grey. Perhaps call it Vss? Probably worth putting a warning logo similar to DP's logo and state something to the effect that the whole board is considered 'Live'.

Yes, as you say, really you could use pretty much any properly isolated transformer for testing, so long as you adjusted your resistors accordingly. I was going to make a brown-out detector to turn off the fridges and prevent burn-out of the motor, as especially around summer we would get a brownout probably once a month and the voltage will fluctuate up and down from around 40V to 150V or so - you'll literally see incandescent bulbs going up and down in brightness like one of those old B grade movies in the mad scientist's lab! lol. It also really stuffs some types of SMPS units, cooked the old VCR a few times. I was just going to drop it down to say 12V and then sample it accordingly, similar to your test, as the permanent way of sampling. It will be divided down whatever the case, so if it's 240V or 24V makes no real difference.

Something that could possibly be added is a neon (with resistor) between Neutral and the Earth pin. The typical resistor used is very high (I think about 270k from memory) and so shouldn't cause any problems with Earth Leakage, but would warn of a wrongly connected (transposed) Active and Neutral.


In doing this project, have you thought about your maximum mains voltage? For instance, when you've set the divider, will you allow for the mains perhaps being a fair bit above the max? The 'official' voltage for Australia is now 230V thanks to our brilliant politicians who thought it would be a great idea to match up our voltage standard to that of Europe, despite the industry screaming loudly. Most places are still on 240V and will be for many years to come until the transformers are changed (which is basically as they fail), so a new area might have 230V, an old area might have 240V and a country area can often get 250V or more depending on the circumstances. My place has been known to be over 250V on the Fluke, typically is about 240-245V.
I got some official tolerances from some helpful linesman, but it varies between states around here. So you probably want to consider allowing a 10% or 15% over nominal as 'headroom'.


Anyway, don't want to tell you how to suck eggs!
User avatar
Sleepwalker3
Hero Member
Hero Member
 
Posts: 539
Joined: Mon Jan 16, 2012 4:12 am
Location: Down Under

Re: PAW7 - Mainslog_Sensor

Postby matseng » Tue Jan 29, 2013 11:08 am

Hmmm... I wonder how many junior hobbyist-level people out there that knows what vcc, vee, vdd and vss stands for and what is positive and negative of them. Most probably knows that vcc is positive, but I think that's about it.

Maybe just v- and v+ on the iscp, that is reasonably non-ambiguous.

I was thinking of a neon light to warn for swapped live/neutral, but that would make a high voltage with a current up to about 1mA on the earth-guard ring if the ground is not connected at all. Not lethal, and it won't trip a standard GFI at 5mA, but certainly very nasty.

I'll probably divide the mains down enough to get 0.5 volt resolution with the 10 bit ADC. This would allow up to 512 volts vpp = far more than enough. Trying to squeeze out maximum resolution seems a bit silly and would give very strange step values that would need to be rounded sooner or later anyways.
User avatar
matseng
Hero Member
Hero Member
 
Posts: 876
Joined: Sat Oct 15, 2011 12:29 pm
Location: Kuala Lumpur, Malaysia

Re: PAW7 - Mainslog_Sensor

Postby matseng » Tue Jan 29, 2013 11:52 am

Have a look at this.... viewtopic.php?f=2&t=5101 - Now that is scary....
User avatar
matseng
Hero Member
Hero Member
 
Posts: 876
Joined: Sat Oct 15, 2011 12:29 pm
Location: Kuala Lumpur, Malaysia

Re: PAW7 - Mainslog_Sensor

Postby presslab » Tue Jan 29, 2013 12:23 pm

matseng wrote:The GND markings... Well, it's true that they are not "Earth Ground", but rather a local "ground-volage" relative the to vcc there. Maybe 0 (zero) would be a better name for it?


I guess I have no problem calling your "GND", "GND." It's not as if you're calling it "Earth." There are many types of ground used in everyday schematics. Earth ground, Signal ground, Power ground, etc. Even a handheld device uses "GND" in the schematic.

At my work we have many designs that use rectified 480 VAC mains power with no isolation. The reference net is called "Power ground." I understand trying to idiot-proof something, but when sacrificing clarity it seems counter-productive. I'm also heavily against "learned helplessness" in our ever increasing nanny society.
presslab
Newbie
Newbie
 
Posts: 37
Joined: Sun Dec 16, 2012 7:33 pm
Location: British Columbia

Re: PAW7 - Mainslog_Sensor

Postby presslab » Tue Jan 29, 2013 12:38 pm

matseng wrote:With one hand on the pocket you're quite safe for mains power unless you're standing barefoot in a puddle of water.

Yes the one hand in the pocket works, but then you only have one hand to use! It's all too easy to touch a piece of grounded equipment with one hand and your "hot" equipment with the other. Umm, yeah I've done that, electricity right through the heart! The lab tech at work likes to float all kinds of things with cheater plugs. I'm always pulling those things off. Very dangerous, please don't do that anyone...

An isolation transformer can be made with two regular transformers wired back to back, like so:
Image
presslab
Newbie
Newbie
 
Posts: 37
Joined: Sun Dec 16, 2012 7:33 pm
Location: British Columbia

Re: PAW7 - Mainslog_Sensor

Postby Sleepwalker3 » Wed Jan 30, 2013 3:44 am

@Presslab - I understand what you're saying, but I really strongly disagree with calling anything GND when it's not. Power Ground, Signal Ground etc. are all still at Ground potential, they are only separated because of ground current interference which is obviously a very very low potential, certainly nothing like something that could give you a tingle, let alone a belt. Ground is Earth or a large ground mass where things are relative to it (say in a satellite) and that's the way it should be. I'd be very critical of any gear calling something GND when it's not, that to me is really poor - Reminds me of some things I've found like an Active wire where some twit wired it with a Green/Yellow Earth wire! All the Industrial equipment I deal with calls 0V just that, it's not called Ground unless it is actually connected to an Earth at some point. About the only time that I would consider that would be acceptable would be in reference to a 'Ground Plane' and related relative points in a mobile RF application or something along those sorts of lines.

What concerns me is so many of the things I've read where people have no idea and could quite easily kill themselves under circumstances which are not at all far-fetched. Yes we shouldn't have to protect idiots from themselves, but if you're publishing a project, then I think it's only morally correct to point out the hazards (if not legally obligated to some extent) at least to try to make the dangers as clear as possible to those that may build it with insufficient knowledge - we all were beginners at some point remember. I would bet most hobbyists that had built a few Mains projects wouldn't think (or even know) to check that their Active and Neutral were correctly connected and may well just plug their programmer on thinking all was fine. Even with the A&N correct, there will still enough oomph every half cycle to damage their programmer and perhaps their parallel port, USB or whatever they are using.

That type of Isolation transformer using two transformers back to back can work in a pinch, but it's not really a good idea for anything used regularly for general purpose (tech) use. The Primary of the transformer will be relatively light gauge wire in most hobbyist cases, adequate for the job they were designed for. The primary in a common 240V-12V transformer of say 1-2 Amps Secondary current, would typically only be draining maybe 100mA plus losses. They may (just for arguments sake) use wire that can safely handle say 500mA, but it would be relatively rare for transformers (that hobbyists are likely to have) to have hefty primary windings. Sure it's OK for this PAW7 circuit and light duty stuff, but totally unsuitable for anything where you will be hauling a couple of amps or more. Many people wouldn't be aware of this.

Not trying to dispute what you're saying, just wanting to point out that plenty of people who visit DP wouldn't have a professional background and wouldn't understand a lot of the potential hazards and if those that do understand are going to produce something, they should make it really clear about any likely dangers - Stupid or not, you'd hate to here of somebody getting killed.


@Mats, yes V- is probably the lesser of the evils, I can't really think of anything better. We don't have the Guard-ring here, so I hadn't thought of that, actually seems pretty dangerous having that ring from that viewpoint if it's easily contacted. Yes it would be about 1mA Peak, which is enough to stop the heart when conducted across from arm to arm. Maybe that's a PAW8 candidate - a 3 light Mains tester! lol. I have a commercial unit like that, it indicated various faulty connections by 3 lights (I think Neons from memory) and works well, has come in quite handy at times.
User avatar
Sleepwalker3
Hero Member
Hero Member
 
Posts: 539
Joined: Mon Jan 16, 2012 4:12 am
Location: Down Under

Next

Return to Project logs