Skip navigation

Elevator test unit

Posted by popupideas Aug 27, 2017

one diy test unit I want to build is a g-force accelerometer tested for elevators. Prefer a Bluetooth enabled box you put inside an elevator that when it is sent up it will record the travel speed, acceleration, start and stoppong force. It bit I had issues figuring out was vertical speed.

Anyway. I am a loooong way off but maybe one day


Multi-Ref Mk. II

Posted by hlipka Aug 22, 2017

The Multi-Ref is not a test device as such, but the tool I use to test my test equipment. I got the idea for this from the user [matseng] as the forum, and found it very useful.

MrRef, as it was called, is just two coin cells powering a precision voltage reference. The intention is to allow checking your own multimeters for accuracy and drift. Not everybody has a 6.5 or better DMM at home, with a accuracy of 0.01% or even better. Back then my best DMM was a TekPower TP4000ZC, 4000 counts and 0.5% accuracy at the best, anything else was just cheap 3.5 digit DMMs, some of them more than 15 years old (but I got a UT61E shortly afterwards which claims 0.1% accuracy). So it was interesting to see how accurate the meters still are. This is something important - you want to know that you can still trust the stuff you measure.

So I built a small MrRef by myself, using REF5020 from TI. This is a low noise precision reference with 2.048V output. Its 0.05% accuracy result in at most 1mV error - one digit basically. But this value creates a problem: its too high to properly check a 2000 count DMM since these go only up to 2.0V.

REF5020 reference

So when I got my UT61E (two actually) I decided that I needed more than one reference voltage. The best would be to cover the range from 1 up to 10V so you can test at least two ranges and also see how good the linearity is. In the end I selected mostly references from Intersil since they came with the highest initial accuracy. I have no way to go to a calibration lab to get the actual reference values so I need to rely on the manufacturer. here is what I selected:

ReferenceVoltageInitial Accuracy
Drift (ppm/°C)
REF102CUREF102CU10V0.025% / 2.5mV2.5
ISL21009BFB8505V0.01% / 0.5mV3
ISL21009BFB8252.5V0.02% / 0.5mV2
ADR4520B2.048V0.02% / 0.4mV2
ISL21090BFB812Z1.25V0.03% / 0.375mV7

Together these did cost about $30, depending on where you get them. The best one is 10 times as accurate as the UT61E and the worst one still three times. I deemed this good enough to check how accurate my meters are and how much they drift over time.

I put all of the references on a small PCB, together with some 78xx regulators so the references don't need to dissipate so much power and heat up. Everything was powered from a 9V AC supply (whose voltage was doubled).


The PCB itself was designed to be generic so I can use other references. Most of them follow a common SO8 footprint, and just differ in whether they need input and output capacitors, and sometimes an optional capacitor.


(The resistors in the middle look a little bit funny - I forgot that the 78xx regulators need some minimal load so I needed to add them. You can see the free footprints for the capacitors, and how they are populated differently for the different references. Whats not to be seen here is that I also have a DPDT switch so I can easily switch polarities to the multimeter so I can test both positive and negative ranges.

Later on I also bought some precision resistors (with 0.01%, and I also some older ones with 0.1%) to test the resistance ranges. I also used them to manually check the current ranges. The most difficult range to test are capacitances - the best you can get are 1% foil capacitors. They easily cost 1 up to 4 dollars each, depending on the capacity. I ended up with a 1nF and a 4.7nF 2.5% capacitor.


Since I have everything to test my meters, why a second version? Well, there are two reasons.

The first one is that I killed the REF102C by accidentally connecting the 9V AC power supply to its output. It didn't like that. I made the big mistake to have all connectors look the same, and AC in and 10V out are just on opposite corners of the board. Its actually surprising that it took me several year to make this mistake. So I replaced the chip, and looked for a way to prevent that in the future.

The second reason is that everything is fiddly. You have the flying DPDT switch, need to place the pin header on a separate output for each voltage (in the correct position). The resistors and capacitors are not mounted to anything but I just kept them in a bag. And the power supply was also in a bag together with the PCB and the caps and resistors.

So my second version was not about a redesign, but about making a real project out of it: place everything in a proper case, with a proper range selection switch and just a pair of binding posts. And since there was some room to spare, I added a precision current reference to.

For the latter one one I used the design from the Scullcom video blog - its easy to build and quite accurate. I wanted to build it since I saw it for the first time but never came around.

For the voltages, resistors and capacitors I found an old 2x24 rotary switch - unfortunately the current reference needs  a three-pole switch so I put it on an separate pair of binding posts. Time to start wiring everything:


The REF200 current source is just on that small SOIC8 breakout board, attached with magnet wire to the range switch. On the large switch I already added the wires for changing the polarity of the voltages.

Then I mounted the existing PCB and the 9V transformer 8without its case) to a small acrylic plate which is then mounted in the enclosure:


