Show Posts
Pages: 1 ... 43 44 [45] 46 47 ... 50
661  Using Arduino / Sensors / Re: AC Line Safety on: January 16, 2012, 02:52:55 pm
Hi and thanks AJOfScott!

I have yet to build a linear opto-isolation circuit. For me, they've always been either the on or the off type, usually with an AC input stage to make them universally applicable. I always thought that linear opto-isolation circuits require a lot more components to keep things linear... so that circuit of yours certainly looks interesting... I have no ability to model optos right now as neither circuit modeling package I have here can handle them outright... some vendors of linear optos like AVAGO go as far as including a SPICE model in their documentation.

As for Eagle, I chose that package since it's the most intuitive one I could find that ran on Windows as well as Mac computers. The large parts libraries available on the 'net are nice too, though all vendors could do a better job of documenting their wares. I frequently find myself coming up with parts libraries for my projects because the chips are not defined elsewhere. My biggest gripe with Eagle isn't though with the clunky UI or the somewhat arbitrary process flows (to define a new part, for example). It's the auto-router, which I find pretty useless.

However, thanks to the free-routing project, I have access to an amazing auto-router that is great for initial layout optimization, even if I later lay out a board on my own. I wish Cadsoft could buy a license from those researchers, as that autorouter makes the one in Eagle look pathetic, even if there are some quirks that have yet to be worked out (i.e. orphaned polygons, etc.).
662  Using Arduino / Sensors / Re: AC Line Safety on: January 15, 2012, 09:14:45 am
A couple more comments:

Using protection diodes as shown here takes some fairly careful calibration. I looked up some schottkys that had a similar form factor as the BAV99 (SOT-23) Their 1A voltage drop is about 0.45V @ 25*C but forward voltage is a function of current and temperature, as their datasheet shows on page 2.

I re-ran the circuit analysis tool and I wonder if those here who have way more experience than me can weigh in... Attached below is a 'scope' output and the circuit, which I am overdriving 100%, i.e. 230VACrms input on the primary side resulting in a 13VACpp signal on the secondary side. The green and blue 'scope' lines are for the protection diode, the red line shows the ADC voltage.



Extrapolating the chart in the datasheet that Diodes Inc published, I would expect about a 0.1V voltage drop at 0.1mA. The 'scope' appears to confirm this, as the peak forward current is around 120uA, while the 'shaven' portion of the voltage is about 0.15V, which looks consistent. However, if I disable the diodes by increasing their forward voltage to 1000V, the Vpp across the ADC is 4.77V. That suggests to me that each diode is actually shaving off more than a volt. So isn't this inconsistent? At a forward voltage of 1V, the SOT23 should be blowing up (i.e. 4+Amps). Granted, this is not a steady-state condition but still...
663  Using Arduino / Sensors / Re: AC Line Safety on: January 14, 2012, 06:44:09 pm
Thanks DC42!

I decided to try out a couple of configurations based on your suggestions that I hope I interpreted correctly.

I have enclosed two screenshots that I hope are interesting / useful... It occurred to me that the protection diodes would have a hard time protecting as long as their forward voltage potential wasn't adjusted. So, I created yet another voltage divider that may be just gilding the lily for all I know. I am assuming Schottky's here, 0.222Vdrop at 1A. iCircuit is extremely limited re: inputs in the interest of simplicity. I hope that it accounts for the different forward voltage drops in diodes as a function of current but I'm not super confident it does!

The first screenshot shows conditions under nominal 115VACrms conditions. I.e. the secondary voltage amplitude of the transformer is 6.5V (4.6VACrms*1.41), offset for fun by 2VDC. The yellow line on the 'scope' shows the voltage drop across the 1M resistor that stands in for the ADC while the blue line is a idealized VAC supply with an amplitude of 1.25 and a DC offset of 1.25V.


At 115VACrms the inputs into the ADC look pretty good. The curves are nicely formed, I see no distortion. Now, lets try a 230VACrms input. Note how the diodes are getting a workout and how the tips of the ADC violtage curves are getting compressed. There are no excursions above 2.5VDC or below 0VDC (so the ADC is safe). Then there is 150V MOV... Not sure if it's strong enough to blow a 1A slow-blow fuse before it goes boom, however.


That aside, the above looks promising. But I don't trust this program enough to accept the above as gospel. Any SPICE programs out there with a good GUI as long as it's either Mac or Windows? I'd like to think that WinSPICE would allow you to adjust component behavior with a bit more granularity.
664  Using Arduino / Sensors / Re: AC Line Safety on: January 14, 2012, 11:28:11 am
Hi and thanks DC42!

