I need to implement a frequency counter (pulses per minute) of a DC circuit that goes up to 20 volts. A little background, I am building a linear power supply 0-20 volts, 0-3 amps for my relative who is a tattoo artist. He wants me to help him build the supply but he has the need to know what frequency the tattoo machine (just a basic doorbell circuit) is operating at. His specialty tattoo machine power supply has this feature and I guess it's helpful for something.

I have found several schematics for DIY frequency counters, I really like the Weeder Tech auto-ranging unit but I cannot figure out a reliable way to interface one with a DC power supply. I have looked into preamp circuits for low voltage signals, but that still presents a question about feeding it up to 20 volts. I am quite certain the full 20 volts will fry the IC's, and honestly I am uncertain if it'll even measure DC pulses because of the capacitors in the signal path of the frequency counter. I have looked into Hall effect current sensors, Zener diodes, voltage dividers and all of that, but I'm lost as to how to simply count how many times a second the circuit is closed by the machine and providing current. I just need a low cost reliable way of making a 0-20 volt DC circuit a logic level signal. Even if it was as simple as an IC or op amp that would go high when any current is flowing, that would seem perfect.

I know this is a rather odd request as usually only AC is interesting frequency wise, but really appreciate any help in finding a solution to this one.

  • \$\begingroup\$ Is it correct, the supply will provide a constant 20 V, but the machine will need current in pulses several times per second? Do you know about how much current is drawn during a pulse, and how much during the "off" time? Do you know the rough range of frequency you need to measure? \$\endgroup\$
    – The Photon
    Jan 4, 2012 at 5:30
  • \$\begingroup\$ @ThePhoton: I'm not sure what tdx means by "doorbell circuit", but I think of a device similar to this one: horst-ries.de/Sites/hobby/Elektrisches/Funkeninduktor/Images/… (basically a electrical magnet which attracts a lever and opens an electrical contact this way switching itself off and allowing the lever to swing back and close the circuit. In german this device is know as a "Wagnerscher Hammer". The current would be all over the place, since an inductance is switched several times per second. \$\endgroup\$
    – 0x6d64
    Jan 4, 2012 at 10:42
  • \$\begingroup\$ If something is DC then there are no pulses and the frequency is 0. If you are using a linear power supply, I am not sure where the pulses would come from. What am I missing? \$\endgroup\$
    – Kellenjb
    Jan 4, 2012 at 14:24
  • \$\begingroup\$ @Kellenjb: If the device is similar to the one linked in my comment above then it will switch a coil repeatedly on and off with a frequency depending on the mechanical properties of a oscillating lever. \$\endgroup\$
    – 0x6d64
    Jan 4, 2012 at 15:35
  • \$\begingroup\$ The power supply is linear, however the load uses electromagnets with points to make and break the connection. This will be happening between 50 - 200 times per minute, and varies by the individual machine attached. I'm wanting to capture how many times per minute current flow starts and stops. \$\endgroup\$
    – tdx
    Jan 4, 2012 at 15:42

4 Answers 4


Maxim has an app note showing how to use their high-side current sensor parts. They also show a basic op-amp circuit as the "traditional" way to do this measurement, and this is probably good enough for your application:

Current monitor circuit

The output from this circuit could be run to a comparator to generate a digital '1' whenever the pulse is "on" and a '0' when the pulse is off. Some low-pass filtering may be required between the sensor circuit and the comparator if there is bounce or noise during the on and off transitions of the current pulse.

Then you have some choices.

In a simple digital logic solution, using probably a fairly modest CPLD, the digital pulse could clock a counter. The size (number of bits) of the counter depends on the maximum frequency you want to measure. A clock circuit would be needed to generate a pulse every 7.5 seconds. The 7.5-second pulse would be used to latch the counter output into a second register, while simultaneously resetting the counter. Some additional refinement would be desirable to avoid latching the counter output while it is the middle of rippling up the result of a newly arrived pulse from the comparator. The latched register, multiplied by 8 (left shifted by 3) would give the pulses-per-minute in the previous 7.5 second interval.

The digital pulse could be input to a microcontroller to count pulses and output how many pulses were seen in the past 7.5 seconds (multiplied by 8 to get pulses per minute). Or, count how many seconds are needed before you receive maybe 10 pulses from the comparator. The micro is more flexible than the CPLD in terms of letting you vary the counting interval depending on the actual frequency, averaging over multiple periods to get a smoother display, being able to change the units of the display, etc., etc.