The current reference is powered from the existing 9V regulator so I don't need an additional battery. The resistors and capacitors go to a separate board, wrapped in heat shrink tube. One of the resistors (the 100k one) is on the bottom side since its a SMD one.

If you count very closely you can see that there are too many wires. This is due to a small trick: I added one pair of wires for the capacitors, which I left open. And another wire for the resistors which gets shorted to the common wire. These additional wires end up in a '0nF' and '0 ohm' selection, which can be used to zero out any capacitance and resistance in the measurement wires. Since they are of the same length and placement as the regular wiring this relative measurement is hopefully quite accurate.


Everything wired up:


The front plate was designed in Draftsight (a free CAD program for Linux, Mac and Windows). I printed it on paper, glued it to the plastic front plate and them covered it with self-adhesive foil:


I found a nice trick to get the lines for the scales all in the right place:

  • draw two circles, centered on the hole for the rotary switch, which mark the inner and outer end of where the lines should be
  • then create points to split the circles in segments (Draw / Points / Segment - select a circle and it gets marked)
  • configure Draftsight so points get a large cross (to see them on the drawing)
  • Use the "Element Snap" function to snap start and end points of each line to the correct segment points
  • afterwards, delete the circles and the points, and you have just the scale lines left

I think it ended up quite well. No need to fiddle with wire grabbers, re-positioning connectors and looking for parts in a small box:



Current measurement can be really awkward when working with circuits. Voltage measurements are (usually) straightforward, but when it comes to current measurements the story is different. One typical approach is to insert a known resistance by breaking the circuit, and then measuring the voltage across it. This is difficult if one end of the resistor is not at ground potential, because oscilloscope probes are (usually) designed with the ground leads all connected together, and it will damage things if the grounds of different channels on the oscilloscope are connected to different parts of the circuit.


This project describes a very sensitive home-made current probe that doesn’t require a known resistance to be inserted. It has not been fully characterized but the initial results are reasonably promising. It was tested at currents of the order of single-digit microamps up to 10mA (it can be assembled for higher current ranges if desired), and it functions from DC to around 20kHz, and is fully isolated.



It is based around a very exotic magnetic field sensor known as a fluxgate magnetometer. Ordinarily this is quite difficult to build due to the requirement for hard-to-find mu-metal and a mix of analog and digital electronics. However, Texas Instruments offers an entire fluxgate magnetometer-on-a-chipfluxgate magnetometer-on-a-chip and an evaluation boardevaluation board. With some effort it is possible to build a current sensor or probe with it. It makes a handy test tool for measuring current in a circuit, in a less intrusive way than normal.


What is a Fluxgate Magnetometer?

There are several ways to make magnetic field sensors, and the fluxgate magnetometer offers very impressive sensitivity. There are slightly different topologies of fluxgate magnetometers, but in a nutshell they consist of windings around a core. If we use a Lego wheel tyre to act as a pretend core then ‘Excitation’ and ‘Sense’ windings can be placed around it as shown in the photo (the windings are the yellow and green wires in the photo).



If we consider the core to look like two semi-circular half cores each with half of the excitation winding on it then an AC signal of sufficient power is applied such that each half-core reaches saturation (i.e. the magnetic field cannot increase any further) in both directions alternately as the AC signal changes direction.