It's the weirdest thing, my iPhone is showing me a longer reply from you earlier, but the web site does not. Anyhow, you brought up some very good points about startup conditions and whether the BAV99's can actually do anything to protect the Atmega input pins.

One solution I thought of (but cannot implement yet thanks to the iCircuit program being on strike again) is using a small triac or SSR in series with the coupling capacitor separating the transformer output from the Arduino. Tie the gate to the 2.5VDC power supply via a 10k and the thing should only conduct whenever there is AREF power. Alternatively (and perhaps smarter) tie the gate to a digital pin so that the analog input into the atmega can be interrupted at will - i.e. detect a high voltage condition and turn the thing off... The question is whether a triac or SSR would have an impact on the signal.

I tried out the circuit with components that have a 10x higher resistance and naturally that works also. Based on the new reply from you (that popped up while I was writing this) I will retain the 100uF capacitor.

Interestingly, iCircuit reports a signal across a NO standard relay being possible even if the coil is not energized. Makes me reconsider some of the other outputs as well! Perhaps time to return the product in favor of the other circuit analysis tool on offer in the App store.
665  Using Arduino / Sensors / Re: AC Line Safety on: January 14, 2012, 10:03:44 am
Hi Grumpy_Mike,

I tried out a couple of tools yesterday, including MacSpice. I downloaded iCircuit from the App store and I am somewhat underwhelmed by it. Don't get me wrong, it has a nice GUI, a number of elements that can be added easily (everything from simple circuit components up to ADCs) but there are several improvement opportunities. For example, only one scope window can be opened. OK if the signal amplitude is similar, not so great if you're trying to monitor two very different signals at the same time (i.e. current on one probe vs. volts on another). Worse, the current version on my CPU will allow me to save designs but not to re-open them later. Kinda defeats the purpose of the save function, no?

Anyhow, I thought I'd include another screenshot. This one includes the transformer though I have to admit that I did not include the internal resistances of the transformer because they were not listed by the manufacturer on the datasheet. So the current flowing through the primary is somewhat fantastical. That aside, I thought it was very interesting that there was only a very small marginal difference between using a 10uF coupling cap vs. using a 100uF coupling cap in terms of transferred signal. The DC was still kept out - note the 100VDC offset I put into the power supply. I also got similar results when I omitted the transformer and used a AC signal source directly on the resistors that would have been attached to the secondary side of the transformer.

A 10uF capacitor is a lot cheaper and smaller than a 100uF capacitor but I worry that this sort of analysis may be oversimplifying what is really going on. The 100MOhm resistor all the way to the right is to represent the ADC, which is where I am getting this 'scope' image from. The input has a max amplitude of 177VACrms with a 100VDC offset, which transfers nicely. The secondary shows a 20Vpp with a 4VDC positive offset. Seems to make sense given the inputs. I have placed a 150V MOV ahead of the transformer on my PCB. So I'd like to think that the circuit wouldn't ever come close to a continuous 170+VACrms input.

Do you think I should stick to the 100uF ceramic capacitor or breadboard the circuit above on a existing Mini that has already lost one ADC channel due to earlier mishaps with voltage dividers?
666  Using Arduino / Sensors / Re: AC Line Safety on: January 13, 2012, 09:42:30 pm
Ok, so I decided to have some fun with some circuit analysis programs. I modeled the old circuit with it's 6VACrms power supply and the 1.25VDC bias circuit. As born out in real life, the circuit works.

As pointed out by ajofscott, a strong dc bias on the AC side leads to a offset that could lead to a negative input into the ADC as you can see below.

I played around with the capacitive coupling circuit and worked the resistors until I got a good signal on the output. Note the much low resistor values. However, the analysis appears to suggest that they work... Even with a large DC offset, only the AC signal is transferred. Seems like this one might be a winner.

667  Using Arduino / Sensors / Re: AC Line Safety on: January 13, 2012, 12:15:28 pm
Ah, but for just $1.65, a 100uF, 10V ceramic capacitor can be yours in single quantities. Tantalum caps in this range seem less expensive, ditto for Aluminum Electrolytic but how to verify that the cap can handle the reverse bias? That is, how to orient the thing and to determine that the thing is going to be safe and not explode the way tantalum and aluminum electrolytic capacitors are wont to?