How you display the output is up to you.

  • \$\begingroup\$ An opamp is something I looked at but the current sensing amplifier is also interesting and might be a possible solution. However if I need to be able to measure a circuit that will supply up to 20 volts and 3 amps that would mean I need a current sense resistor that can handle 60 watts correct? \$\endgroup\$
    – tdx
    Jan 4, 2012 at 15:45
  • \$\begingroup\$ @tdx: No. Your sense resistor will have a voltage drop of far less than 20V (if the voltage drop over the sense resistor gets to high, it influences the operation of the circuit which it is supposed to measure). Sense resistors usually have a voltage drop of a few mV, and therefore an opamp is needed to amplify the output to a usable level. Have a look at the app note from maxim (link in The Photon's post), it contains a few words about "Considerations When Selecting Rsense". \$\endgroup\$
    – 0x6d64
    Jan 4, 2012 at 15:58
  • \$\begingroup\$ That makes sense. And actually the power supply I'm building will have a 0.47R 10w resistor on the ground that it uses for its own voltage and current reference & regulation, it would be just as well to use that for a low-side current amplifier correct? The voltmeter I'm integrating uses that resistor, so it shouldn't be a problem tacking on current sense opamp should it? \$\endgroup\$
    – tdx
    Jan 4, 2012 at 19:02
  • \$\begingroup\$ If all the current from the load flows through the .47 Ohm resistor, and no other current does (or any other current is much smaller), then you should be able to use this as a sense resistor also. Beware, though, of adding extra capacitance on the feedback node of a linear regulator. If you're not sure, please post a schematic, because I'm not entirely clear how your .47 Ohm resistor is connected. \$\endgroup\$
    – The Photon
    Jan 4, 2012 at 22:11
  • \$\begingroup\$ Here is the schematic for the power supply. R7 at the bottom right on the ground is the .47R current sense resistor for the power supply. I am also going to add a AVR based volt/ammeter which was designed with this power power supply in mind and shares the current sense resistor for itself, but I don't believe there should be much added capacitance as the only a few resistors lie between the power supply output and the AVR IC. \$\endgroup\$
    – tdx
    Jan 5, 2012 at 0:26

If you only need to measure the frequency a couple of times, I would recommend using an oscilloscope rather than a frequency counter. Odds are that you have one (or can borrow one), and it doesn't require you to build or buy any special circuit that is only useful for one thing.

Alternatively, some higher end digital multimeters have a frequency mode.

But let's say that you really do need a dedicated frequency meter. In that case, I still suggest starting out with an o-scope. Look at the signal you want to measure, then take a picture or screen capture. Post that picture here, along with a link to the frequency counter that you want to use, and then we'll be able to help you with interfacing the two.


Tattoo Machine Single Operation Cycle:

Power applied, by the power supply, to the negative terminal top post and the positive terminal lower binding post of the support structure (frame). The first and the second electromagnetic coils are charging ,to form an electromagnetic field. The armature bar is pulled down, by the electromagnetic field,towards the coils. Pushing the needle bar and thus the tattoo needleset in a downward motion as a down stroke. The front spring bends downwards,losing contact with the contact screw. Thus the circuit opens.The coils cease to charge. The magnetic field collapses. A brief kickback current spike is induced. Some of it's charge is withheld and stored by the capacitor. Capacitor then discharges,re-energising briefly the coils. Armature bar is at the lowest position. The armature bar forced by the tension of the back/rear spring returns to it's 'rest' position. Needleset is moving off the skin upwards. The front spring contacts the contact screw. Circuit closes ,thus coils are charging again.

Assuming that the footswitch is continuously pressed down,that leads to the fact that there's going to be a stable (ideally) voltage dynamic difference between both ends of clipcord.

Simply put ,as long the footswitch is pressed , there's always voltage at the clipcord, thus also at the binding posts of a tattoo machine , where the clipcord is attached to . There's is not a "switching on & off state", of the tattoo coil machine that can be measured along the clipcord ends.

When the contact screw is in contact with front spring, el. current flows through the coils, producing a magnetic field around them. When the coils charge and pull the armature bar downwards, it's contact with the contact screw open, interrupting current through the coils and causing the magnetic field to rapidly collapse.

Because the voltage induced in a coil of wire is directly proportional to the rate of change over time of magnetic flux (Faraday's Law: e = NdΦ/dt), this rapid collapse of magnetism around the coil produces a high voltage “spike”.The contacts (contact screw & front spring ),will get excessive arcing at them, which greatly reduces their service life.

Either a "surge capacitor " or a " commutating diode " , has to be tied parallel to contacts ,to mediate this phenomenon. Because of the faster ' absorption ' rather than 'dissipation ' of capacitors and the “time delay” of coil de-energization that diodes induce , usually capacitors are used in mediating 'kickback' spikes of a coil tattoo machine , instead of diodes.

In order for the operational frequency and duty cycle to be measured, a sensing device or mechanism must be " tied " ( connected ) at the very same place , where the actual mechanical switching of the coils is taking place . At the front spring's "contact screw " .

There are other ways to sense operational variables ,also. Like by measuring the characteristics of the 'kickback' current spikes, induced by the collapsing magnetic field of coils , when front spring loses contact with the "contact screw ' . But while from spike to spike is a full cycle ,making frequency measuring
quite precise ,measuring the actual duty cycle time duration might prove somewhat
relative and prone to alterations from various interferences , that could cause enough declinations / fluctuations, between measured and actual values. So this method was avoided,although being more "convenient" as it does not need an external extra sensor wire,but offers rather reduced Duty Cycle measurement precision,also . Another way is measuring the power line current fluctuctions. But in that method also,measurements with serious declinations from actual values , may be obtained, mainly due to the fact that charging of coils is not linear, ( and there's also other unknown variables ,such as spike rising time & fall time.) thus monitoring precisely the current running through power lines , might prove quite tricky to translate onto precise Frequency and Duty Cycle figures. Moreover a more complex & sensitive sensoring circuitry, of rather higher cost is needed (Hall effect sensoring ). While still being somewhat prone to any kind of E/M interference.

Contact screw sensor circuitry :

When the Front Spring contacts the Contact Screw:

Coils are charging.The "HIGH" duration depends mostly on the deflection caused by the rear / back spring.

The higher deflection of the back spring , the longer the front spring will remain in contact with the contact screw. The longer the coils will charge. The higher the velocity with which , the needles will pop in & out of the skin. Needle stays off the skin most of the time of a cycle,while popping in and out ,quite 'clean' (with high velocity).

The opposite happens with low back spring deflection. Needle will stay longer inside skin ,penetrating it with " dull " punctures of low velocity . Excessive bleeding might occur,especially with a 'fast working hand '. Healing times are quite prolonged.

While coils are charging ,no current runs through the sensor wire . (Due to sensor's high input impedance and coil's large current draw ). Sensor 'reads' a "LOW" signal,when actually the machine state is "HIGH" ( coils charging).

When the Front Spring loses contact with the Contact Screw: Magnetic field is collapsing. A brief (rapid) current spike 'kicks back", onto the power lines. Some of the spike kickback current gets" absorbed " by the tattoo machine capacitor.

( Which in turn, will discharge keeping the coils "active" , thus holding the armature bar briefly "stuck" with the front coil's core. The bigger the capacitor ,the longer the armature bar will stay -briefly- "stuck" at the front coil's core).

Since the footswitch is still pressed down,and there's voltage at the clipcord ends , but there's no closed-circuit charging the coils ,at this point a current flows along the sensor line. Meaning that while the machine state is "LOW" ,the sensor reads "HIGH".

So ,there's an OPTICAL COUPLING LOGIC GATE INVERTER circuit involved ,in order to invert the sensor's input signal [ Rxi ]* , for it's output signal [Txo]** to match the state of the tattoo machine, while optically (and not electrically ) "coupling " the received signals, with the transmitted- and inverted- output signals, going into the microcontroller's dedicated input. Ensuring 100% noiseless signal transmission and precise measurements.

Turn- On & Turn-Off delays of the
OPTICAL COUPLING LOGIC GATE INVERTER Circuitry, have been taken into consideration also ,while calculating HIGH/LOW values. Even if they are falling in the range of just a few millionths of a second! In order to achieve as higher level of measurement precision,as possible .

My hard guess: Use an optocoupler (I.e 4N33 ) with a 10 K res and a protection diode at it's led inputs and an 'inverter' output circuitry,to feed a "high" pulse or "low" pulse signal ,onto a microcontroller's input . Then you'll need some sort of software routine,counting the period and width of each pulse,averaging and displaying the results in a display of some sort.


And something more about tattooing and power supply choice.

While Linear Power Supplies /Regulators offer less output DC ripple noise than the switching ones.

(Dual coil Tattoo machines are way sensitive to electrical noise.High Frequency AC noise causes overheating of coils,due to high Equiv.Series Resistance of coils to high frequency AC. DC ripple noise will affect the 'smooth' operation of a tattoo machines,as also abnormal & periodical arcing,might occur at the contact of front spring with contact screw.)

From the other hand their linear regulating ICs "cut -off "-protection- if kickback spike voltages are high enough ,as the difference between Vin & Vout ,gets way out of operational range. A tattoo machine is an inductive load. Not an easy one ,for linear Voltage Regulators. So a high frequency tattoo machine or a high-voltage operating one ,might cause trouble. A 'pass transistor ' parallel to Linear regulating ICs ,will solve out any problem like that.Prefer High Amperage ICs. Like LM 350 instead of LM317.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.