The other coil, the green sense coil, is wound around the outside like a wrapper to the entire thing. When the core is in saturation the magnetic field does not change, and therefore there is no voltage across the sense winding. In other words, a changing magnetic field is needed to induce a voltage in the sense winding. The clever bit occurs when there is an additional magnetic field present (either created locally with another winding, or any existing nearby magnetic field as shown in blue in the photo above). Because the two half cores have their excitation windings in opposite directions, ordinarily the magnetic fields cancel out. But in the presence of a magnetic field, when the AC excitation signal direction changes, one half core will exit out of saturation slightly sooner than the other half core, or slightly later than the other half core, depending on the direction of the additional magnetic field. When this occurs, there is no balancing out of the magnetic fields! And since the magnetic field is no longer zero, during this time that the field is changing, a signal is generated in the sense winding. It is an easy-to-detect signal because the asymmetry caused harmonics of the excitation signal frequency, and it can be detected using analog electronics.


The basic design can be modified by having yet another winding known as the Compensation coil and an amplifier to drive it such that it nulls out the external magnetic field. The output of the compensation coil therefore becomes the output of the fluxgate magnetometer.


Fluxgate magnetometers have exceptional sensitivity and can detect the earth’s magnetic field. Texas Instrument has several ICs that contain all the signal generation and signal processing required to construct a fluxgate magnetometer. There is also one IC in the range which even integrates the core inside the package. I decided to use that IC for this project. All I needed to worry about was how to generate the external magnetic field, and that is possible with an external winding.


The diagram here from TI’s website shows the internals of the IC. All of this is integrated into a tiny square 4x4mm package.



Why build a Current Sensor? What is a Current Sensor? What types are there?

The voltage across two points is easy to measure with a voltmeter/multimeter. If the voltage is changing over time then an oscilloscope can be used too.


The current through a wire is harder to measure; it often entails breaking the wire and attaching an ammeter/multimeter set to measure current. If the current is changing over time then one way to observe this is to insert a fixed value resistor in series with the wire, so that a potential difference (voltage) is created across the resistor. The voltage will be directly proportional to the current flowing through the resistor, and so then the problem has been reduced to one of observing a voltage which is easy to do with an oscilloscope. However, by adding a resistor the circuit has been modified slightly. To minimise this, the resistor is usually chosen to have a very low value. But if the value is too low then the measured voltage will be very low too.


Another issue is that sometimes it is desirable to have a way of measuring current with isolation; this is especially necessary if it is desired to measure current through different parts of the circuit simultaneously using an oscilloscope (the probe ground connections are all connected together and to ground usually).


So, resistors as current sensors can have limitations. Another type of current sensor looks very much like a transformer. It can work very well but usually just for AC signals; a DC component is not detected because there is no change of flux and therefore no voltage induced in the secondary coil.


Yet another type of current sensor is based around a hall effect sensor which detects magnetic fields. It functions from DC to tens or hundreds of kHz. It is primarily used for measuring currents in the tens or hundreds of milliamps and upwards.


Like the hall effect based sensor. a fluxgate magnetometer has the capability to allow the creation of sensors for both AC and DC signals because it measures the magnetic field, not an induced current like a transformer does. Unlike a hall effect sensor, it can be extremely sensitive.


It is possible to purchase current probes for oscilloscopes that are based on the fluxgate magnetometer principle but they cost thousands of pounds/dollars. This project uses a similar principle but only works to a low frequency range of about DC to 30kHz. This could be useful for examining dynamic current consumption of parts of circuitry. It is no useful for examining many modern DC-DC converter circuits however because they operate at very high frequencies nowadays.


This project doesn’t really compare to a commercial current probe for an oscilloscope, because they will function to tens or hundreds of megahertz.

However, this project is far cheaper and still offers some benefits. It has isolation just like a commercial probe. The other main advantage is the very high sensitivity (around 800 volts per amp sensitivity with a simple circuit).


Building the Sensor

As mentioned the fluxgate magnetometer resides on a single chip, so there is no work to do there. It is in a 4x4mm surface mount package (QFN) which is awkward to work with however an evaluation board is available with it pre-soldered. I used that.


To construct the magnetic field, I used a ferrite core; some experimentation here could be useful, I used Amidon FT-50-43 in my tests but others could be used too. Several will need to be purchased because it is almost inevitable that they will be damaged at the next step, the yield is very low. A slot was cut into the core, so that the 4mm fluxgate magnetometer could be a snug fit. With hindsight I didn’t need to cut all the way into the core, just the thickness of the IC would have been sufficient. Anyway, attempting to cut or file the core will almost certainly result in it breaking apart unless lots of care is taken. I couldn’t find a perfect strategy, but 3D printer owners could construct a jig to precisely hold the core during the cutting operation.