I can order a bi-polar Aluminum electrolytic capacitor from Digikey for less than a dollar but they're only offered as through-hole components. On the Tantalum and Niobium side of things I found the following statement from AVX in this document:
Quote
In the reverse mode, tantalum and niobium oxide dielectrics are modeled by a diode DR and resistor RD integrated in the
equivalent circuit diagram. The diode DR has a bend at approximately 10%  of the capacitor’s rated voltage to describe the real change of capacitor’s VA curve

There is a chart there also showing the reverse current as a function of voltage for an unspecified chip. I wonder whether one should select the capacitor voltage rating on the basis of the above to survive the reverse bias, i.e. a 25V-rated chip or whether one should select a rated voltage that allows the same amount of reverse flow as it did forwards. For example, using a 10V-rated chip for the 1.25VAC signal that I'm trying to pass here...

Anyhow, an updated diagram is below, the parameters haven't changed, but the values of the capacitors and resistors have based on prior feedback. Additionally, I threw in a MOV to help with permanent excursions above 120VAC. AREF = 2.5VDC, supplied by a linear regulator. The secondary winding voltage is 4.6VACrms. Volts = Analog input pin on Arduino dedicated to Voltage measurements.



Thanks for the help and I appreciate any additional observations, pointers, etc. Cheers!
668  Using Arduino / Sensors / Re: AC Line Safety on: January 13, 2012, 10:28:28 am
The 27nF capacitor is way too small, its impedance at 60Hz is around 100K ohms. If you want to stick with that circuit, I suggest you increase the two 1K resistors to 22K each and increase the capacitor to 100uF (impedance about 60 ohms @ 60Hz). Alternatively, I think your previous circuit was OK, because the capacitor from pin 5 of the transformer to ground means that one end of the transformer secondary is virtually grounded anyway.
Both of you, thanks for the suggestions and formulas. The previously posted circuit topology has worked for me in the past - I just got my resistor value ratios wrong in my haste to post here.

What is interesting in the light of Grumpy_Mikes earlier comments is that the previous voltage divider on the secondary side was fed by a nominal 6VACrms wall wart, whose unloaded output was closer to 7.2VACrms. The resistors I used on the secondaries were 100 Ohm (whose output fed into the Arduino) and 2.2k for most of the voltage drop. Even though the combined resistance of the two resistors on the secondary of the transformer were very close to the total resistance of the bias circuit, the circuit works... Curious.

I thought I'd explore the capacitive-coupled circuit topology because it's allegedly better at protecting the Atmel. That I got my Xc reactance wrong is just typical of me, it's been a while since I took my last EE course. Thing is, when I plug in the above formulas, I get a reactance of 26 not 60 Ohms as expected with a 100uF cap @ 60Hz. I must be missing something because the ESR of the types of caps I usually consider only add another Ohm or two per their spec sheet...

As far as capacitor types go, are there preferences one should follow? I was thinking of going with a 100uF 10V ceramic cap as there are no issues with reverse bias then and the cost is only a dollar more vs. some of the polarized capacitor choices. People apparently use Aluminum electrolytic capacitors in this type of circuit, what I wonder is what the reverse bias would do to it over time. I wager you'd have to be more knowledgable about the topic than I presently am...

Anyhow, which circuit to go with is a good question at the end of the day is a good question. With the right voltage divider on the secondary and so on, the first circuit is appealing because of its proven performance in past board iterations. The capacitive-coupled circuit certainly also has appeal thanks to the grounded output and costs only marginally more to implement. Thanks again for the insights...
669  Using Arduino / Sensors / Re: AC Line Safety on: January 13, 2012, 12:40:54 am
Prudence would say to ground one side of the secondary, apply the voltage dividers for line scaling then capacitively couple the ac to the arduino input biased at 1/2 IOReference. This keeps any winding leakage that may or may not be present from being applied to the cmos inputs of the arduino.
Hi there and thanks for your thoughtful replies! Based on your feedback and that of Mike's, here is a updated circuit drawing that attempts to meld the two sets of suggestions, i.e. higher resistance values for the signal voltage divider, a de-coupling capacitor in the middle, etc. I think I have it right, but would appreciate further feedback.

The inputs are the same, i.e. nominal 115VACrms input with a nominal 4.6VACrms output. One of the secondary legs has been grounded, the voltage divider circuit across the secondary windings now features higher-resistance resistors as well as a decoupling capacitor. Based on a suggested cutoff frequency of 6 Hz I found elsewhere, I calculated C to be ideally around 0.035uF. Based on the availability of a 0.027uF film cap chip, I selected that value instead. I have omitted the BAV99, the 22 Ohm, and the 100 pF transient protection from the drawing above to keep things simple. The voltage coming into the DC-bias circuit is 2.5VDC as before, which is also the externally-applied AREF voltage (linear regulator).

