Thursday, July 22, 2010

HP RPN online

For those like me who don't have an Reverse Polish Notation (RPN) calculator but would like to try one out or use one without actually getting a unit, here's one by Hewlett Packard.

I've always been a Casio devotee. And currently my scientific calculator of choice is the FX115MS. Love it. Has every function I need. If it were programmable it would be perfection itself.

Tuesday, July 20, 2010

Where's the spec?

I've been going over the Fluke 80 Series V user's manual but I can't find the specs for the DCmV impedance when high input impedance mode is set. Input resistance is normally 10MOhm but when the "Hz %" button is held down when the meter is turned on its goes into high impedance mode in the DCmV range.

The Fluke 87 (original series) manual actually states how much it is: "The input impedance of the function (400 mV range) is changed from 10 megohms to greater than 4000 megohms." But that's for the 87 not the 87V.

Googling turned up only one source for this datum. Fortunately, it's pretty reliable since it comes from one of Fluke's own engineers. Chuck Newcombe tells us that,
If you want to measure a high impedance dc source, and the anticipated voltage is less than 600 mV, the Fluke 87V has a power-up feature that can save the day. Just hold the 'Hz %' button while you turn the meter on to remove the 10 megohm divider from the circuit. Now, the dmm's loading effect is greatly reduced, with an input resistance of 1000 Megohms or more. 
So there. For the 87V high input impedance mode value is at least 1000 Megs.

Why this isn't in the specs section of the manual boggles the mind.

Sunday, July 11, 2010

Half a Fluke






Always dreamed of having a bench multimeter. Sure can't afford a brand new Fluke. So I settled for a couple decade old 8842A. Got it off ebay. Was excited to start using it when it arrived. But just minutes into checking the various functions my heart sank when I discovered the AC functions weren't working. "Error 30" kept popping up whenever the "VAC" and "mA ~" buttons were pressed. That could only mean that the AC circuit board isn't installed! That's despite the fact the supplier had told me personally that all the functions--including AC--were working fine. But that wasn't the worst of problems. Turned out the power switch is faulty. After turning the unit off for the first I had trouble getting it switched back on. It's a pushbutton type that mechanically latches. Apparently the mechanism is already dodgy. Had to press it several times for it to stay in the down (on) position. After turning it off for a second or third time the switch just died. That was when my heart stopped. I had bought a lemon. I now had a $300 paperweight adorning my workbench.

Lesson learned. Don't buy expensive antique second hand equipment from half a world away unless you're prepared to be disappointed and unless you can afford to have it sent back in case it's not as described in the ad and/or is defective.

Fortunately that isn't the end of the story. The following day I performed CPR on the Fluke. I kept pressing the switch--gently!--while turning the unit over and on its sides. I was banking on the off and off chance that gravity might help get the switch mechanism to engage. I don't know if the turning helped at all but after a minute or so of pressing the switch actually engaged. Well, that was it--I was not ever, ever going to push that button again. No way I'm going to risk being unable to switch this meter on again.

To power the unit up and down I'm now using an extension cord that has a similar latching pushbutton switch. I've already turned the meter on and off at least a dozen times over the past few days and the unit seems to not mind. I'm just crossing my fingers it stays that way. Will eventually have to look for a service center that can replace this switch. My concern, however, is loss of calibration when they take the unit apart, and what component they might wreck!

As a precaution I've stuck a neon yellow Post-It over the 8842A's green power switch to prevent me from accidentally pressing it! Given how absent-minded I am that's bound to happen without this warning sticker.