Enamelled wire was wound around the core; I picked 40 turns as a ballpark to experiment at, and 0.2mm diameter wire fitted well. A bit of glue can secure the ends from unravelling. The resistance of the coil is about 0.4 ohms, but with slightly thicker wire (which would fit) the resistance can be reduced. 0.3mm diameter wire would halve the resistance for example.



Next, it needs to be secured to the fluxgate magnetometer board. Since I wanted to experiment, I just used blu-tack (temporary putty) for now instead of a permanent glue. Although it looks like it might function poorly with such a trivial attachment, the result is very stable. The measured current does not fluctuate.



Initial Tests

In use, the circuit would be broken at the point where the current needs to be measured, and the ends of the wound coil would be attached into the circuit. For the tests below, it was decided to use a resistor and a signal generator as the circuit under test. The circuit was broken and the current sensor was inserted in. The output of the current sensor went to an oscilloscope. I borrowed an oscilloscope from work for this, it needed the big gun Tektronix MDO3000 so that I could use some advanced math features and waveform processing capabilities to make my life easier.


So, this was the topology:



Although there was no need to connect the signal source to the oscilloscope, it was connected to measure the voltage across the input resistor, to determine how much current was flowing through the current sensor input. For all the traces below, the important trace is the yellow trace which is the output from the current sensor. The blue input trace is just a reference to see what the input signal looked like. For these initial tests, even though the current sensor responds to DC, the oscilloscope was set to AC input because the output has an approximate 2.5V offset. The oscilloscope bandwidth was set to 20MHz for these tests.


All measurements are approximate, since this was just an experimental circuit.


100Hz, 1mA RMS Input current

As an initial test, a low frequency (100Hz) was used. From the measurements at the bottom of the ‘scope display you can see that the input signal was 100mV RMS and the output was around 43mV RMS. Since the input blue trace was measured across a 100 ohm resistor (approximately), that means the current through the resistor was 1mA RMS. The yellow trace shows that the current sensor therefore has a sensitivity of just over 40 volts per amp (i.e. 43mV divided by 1mA).



There is some noise on the output, but that could partially be due to the measurement since it is a low-level signal (43mV RMS) that is being observed.


To examine if the trace could be cleaned up a bit, averaging was turned on in the MDO3000. At a default averaging setting (16 or 32 averages, I need to double-check), this is what the output looked like:



So, for repetitive current draw at around 1mA RMS and at low frequency, it is possible to get a very clean output from this solution.


10kHz, 100uA RMS Input current

As a more extreme test, the frequency was increased to 10kHz, and the current was reduced to 100uA. At this level I would expect the output to be noisier, and perhaps observe some phase difference due to delay between input and output, and see a change in gain perhaps if the frequency response is not flat. Here is the observed result:



With averaging turned on, this was the result:



The output is about 3.9mV RMS which corresponds to a sensitivity of 39 volts per amp. So, compared with the 100Hz 1mA RMS traces earlier, this result shows that the frequency response is fairly flat to at least 10kHz. These measurements were not precise, these are just quick measurements to characterize the behaviour slightly.


Building an Amplifier

By now it was clear that the output benefits from an amplifier to make best use of it. I used an Analog Devices AD8226AD8226, assembled into a 20x gain instrumentation amplifier on a breadboard. There isn’t a lot to the circuit (I’ll draw it up if there is interest), but basically it consists of a 2.7k resistor to set the gain, and a couple of 100nF capacitors for supply decoupling. It was powered from +10V/-10V supplies, and the 2.5V reference output from the DRV425 board was used as the offset input to the amplifier. Some trimming would be useful to completely null out the 2.5V offset, but it was mostly nulled out, enough for me to switch to DC on the oscilloscope, for some of the tests below. For a real design the frequency response of the amplifier should be confirmed to be flat; I didn’t characterise it since it was just a quick hack on a plastic breadboard, and I could always circle back if I saw any anomaly in the subsequent tests.


Tests with the Amplifier

The diagram here shows the test topology:



10kHz, 100uA RMS Input Current

With the amplifier connected, the output was clearer and of course larger. I was no longer in the noise with the oscilloscope gain having to be set at max. I use a 1kohm resistor for this test.