DC42, you are correct, the AC signal has to vary from a maximum condition of -Vbias/2 to +Vbias/2 for this circuit to function. There is a tradeoff to make between measureable range and voltage protection - how much range to trade for headroom vs. accuracy of measurements at nominal conditions. So the secondary voltage divider resistors are still closer in value than those used by the open energy monitor project (about 5:1 vs. 10:1 ratio, respectively). My reasoning is that I want the Arduino to capture the nominal AC signal as best as it can, there is a allowance for 25% over-voltage, there is the BAV99, the series resistor, the 100pF cap, and then there is whatever is inside the Atmel.

Thanks everyone, I really appreciate all the help. You guys are the best.
670  Using Arduino / Sensors / Re: AC Line Safety on: January 12, 2012, 05:59:19 pm
OK, let me go back to past documentation and come back again later when I have more information. It's entirely possible that I got the drawing wrong.

FWIW, I based my implementation on the prior work done by the open energy monitor project. Their description of the AC-voltage detection circuit can be found here. The circuit there seems similar to the one I have posted above (minus the BAV99, 22Ohm Resistor, and the 100pF capacitor), which is what is baffling me. If you have a moment to review the above, I'd be much obliged. And even if you don't, many thanks again for your help, Mike, I really appreciate it.
671  Using Arduino / Sensors / Re: AC Line Safety on: January 12, 2012, 05:31:22 pm
OK, I thought I was missing something. In the past, I used a wall-wart AC-AC transformer for the AC input signal. Here is a analogous circuit with an on-board transformer from Pulse Engineering. The specific model is designed to bring 230VAC down to 6VAC, so in use with the 115VAC input the output should be 3VAC.



Pulse Engineering was nice enough to list the no-load voltage, 4.6VACrms in this usage. Adding 20% of safety factor and multiplying by 1.41, I get a peak voltage of about 7.8V. The voltage divider circuit then reduces that AC voltage signal down to less than 2.5V, centered around 1.25VDC. Does the above seem reasonable?

So I expect the BAV99 to activate only when the voltage shows significant excursions above 140VACrms. That's hopefully rare - but do I have it right? Circuits similar to this one have worked well for me and I was too greedy trying to eliminate the transformer. FWIW, the transformer is allegedly short-circuit proof and the attached circuit only draws about 1mA (vs. the 13mA that the transformer can deliver).  Would loading the transformer more help with accuracy?  That is, decrease the load resistor from 1k to 200 Ohms, the drop resistor from 2.2k to 470 Ohms and hence increase the circuit draw to about 6mA, for example?

Presumably, since this is a transformer-based design, the polarity is less of an issue? I have the fuse on the presumed line input, 1A, which also protects the switch-mode power supply. I guess I shouldn't worry too much about reversed polarity then?

Speaking of which, some of the CUI power supplies suggest common-mode chokes for better EMI performance but this one specifically does not in its datasheets. Per the manufacturer (I inquired) they are not necessary. But would you add other external components beyond the fuse to limit transients, reduce EMI noise, etc?

Many, many thanks again and I apologize to Mike for misapplying the knowledge he so generously shares.
672  Using Arduino / Sensors / AC Line Safety on: January 12, 2012, 12:09:48 pm
In order to make the power measurement unit more compact, I am considering following in the footsteps of the open energy monitor project as well as the low-cost single phase power meter design published over at Atmel. The line voltage is a nominal 120VAC.