This is a calibrated unit (well at least that's what the seller tells me) and initial tests show that it is in fact pretty accurate. I used another Fluke and did a side-by-side test of the DCV, DCmA, and ohms ranges and readings from both meter are within 0.01% of each other. The other Fluke has much less resolution so the two meters are hardly on equal footing.

Friday, June 25, 2010

Shape up, Farnell

Four weeks after I placed an order with Farnell, the ICs haven't arrived yet. Their lead time is 1 to 3 weeks. I emailed them saying it was way past the maximum lead time they had provided me. A representative of theirs called me the next morning and told me that all the parts were already in their local warehouse, except for one. And that one part has a lead time of 32 weeks! 7 months! Well, why the heck didn't they tell me earlier? And why didn't they deliver the components that are already in their office? Why did the client have to follow up before informing him of this extraordinary situation? Uhh!

The person I spoke with told me she'll get on matter immediately and deliver the parts that are already around. She gave me the option of retaining or canceling the IC that won't be available till next year. After I said it would be good if could be cancelled, she said she'll have to check whether it can be cancelled. Argghh! Doesn't this company have a policy in place for these situations? This isn't at all what I expect from a global distribution company. Three thumbs down.

I rarely purchase from Farnell because their prices are way higher than RS Components'. The only reason I ever get from Farnell is if RS doesn't carry the part. And I only buy from RS when local suppliers don't have what I need. With this unforgivable incompetence, Farnell has slipped further than last place in my list.

Tuesday, June 22, 2010

Sayonara to Sanwa DMMs

It may be strange to hear but the only multimeters I've used over the decades are those by the Japanese company Sanwa.I've laid hands on various Made in China meters, some of which were Fluke look-alikes, but hey those meters aren't even worth having had for free.

In my small collection I have a very old N101 (purchased c.1970s) which I inherited from my dad. I'm still using the original test leads, and have the original box and its manual (which includes a complete schematic). I really like this meter, specially its exterior design. I don't think there's a Sanwa analog meter that can beat its clean, smart, modern, look. I've burned this meter in the past--accidentally poking the VAC mains while the range switch was set to ohms. You get the shock of your life from the BZZZZT that goes off inside the meter. And you end up with deep fried resistors for lunch. Great thing about these old analogs is that they use large through-hole components which are so easy to replace. Take out the burnt component and solder in a new one and it's good to go again. No ICs to worry about. No surface mounts. Of course, accuracy isn't one of its strong points. But it's good to have one (inexpensive) analog around, even if only as a backup meter. And hey, this N101 is quickly becoming an antique. Maybe it's already appreciating in value. This unit is a keeper. I want to pass it on to one of my nephews--one who will eventually grow up to have a love for electronics/electrical work.

About two decades ago I bought my first digital multimeter--the CD721. (Sorry no pics available.) As always I wrecked this meter within a couple of years. Shot its brain with 240VAC while it wasn't expecting it--ohms range. And moreover, the plastic casing is now bloated. I can't remember exactly how that happened, but it could've been because I left it baking inside the car while it was parked in the sun--we're talking of something like 50Celsius. The CD721 is with my sister now. I have no use for that piece of junk. Her kids like playing around with it though. Yes, I have taken precautions so that the little ones won't be able to stab themselves with the probes or get themselves roasted poking into outlets.

Got a CD771 back in 2007 for around $65 to $70 (depending on what the dollar conversion rate was at that time). I don't even use my meters on a weekly basis. And yet this dang unit has already been on the blink for a year now. It just sucks. When this meter works, it works quite well. But when it's in a fit, it'll throw garbage at you. During those moments, the meter might give yo a reading of 40V while you're measuring a 5VDC circuit or it might even display "OL" meaning it's out of range. And the resistance might read several megohms when you short the probes and autoranging slows down to a crawl. To get the meter to work again I switch it off then on again. Usually after one or two such resets the meter gets its sanity back.

So in terms of ruggedness and reliability I can't but give Sanwa digital multimeters a two thumbs down. I've really become sick and tired of Sanwa DMMs that I got myself a Fluke. No cheapo. The Fluke 80 series is some 5 times pricier than the Sanwa. It hasn't arrived but I know I won't be disappointed. And that's one DMM I'm certain will proudly be on my bench and in my tool box for decades to come.

Monday, June 21, 2010

Thou shalt not turn an op amp into a comparator

Is that writ in stone? A commandment from Mt. Sinai no less?

Texas Instrument engineers Bruce Carter and Ron Mancini say that using an op amp as a comparator is a no-no because "an op amp has an output stage optimized for linear operation, while the output stage of a
comparator is optimized for saturated operation." Moreover, "the comparator is an open loop device, utilizing no feedback resistors." The op amp, on the other hand, is
optimized for closed loop applications. The results are unpredictable when an op amp is used open loop. No semiconductor manufacturer can or will guarantee the operation of an op amp used in an open loop application.
Yet more bad news:
The transistors used for op amp output stages are not switching transistors.... When saturated, they not only may consume more power than expected, they may also latch up. Recovery time may be very unpredictable. One batch of devices may recover in microseconds, another batch in tens of milliseconds. Recovery time is not specified, because it cannot be tested. Depending on the device, it may not recover at all! Runaway destruction of the output transistors is a distinct possibility in some rail to rail devices.
There can be exceptions to the rule, however. 
In some cases, the designer may get away with using an op amp as a comparator. When an LM324 is operated in this fashion, it hits a rail and stays there, but nothing 'bad' happens. The situation can change dramatically, however, when another device is substituted.
But what if we use the op amp with positive feedback? That's no longer open loop, right? Well that's a question that Carter and Mancini don't tackle. And positive feedback is what we put into the touch sensor op amps to turn them into comparators with hysteresis. So does that make the use of op amps as comparators ok? Doubt it. Even if that solves the open loop problem, it still leaves the issue of op amps being used to saturation and slamming its output to rail. Then again maybe we'll get lucky and will be able to get away with it, depending on the op amps we use.

Engineer James Bryant of Analog Devices has the same advice as the guys from TI.
[T]he best advice on using an op amp as comparator is very simple—don't! Comparators are designed to work as open-loop systems, to drive logic circuits, and to work at high speed, even when overdriven. Op amps are designed for none of these. They are intended to work as closed-loop systems, to drive simple resistive or reactive loads, and should never be overdriven to saturation.
Damn.

Bryant does address the matter of building hysteresis into the op amp.

He concludes on a more positive note:
[A]lthough op amps are not designed to be used as comparators, there are, nevertheless, many applications where the use of an op amp as a comparator is a proper engineering decision. It is important to make an educated decision to ensure that the op amp chosen performs as expected.

To do this, it is necessary to read the data sheet carefully and to consider the effects of nonideal op amp parameters on the application. Because the op amp is being used in a nonstandard manner, spice models may not reflect its actual behavior, and some experiment is advisable. Furthermore, because not all devices are typical in their behavior, some pessimism is warranted when interpreting the experimental results.

----

Reference:

Bruce Carter & Ron Mancini, Op Amps for Everyone, 3rd ed., Newnes, 2009, p. 535-538.

Sunday, June 20, 2010

A purely analog touch sensor

My sister's family and I spent the afternoon together last Sunday. Had a late lunch at a fine dining restaurant. Food was great. Unfortunately the kids still need years to develop a taste for good food. Their dad said he'd just bring them to Krispy Kreme after lunch to fill their bellies.

At least twice during the meal the 5- and 4- year old had to go to the washroom. Being the good and lovable uncle I accompanied them.Well, it proved to be an adventure for the boys. The urinals in the air conditioned and plush restrooms had infrared sensors to detect the presence of, well, humans. As can be expected the brats had a ball playing with them, tripping them off with their hands and watching as the gizmo flushed water down.

That evening it occurred to me that I could easily design a circuit the kids can have fun with to turn on a light or just an LED. I already have a circuit installed in my home that switches on the ceiling lights whenever I cross the hallway. It's a windowless area and is pitch black at night. With the circuit I don't have to go back and switch off the lights. The sensor is a Keyence PZ-51 infrared transmitter-receiver with an NPN output, which I set up as a reflective system with the emitter and detector side by side. When something/someone reflects enough of the infrared beam back to the receiver the circuit gets triggered and the lights are switched on for a little over half a minute. A 3-second beep sounds right before the lights go out to warn the person.

Given my experience with photoelectric sensors and the fact that I still have a number of these Keyence products I got from a sale almost a decade ago, I started designing a circuit based on photosensors. But I hadn't even drawn a single schematic when it hit me that this was just overkill. Using an industrial part like the Keyence didn't seem right. Worse, it isn't kid-proof at all!

I needed something simpler and more rugged, something more or less immune to the bashing, smashing, "crayoning," drooling, and what-have-you the sensor will be up against and subjected to with a brood of 2-, 3-, 4-, and 5-year olds. So it occurred to me--Why not detect the 60Hz hum that everyone in the city conducts? That way the sensor could be any conductor--a length of wire, small thumb-sized metal sheet, maybe even the door handle of a cabinet.

Mulling over the circuit requirements, it seemed to me that what had to be done was to amplify the signal from the human touch and pass it through a comparator with hysteresis to get a good clean digital output. I hit the breadboard and configured one of the op amps of a MCP6232 dual op amp as a noninverting amplifier with a gain of 100 and the other as a comparator. Well, surprisingly, it worked!

Oscilloscope showed, however, that there was a lot of high frequency noise being amplified as well. So I figured I'd add a low pass filter (LPF) at the front end (before the amplifier) with a cutoff frequency (Fc) of around 120Hz .To try it out I used a good round figure of 100Kohm and 10nF which gave an Fc of 160Hz.(equation is 1/(2πRC)). Sure enough it cleaned up the signal pretty well.

The design was practically finished and I could feed the 60Hz pulse train output of the comparator to a microcontroller and have that MCU process the signal and turn on lights and buzzers, etc. for, say, a specified amount of time. It can even reject rapid multiple "button presses" to prevent the light from being turned too many times a minute. Or it can process such multiple contacts as a code to turn the load on for a certain amount of time or certain fashion, etc. Once the analog end was able to provide a reliable signal, the MCU could do the rest. And if the MCU had an onboard comparator then we need only filter and gain the input signal before sending it to the MCU.

But I wasn't satisfied. I wanted to push myself and create an output (from the op amps) that stayed high (Vcc) the moment the comparator was triggered and then drop out (go to ground) once the 60Hz pulse train ceased. In other words, if I hooked up the output to trigger an NPN, the transistor would be completely and continuously on while the user was touching the sensor.

So what I had to do was to convert that pulse train from the comparator to a DC signal that would rise to and remain above a certain minimum voltage while the user was touching the sensor. My solution? An LPF with a Fc of <60Hz.

As a first cut, I used a 1uF tantalum and 100Kohm to give an Fc of 1.6Hz.  I then got another MCP6232 and configured one of the op amps as a noninverting comparator (with no hysteresis). The output of the passive LPF was then fed directly into the noninverting input of the op amp.

Lo and behold! I got what I wanted. Well, almost. Not surprisingly the long RC constant of the 1.6Hz LPF caused a hell of a delay in the response of the second comparator. After the user touches the sensor it took tens of milliseconds for the voltage to ramp up to the trip point of the comparator and then after the sensor ceased detecting contact, it took about a hundred milliseconds for the voltage to decay below the trip point. Very slow and humanly noticeable delay.

To alleviate this, I had to decrease the RC constant which meant increasing the Fc. I chose 6Hz. Oscilloscope showed a very significant increase in ripple voltage. And this of course meant that the comparator (remember, it had no hysteresis) could rapidly go high and then low and then high again as the voltage was passing the comparator trip point. And in fact, tests showed that this does happen every once in a while. This meant that hysteresis had to be designed into the circuit.

Which I did. I added positive feedback using two resistors. When I tried the circuit it was a dud. Why? Because the output of the passive LPF is high impedance. The noninverting input of the comparator is very high impedance but with the positive feedback resistors also connected to the noninverting pins of the op amp that just changes the circuit characteristics. Solution was simple but required the use of another op amp. The LPF had to be buffered by a voltage follower (unity gain amplifier). This low impedance signal could then be fed to the comparator with hysteresis.

The following is the final circuit (for now) after tweaking the values for the LPFs, hysteresis, comparator voltage reference, etc. Load resistor RL is necessary and has to be high value. The lower the value the more attenuated the signal becomes. I used a 3Meg in the test circuit. The front end LPF has a Fc of 72Hz. You might notice the "coax." in the schematic. A coaxial cable is needed only if the sensor--a fingernail-sized touch plate for instance--will be located more than a few centimeters from the circuit board. Any plain old conductor acts as an antenna picking up the 60Hz hum; and the longer the conductor the higher the amplitude of the signal. At the amplifier gain of 100, a wire longer than 20 centimeters will transmit a large enough signal to trigger the first comparator. I've actually tried using a meter-long coaxial wire and it does work--the circuit is not triggered unless the far end of the coax is touched. The copper braid (shield) of the coax must be electrically connected to circuit ground.

Note that amplifier A3 is no longer a voltage follower that buffers the 6Hz LPF, but a noninverting amplifier with a gain of 2. The reason is that the buffered LPF signal was approx 2.3VDC with a ripple voltage of around 850mV peak to peak. The upper threshold trip voltage of the comparator A4 is about 1.8VDC. This is no problem when the sensor is fully touched--that is, output of A1 reaches the positive rail (and you get a quasi rectangular pulse train, not a half sine wave). But when A1output is weak (low amplitude but is above the upper threshold trip voltage of comparator A2) the duty cycle of the output of A2 drops and so there is much less on time for CF2 to charge, resulting in a much lower average DC of the LPF output. This causes comparator A4 to fail to trigger. Thus, it was necessary to gain the LPF output to make sure that when A2 trips, A4 will trip too. Both comparators are referenced to 30% Vcc.

Finding the equations for determining the upper and lower threshold voltages of the comparators has been a headache. Still is. The commonly given equations in textbooks are for op amps/comparators using a bipolar power supply. I'm using a single supply. I did find single supply equations in the datasheet for the MCP6541 comparator. However, measurements using an oscilloscope (see below) do not tally with the results from the equations. Perhaps input signals to comparators A2 and A4 need to be buffered.

What follows are oscilloscope (Rigol 1102E) screenshots of the circuit in action. Refer to the schematic for test points P1 to P4.


Test point: P1

Output of A1 when sensor (a 14-cm AWG 22 wire) has not been touched. As can be seen the measured frequency is 60.2Hz and Vpp = 720mV



Test point: P1

Output of A1 when sensor touched. The amplifier saturates. (The Vpp as measured by the scope can't be right of course given the 1.00V/div)



Ch1 test point: P2
Ch2 test point: P1
Ch1: 2.00V/div
Ch2: 1.00V/div
Trigger: Auto, Ch2, 200mV, rising edge

Sensor touched. The output of comparator A2 is almost a square wave. The output of A1 is coming close to square wave. (The scope's Vpp measurement of A1 output is now correct)



Ch1 test point: P2
Ch2 test point: P1
Ch1: 2.00V/div
Ch2: 1.00V/div
Trigger: Auto, Ch2, 200mV, rising edge 

Sensor not touched.



Ch1 test point: P3
Ch2 test point: P1
Ch1: 2.00V/div
Ch2: 1.00V/div
Trigger: Auto, Ch2, 200mV, rising edge 

Sensor is touched. In the above screenshot output of A3 has already stabilized. With the gain of 2 the LPF output reaches positive rail.



Ch1 test point: P3
Ch2 test point: P2
Ch1: 2.00V/div
Ch2: 1.00V/div
Trigger: Auto, Ch2, 200mV, rising edge

Sensor is touched. 



Ch1 test point: P2
Ch2 test point: P1
Ch1: 2.00V/div
Ch2: 1.00V/div
Time base:10.0ms/div
Trigger: Single sweep, Ch1, 200mV, rising edge,

Here we see the very moment A1 output trips comparator A2



Ch1 test point: P2
Ch2 test point: P1
Ch1: 1.00V/div
Ch2: 1.00V/div
Time base: 500microsec/div
Trigger: Single sweep, Ch1, 200mV, rising edge,

This is a zoomed in portion of the preceding single sweep capture. Cursors have been turned on and manually adjusted to the point of intersection between the output of A1 and A2. The scope measures the hysteresis band at 840mV. Comparator A2 upper threshold voltage = 1.88V, lower threshold voltage = 1.04V



Ch1 test point: P3
Ch2 test point: P1
Ch1: 1.00V/div
Ch2: 1.00V/div
Time base: 20.0ms/div
Trigger: Single sweep, Ch1, 200mV, rising edge,

This clearly shows that because of the RC constant of the 6Hz LPF there will be a delay before A4 output goes high.



Ch1 test point:P4
Ch2 test point: P1
Ch1: 1.00V/div
Ch2: 1.00V/div
Time base: 20.0ms/div
Trigger: Single sweep, Ch1, 200mV, rising edge

The delay between touching the sensor and A4 output going high can be seen here. Also shows the clean digital output of A4. The ripple voltage is due to the power supply.




Ch1 test point: P3
Ch2 test point: P2
Ch1: 1.00V/div
Ch2: 1.00V/div
Time base: 50.0ms/div
Trigger: Single sweep, Ch2, 200mV, rising edge

Rise and decay of A3 output in relation to comparator A2 output




Ch1 test point: P3
Ch2 test point: P2
Ch1: 1.00V/div
Ch2: 1.00V/div
Time base: 20.0ms/div
Trigger: Single sweep, Ch2, 200mV, rising edge




Ch1 test point: P4
Ch2 test point: P2
Ch1: 2.00V/div
Ch2: 1.00V/div
Time base: 20.0ms/div
Trigger: Single sweep, Ch2, 200mV, rising edge

A4 output in relation to A2 output. What is most evident is the large delay in A4 output droput



Ch1 test point: P4
Ch2 test point: P2
Ch1: 2.00V/div
Ch2: 1.00V/div
Time base: 2.0ms/div
Trigger: Single sweep, rising edge, Ch2, 200mV

This is a zoomed in portion of the preceding capture. Cursors are on to measure the delay between comparator A2 output and A4 output. In this particular case it's 3.5ms




Ch1 test point: P4
Ch2 test point: P2
Ch1: 2.00V/div
Ch2: 1.00V/div
Time base: 2.0ms/div
Trigger: Single sweep, Ch2, 200mV, rising edge

This is a zoomed in portion of the second to the last capture. Cursors are on to measure the delay between comparator A2 dropout and A4 dropout. In this case it's 57ms.


 
Ch1 test point: P4
Ch2 test point: P3
Ch1: 1.00V/div
Ch2: 1.00V/div
Time base: 50.0ms/div
Trigger: Single sweep, rising edge, Ch1, 1.0V




Ch1 test point: P4
Ch2 test point: P3
Ch1: 1.00V/div
Ch2: 1.00V/div
Time base: 2.0ms/div
Trigger: Single sweep, Ch1, 1.0V, rising edge

This is a zoomed in portion of the preceding capture. Cursors are on to measure the upper threshold trip voltage of comparator A4. In this case it's 1.80V.




Ch1 test point: P4
Ch2 test point: P3
Ch1: 1.00V/div
Ch2: 1.00V/div
Time base: 2.0ms/div
Trigger: Single sweep, Ch1, 1.0V, rising edge

This is a zoomed in portion of the second to the last capture. Cursors are on to measure the lower threshold trip voltage of comparator A4. In this case it's 880mV. The hysteresis band = 920mV.




Ch1 test point: P4
Ch2 test point: P1
Ch1: 1.00V/div
Ch2: 1.00V/div
Time base: 50.0ms/div
Trigger: Single sweep, rising edge, Ch1, 1.0V

A4 output in relation to A1 output.




Ch1 test point: P4
Ch2 test point: Vcc
Ch1: 1.00V/div
Ch2: 1.00V/div
Time base: 20.0ms/div
Trigger: Single sweep, Ch1, 1.0V, rising edge

This one shows the ripple voltage present in Vcc. Also shows how close to the rail A4 output is.

---------------------

Addendum
June 20 11:00pm

I reduced the cutoff frequency of the front end LPF to 1.6Hz by changing CF1 to 100nF. Touching the sensor didn't even trigger A2. I then increased the gain of A1 to 400. Didn't work either. I couldn't get A1 and A2 to have the outputs of A3 and A4 respectively. Seems there are no shortcuts.