new-10kHz100uARMS - with-amp-1kohm.png


The voltage across the 1kohm resistor is about 100mV RMS according to the blue measurement on the oscilloscope, so that corresponds to 100uA RMS input current. The yellow output is about 81mV RMS which means the sensitivity with the amplifier is 800 volts per amp.


With averaging turned on, the trace was again cleaner as expected:

new-10kHz100uARMS-averaged - with-amp-1kohm.png


I kept the averaging on, and with a square wave input (again at 100kHz, 100uA RMS), the bandwidth effects were apparent, but still a very clean and usable result:

new-10kHz100uARMS-square-averaged - with-amp-100ohm.png


10kHz, 10uA RMS Input Current

Since the results at 100uA RMS were fairly clean and usable provided some averaging was possible, I was curious to see if 10uA RMS was usable too. This is quite a small current draw! To put it in perspective, an AA sized battery (2000mAH) should (self-discharge excluded for this hypothetical experiment) last for 16 years if attached to a circuit drawing 10uA! Here is the result with averaging turned on:

10kHz10uARMS-averaged256 - with-amp-1kohm.png


10kHz, 10mA RMS Input Current

Since the low-level current measurements were not bad, I wanted to explore higher current values. I switched off the averaging and with the input current set to 10mA, I needed to increase the amplifier supply voltage from +10V/-10V to +15V/-15V to stop clipping, and the result is shown here:

10kHz10mARMS-15V - with-amp-100ohm.png



For the limited 1000:1 range of around 10uA to 10mA the circuit functioned well. It allows for fully isolated measurements from DC to 10kHz or beyond. While it would be quite useless for DC-DC converter measurements, it could have uses in developing low power circuits where current in sleep periods needs to be monitored as well as current during wake-up periods.



By experimenting with the winding and amplifier, different current ranges could be implemented. I’d love to see what uses others could find for such a current measurement device with these characteristics.


I really enjoyed experimenting with the fluxgate magnetometer; it is awesome to have such high sensitivity in a low-cost, tiny device. I'm hoping to try non-current-sensing applications with it too.


The big problem with being a maker newbie, is that you have to have equipment.

When I started, I bought soldering kit and a multimerter - things that don't cost allot and are very needful to start your first steps.

But I believe the most important test equipment one need is oscilloscope, but it also very expensive.

So there is a conflict...

Many times you need to debug a circuits because things can go wrong (we all know that...) and you need a scope to figure out what's the problem.

Consider you still in the noob phase, you don't want to spend hundreds of $$$'s just for buying a simple scope


If you could just have a simple cheap one that is good enough for very simple circuits you wouldn't think twice


Now, let's define what is a simple circuit.

For me it has two major parameters

1. Low bandwidth

2. Low voltage, let's say 0-5Volt and if you insist 0-15Volt


I have searched the internet and found many of them, some are better then others, some are complicated to build than others.

I put my eyes on Girinoscope

This scope is using aruino uno (I built my with arduino nano) and reaching 150Ksps with 5V voltage swing.

The problems with the tutorial are:

  1. Its explaining allot of the software and a general knowledge on how a scope trigger works, but:
    1. The info not that well explained to a noob that just want to build it.
    2. There isn't even a simple connections diagram.
    3. You need to deep dive the Atmel documentation to really understand what the tutorial explains.
  2. The provided code needs to have patches to work in max BW (Currently 150kbps).
  3. The GUI provided by 3rd party only visualizing the sample but can't save it for future use.
    1. GUI link:

The Software

The instructables describes how to configure arduino's CSR and you get a pretty good feeling what is happening, but only if you have some knowledge in VLSI and logic design (Muxes, Flipflops, PADs, etc...)

I have tweaked the SW a little bit to support higher sampling rates (code improvements to save MIPS)

I also put the GUI in the same github for ease of access, Also with script to run it from arm CPU (RPI, db410c)

  • main path contains the arduino code
  • capture_exe - perl program to acquire samples that can be saved to a disk (not just watching on the screen)
    • excel can be used to manipulate data and show graphs
  • scope
    • contains the GUI
  • db_src
    • source code for test suites in db410c.
    • RPI can be also used with minor changes.


The Hardware

All you need is an arduino + some resisters and capacitors.