Below, you can see the circuit that I am considering for the AC voltage measurement. Both line and neutral have drop-down resistor while the measurements are taken off of the 4.7k resistor (i.e. it's floating - 59VAC above and 59VAC below). The two 1k resistors create a DC voltage divider that the 10uF tantalum cap supports. The 22 Ohm resistor, BAV99, and the 100pF capacitor are protections that Grumpy Mike suggested on his site and I hope I implemented them correctly.



For this design I expect the output signal for the Arduino to fluctuate from about 0-2.5VDC (i.e. 0VDC to AREF). I have successfully used this topology before with a AC-AC transformer. Note: the AREF has it's own 2.5V linear voltage regulator that derives its power from an isolated 5VDC switch-mode power supply (VOF-6 from CUI).

Here now my questions: For one, is it a good idea to have the 220k-4.7k-220k resistor network set up this way? The reason I chose this topology is to guard against the possibility of a line/neutral reversal in the wall socket. Having a drop down resistor on either leg feeding the 4.7k resistor that measurements are made on reduces the maximum current to less than 10mA even under peak line voltage conditions and a short to GND on the Arduino side of things.

Atmel goes a slightly different route in their design. They use a series of drop down resistors and tie the AC neutral and AC ground lines together. Their power supply is a drop-cap design that feeds a linear regulator. I could tie the AC GND and AC Neutral together as well, I simply worried about fireworks if the outlet was miswired. This does not seem to be a concern for a power meter... :-D Which design is better?

Also, as designed the 120GND and the board GND are not tied to each other and there doesn't seem to be a need given that a similar design has worked in the past when I used an external AC-AC wall transformer and a external switchmode DC power supply. Is the above sane?
673  Using Arduino / Sensors / Re: 360 degree wind direction sensor on: January 11, 2012, 10:02:19 pm
Thanks retrolefty, some digging minutes brought me to - http://www.technik.ba-ravensburg.de/~lau/ultrasonic-anemometer.html - AMAZING!!
Rob, thanks for sharing that link. What an amazing array of instruments, sensor systems, etc. this gentleman has built.  Some day, I may begin to understand 1/2 of what this gentlemen does in his spare time. Using a laser to characterize the quantity of precipitation is pretty amazing. Distinguishes among the many different types of precipitation is over the top!  Certainly inspiring. Some day when the kids demand less attention perhaps I'll have time...
674  Using Arduino / Sensors / Re: Question regarding trenches around analog inputs on: January 11, 2012, 09:56:11 pm
Hi everyone,

Many thanks for your thoughtful replies. The trenches are gone, now the PCB is 95%+ ground plane on one side (with no non-GND conductor there longer than 0.1" or 2.5mm and a couple of islands thanks to through-hole components like the ISP header).

I didn't have issues with analog measurements in the past either, I simply was wondering if I was following best design practices or not. Given that Atmel is the maker of our chips, I ventured the guess that their advice is worth following... anyhow...

Does "trench" mean a break in the ground plane around a component or certain area, so that the ground plane under the area in question only connects to the larger plane at one point?
Yes! The idea per the theory is that you cannot get induced loops if the signal can only exit at one point in the PCB. Likely more of a consideration with chips operating in the GHz range than our rather more pedestrian Atmels... :-D

And to your other points, all signal lines are 15 mil, power lines are 24 mil thick and up. Thermal management can also be a consideration, i.e. where to put the heat emitting chips like voltage regulators vs. thermal sensors. I try keeping them on opposite ends of the board. Since I hand-assemble the boards, I use no chips smaller than a 0805 because getting those to seat on pads is interesting enough. I am also a big fan of the input protection system that Grumpy Mike posted on his site, i.e. a 22Ohm resistor in series with the signal plus a 100pF cap and a BAV99 protection diode referenced off AREF.

One resource that I have found incredibly useful is the freerouter to help me with chip placements. I may still route a board by hand, but the freerouter quickly illustrates what kinds of designs are likely going to require a lot vs. very few vias. The only downside to the freerouter is its tendency to 'forget' that polygons that are defined as GND do need a connection back to GND somehow... but I am certainly not complaining, it's an amazing resource, free, and it beats the autorouter in Eagle 5.11 to a pulp.

Everyone, thanks again, I really appreciate the help.
675  Using Arduino / Sensors / Re: Question regarding trenches around analog inputs on: January 11, 2012, 07:13:49 pm
Hi RuggedCircuits and thanks for the reply!

That's good news regarding the solid GND layer - which is pretty much what I have. I cut trenches into it after the fact but the exercise seemed somewhat counterintuitive given the boards that are on the market versus what Atmel is advocating for. I wonder what is motivating their positions in these application notes then.

The de-coupling caps weren't too hard to implement - the board still had room and it allowed me to move traces as needed.

The AGND-GND question came from the trench question - if one has to trench around the AGND area, where is the best place to 're-connect' to the regular GND on the board? That's kind of a moot point now that the trenches are going bye-bye.

Seeing that the power consumption is likely going to be minimal as you suggest and that the board is not driving motors, I'm not going to worry too much about the star distribution system either. A fat ring, a nice 100uF cap to keep things level ought to go a long way towards stability in conjunction with all the de-coupling caps around the board.

Thanks again!
Pages: 1 ... 43 44 [45] 46 47 ... 50