For simple testing purposes I used 555 timer with output swing from 0-5v, calculated the expected frequency and tried to match expectations with result samples.


{gallery} My Gallery Title

Full circuit: Arduino ADC connected to LM358N as input probe. ne555 as the test circuit. ne555 is supplied with 7v rail to rail so the output will be about 5v.

DB410c as tester: I use the 1.8v digital GPIOs on the dragonboard to the arduino ADC. I sometimes using level shifer txs0108e to provide arduino with 5v from DB410c

Girinoscope schematic: From girinoscope intructables it is very hard to tell what to connect where. You need to deep dive the arduino code to understand what to do. This simple schematic can help allot

555 Timer: I use this circuit to see if the calculated frequency of the 555 timer will match what I sample using arduino.

GUI: Acquiring sample from the girinoscope GUI


The probe - Try 1 (not that good, please review try 2)

If I want to cross more than 5 volts I actually need to create a probe.

Special thanks to jc2048 and DAB for helping me navigating the world of opamps (there are thousand of them, and you gotta choose )

I have tried a simple simulation with the MCP6024

Basically I made a 1/4 voltage divider for being able to insert arduino more than 5V.

This is the simulation results:

WAY BETTER THAN LM358N! (See photo gallery for old opamp result)

Vin is square wave 20V@15KHz

You can see output is 4.98V (fair enough for basic scope)

Only thing that worries me is rise and fall time on the max acquired BW (15KHz)



  1. Maybe I need a higher BW op-amp?
    1. Does adding some passive component to the feedback loop will help?
  2. Do I need to add to Vout of the opamp some reverse protection diode to save arduino from human fault?
  3. Why V_rise is slower than V_fall?


The probe - Try 2

  • Red circuit is is Differential amplifier
  • Orange Circuit is voltage offset
    • Since the opamp is 5V we need to offset for half meaning 2.5v
    • By adding 2.5V to to red circuit V+ we get -2.5v:2.5v input only by supplying 5v and GND to the opamp supply.
      • That I understood but could find proper analysis why??? (TODO - find a link to article)
  • Power supply
    • C2,C3 are for noise cancellation of the power supply (power supply decoupling)
  • U2,U3 are only 1:10 multiplier to work on low voltages.
  • C1 - power supply filtering
    • Remove some of the noise coming from the 5V and give a cleaner pseudo ground to work with.
  • R11
    • Isolates any capacitance on the output a little from the op-amp
  • R14
    • Input pit of GND that is connected to GND of the circut
    • Resistor is there to prevent high current from flowing when grounds are uneaven.


Probe schematic

Simulation result

I put square wave of 20v out of 25v.

You can see the output is from 0.5v-4.5v.

T_fall is about 4u_sec which is pretty reasonable. less than 1/7 of the square wave low voltage time...


Pad schematic from atmel datasheet:



I think the next step is to order this opamp

This would probably not happen during this competition period (shipping takes a while where I live)



Hope every noob will find this article:

  1. with full details how to built it
  2. Step by step explainable
  3. Have enough analysis details for understanding without inner assumptions not said.


I want to have a special thanks to jc2048 for helping me allot trying to build the probe.


Proof of work

The following video shows db410c (similar to RPI) generating square wave using one of its GPIOs in 1.8v

Then a level shifter which is design to between-chips communication is used to amplify the signal to 5v

The signal is captured by girinoscope and BitScope Micro Oscilloscope & Analyzer for a reference.

I demonstrates trigger modes and sampling of the square wave by both scopes using girinoscope GUI.


The following video shows the probe detailed in this thread with 1:10 attenuation

Currently the opamp is the only one I have got LM358n which is manufactured around 30 years old, I have extracted it from an old circuit I have.

The opamp output is very noizy, I hope a newer opamp will do a better job (I put this video for proof of work of the probe)

Again caputes of both scopes are provided for a reference.






Too many button clicks

Buttons and tactile switches are frequently used in many projects involving micro controllers; one of the most frequent issue is related to unwanted multiple transitions when the button is pressed once.

Tactile switches as well as push buttons are mechanical components subject to the problem of bouncing. When a button is connected to a digital GPIO input pin (i.e. an Arduino pin configured as INPUT) we ideally expect that when the button is pressed we get only one high signal; unfortunately this rarely happens. During the mechanical movement the physical material vibrates affecting the voltage and the transitions between the On/Off status are not so clear as we usually need. Micro controllers and FPGA are fast enough reading the microseconds oscillations when the button is pressed, resulting multiple transitions while apparently we are pressing the button only once.


Button debouncing

To solve this problems we should apply a button debouncing to reach the goal: pressing a button only one signal should be detected by the micro controller digital input. We can identify two possible approaches: software and hardware.

There are plenty of source examples on how to debounce a button via software; the software approach seems the easiest way but in my opinion this is one of the cases where a hardware solution may be more efficient and resource saving. Micro controllers have memory and resource limits so adding a debouncing routine maybe critical in many cases.


The hardware choice

As I had to add a button debouncer to a test project based on Arduino 101 I decided to make something as much general as possible, easy to adapt to almost any micro controller and possibly platform independent. I figured two possible approaches: RC (resistor-capacitor) method and IC method. The RC option is easier to realise but I am not so confident it can be applied to very different operating conditions (e.g. very different micro controllers types and clock speed). It is not so difficult to calculate the values of resistor and capacitor for a RC debouncing circuit but I see a limitation restricting the application range. The calculation of the RC circuit is  dependent on the voltage of the board used; this means that for different voltage boards (1.8V, 3.3V, 5V etc.) we should provide a different RC calculation.

The RC simple circuit shown in the image below can be calculated with the nice RC Debounce online calculator

Screen Shot 2017-08-11 at 23.58.14.png

The parameters involved in the calculation are:


  • Voltage
  • High logic level
  • Bounce time (ms)
  • Capacitor value
  • Resistor value


The other hardware alternative is adopting a debouncing IC.

There are many specific IC for mechanical contacts debouncing, but they are almost expansive and oriented to manage power buttons while we generally use a push button is to generate a logic signal. The LTC2951CTS8LTC2951CTS8 for example sounds good (not sure if the DIL version is available) with a base price of about 5$.

This is why I decided to move to a general-purpose debounce circuit based on the Vintage NE555. TI provides a wide range of 555 ICs including DIL packaging covering a range supply levels from 1.5V up to 16V; the most common is the DIL package NE555-PNE555-P in the range between 4.5V and 16V. Just what I need, sold at 1/10 (one tenth) of the specialised debouncing ICs average price!


The NE555 circuit

Screen Shot 2017-08-12 at 12.30.10.png

I designed the circuit based on the popular NE555 monostable configuration shown above and detailed in the below schematics:


In this specific case using the two 10uF capacitors connected in parallel to the discharge pin and the 10K resistor for charging we get a timing of about 220 ms. It is a reasonable value to debounce a tactile switch connected to a digital input pin of an Arduino board; changing the values of the capacitors and the resistor we can increase or reduce the charge time resulting a different timing to the output pin (debounced signal.


Wiring the circuit

Using the NE555-P IC the circuit can be powered by the Arduino itself; the images below show the circuit placed as part of the Arduino 101 project where a push button is needed. The small board can also host the designated button making a compact object independent by the platform (an external power source can also be used) involving only the debounced signal connected to the desired GPIO micro controller pin.

IMG_20170801_094225.jpg IMG_20170806_201844.jpg

IMG_20170806_201900.jpg IMG_20170806_201907.jpg

IMG_20170806_202753_008.jpg IMG_20170806_202753_014.jpg

The resulting PCB is about 30x35 mm; I have provided a tactile switch button surface mounted on the opposite side of the components to make easier assembling the module in any project.

LevelingArduino101DebouncingSchematics3D01.PNG LevelingArduino101DebouncingSchematics3D02.PNG

The button in action

The video below shows the debouncer module at work powered by the Arduino 101 and a couple of screenshots showing the stability of the signal



Capture.PNG Capture3.PNG



When I saw Jon's The ByEar 2000, I remembered a Cypress' video showing a construction of an analog alarm and posted that as an comment under his blog post.

PSoCs usually have many integrated analog and digital peripherals, so I thought I could make a compilation of both mentioned projects. I am an amateur, so don't expect scientific explanations or ground-breaking discoveries I only built this device using a CY8CKIT-050 PSoC® 5LP Development Kit, which is obviously an overkill, but the same can be performed using a much small USB stick kit, featuring PSoC 5LP: CY8CKIT-059 PSoC® 5LP Prototyping Kit With Onboard Programmer and Debugger. Please do not consider this as a finished product, but just as a set of ideas for PSoC beginners.

How does it work


Hardware / schematics

Below is the schematics of the whole circuit. I decided to power the circuit by a 3,3 V, meaning it can serve as a programmable logic probe for voltage levels of 3,3 V or lower.

I downloaded a 74LVT125 datasheet to get the LVT families logic levels:

High-level input voltage Vih is supposed to be minimally 2 V.

Low-level input voltage Vil is supposed to be maximally 0,8 V.



Jon has described his circuit very well, so I am just going to list the differences / PSoC 5LP specifics:

  • LogicInput pin is connected to the voltage tested and TonOuput to a buzzer or a speaker.
  • There are two VDAC components and their purpose is to generate a reference voltage for the comparator. These components are programmable in a PSoC 5LP and I have chosen a range of 0 - 4,080 V (16 mV / bit), however, as I am powering the circuit by Vdd = 3,3 V, the maximum reference voltage generated would be Vdd. (The good thing is that PSoC Creator makes you aware of this fact, so it's not a surprise for starting engineers / makers.) One VDAC is set for logic low level 0,8 V and the other for logic high level 2,0 V.

  • VDAC outputs are fed into the inverting inputs of the comparators. Input of the logic probe is fed into both of the comparators, but to the non-inverting inputs. The comparators have to decide then, whether the logic input is lower than Vil (and obviously Vih), between Vil and Vih, or above Vih (and Vil, of course). There is one hypothetical fault condition, that the high voltage level comparator will output a logic high, while the low voltage level comparator will ouput a logic low. I hope this won't happen, but the situation will be taken care of by the sound signaling part of the circuit. By the way, the comparators' synchronization is bypassed, so they don't expect to be clocked.


The rest of the circuit is used to produce a sound output so the user has an idea of the voltage level measured.


  • Two PWM modules are used to create two sounds with a different frequency, one for logic high and one for logic low.


  • As you probably noticed, there is an OR gate mixing both of the PWM outputs together. This was just found by an experiment to create a sound that would differentiate from logic low and logic high sound. This could definitely be done many other ways, using more internal PSoC resources.
  • All the outputs are fed into the multiplexer and the meaning is to provide separate channels with all the possible sound outputs, so only one sound buzzer is needed. (This probably isn't the smartest description of a multiplexer usage, right?) The multiplexer has four inputs, the last is not needed, so I connected it to a logic 0, but this input is never used.
  • The fun part is the control function of the multiplexer. We have two comparator outputs and their output combination tells us in which boundaries is the input voltage. This is where a lookup table (LUT) comes in. It is basically a definition of a discrete function. We have two inputs (4 possible states) and need two outputs for controlling which frequency output will be connected to a buzzer. Here is the definition:

As I mention before, state 0x02 should never happen, but it's output is the same as if the voltage is between the voltage levels of logic low an logic high. This means that the weird sound produced is "not defined voltage level" or "logic probe is broken"



Now comes the easier part, the PSoC code (main.c):


#include "project.h"

int main(void)
    CyGlobalIntEnable; /* Enable global interrupts. */

    // Starts both VDACs
    // Starts both comparators
    // Starts both PWMs
      /* Place your application code here. */


Pretty short, right? I think the device could be put into a sleep mode, but I will leave this as reader's homework.



Here is a screenshot of PSoC 5LP resources used. Please note that the majority of RAM is usually allocated for a stack and heap and can be reduced if not needed.




Using a different PSoC power voltage and different VDAC voltages can be used to adjust the circuit to other voltage levels or needs.

PSoC is very versatile and the circuit can be modified in a countless ways (adding a button to start measurement, one or more LEDs, display, provide some output for testing other circuits ...)


Here is a proof of the working prototype. I used the onboard potentiometer to simulate the input voltage level.



I also attached the project bundle for anyone interested in exploring the design.


For readers willing to experiment more with PSoCs 4 (lower series):

100 Projects in 100 Days

PSoC® 101 Video Tutorial Series: How To Use the ARM® Cortex®-M0 Based PSoC 4 | Cypress Semiconductor