High Voltage AC Sensor To Arduino

Mk1_Oz:
Thanks for taking the time to draw that up.!

No problem. Took a few minutes maybe, including posting it here. Just a quick sketch.

The way my sensor works is that at low engine RPM it outputs a sine wave at low voltage (say +/-4v peaks) but at high RPM those peaks are close to +/-50v. Although the voltage divider will reduce the 50v to 4.55v will it not reduce the 4v to something like 0.35v?

Here is the thing about sine waves: the peak is a lot higher than the average. If you're measuring mains voltage, you see 220V on your multimeter, yet the peaks of that voltage are at about 360V. For your system it works the same, so if you say 4V is that the average or is that peak?

Also this isn't s square wave output to the Arduino?

No - this will be a very constant voltage, no peaks, and the voltage you get out is the peak voltage rather than the average. So you can put in 4V AC and get out about 6V DC. So before hooking this up to your Arduino you really should take a multimeter and measure what voltages you get across the capacitor.

This way you can measure the voltage without having to worry about waveforms, as you said your voltage is a direct measure for the RPM so this sounds like the simplest way of doing this.

If you really want square wave output, you gt a different circuit. I think you'd best use an OpAmp for that. Use the voltage divider/zener combo as above to protect the input of the OpAmp, and let it produce a square wave. The output will be a wave between 0V and 5V, regardless of the input voltage. Use a circuit like this if what you're after is the frequency of the signal. This you can measure using a pulseIn() call (measure the duration of a single pulse - for low frequency signals) or by counting the number of waves for a period of time using an interrupt.

My 4v i mentioned is the peak figures (+/-) as is the 50v figure.

Right. Using the sine wave signal as a frequency from which to drive RPM is what u want.

My understanding is that an op-amp becomes a schmitt trigger by adding a few resistors that determine the upper and lower voltage on/off points. Using your zener bits to limit the voltage in (ie limit my max of +50v peak) to the op-amp to whatever it can handle is great. At low RPM when the sensor output is around 4v peak the zener bits probably wont be needed. I guess this will also remove the negative part of the sine wave which is surplus to my needs anyway.

Ok i am starting to get somewhere.

Not being very good at this stuff i wish there was an off the shelf part to just make this all happen! !!

The zener just won't do anything at the 4V levels, it's protection. You still need a resistor between the input signal and the zener. I'm sure there are folk here with much more experience with OpAmps that can suggest specific circuits, or do a Google search for this.

Basically you wire the OpAmp as comparator, so whenever the voltage of your signal is the slightest bit (in practice a few mV) above your reference (could be GND), the output will be at Vcc.

It still looks like you are barking up the wrong tree. Get a sensor which works at the Arduino's voltage to begin with. Hall effect or proximity sensors are perfect for this.

If it is a reasonably modern car with OBD2 then plug into that and use the engine's own sensors.

No barking. Using what i have already. I know a hall effect sensor would be better but i don't have one installed on this engine. Only an induction sensor. Very old car. ....

I have spent slot of time looking into schmitt triggers and they appear to be my immediate solution. One thing i have not been able to work out (most tutorials are pegged at a higher knowledge level than mine) is what is connected to the +Vcc and -Vcc points. The attached pic seems reasonably standard. On the triangle V2 is my ac sine wave and V1is ground. Rdiv1 and Rdiv2 take care of the upper and lower trigger points. The output is the output (i want +5v or 0v). But what is +Vcc and -Vee. Is this a +5v input and ground ie that gets outputed as the square wave? Sorry to be stupid.....

Schmitt-Trigger-Using-Op-Amp-741IC-1.jpg

The negative rail is often connected to GND for single supplies. See this page for examples.

my head is spinning

If you put the tachogenerator signal through a series resistor through a pair of back-to-back diodes you'll
get a nice 1.2V peak to peak signal whose voltage is relatively insensitive to the speed. Try 10k or so.

This diode clipping circuit is commonly used for limiting voltage of an ac signal or protecting an input.

Very nice solution indeed.

MarkT:
If you put the tachogenerator signal through a series resistor through a pair of back-to-back diodes you'll
get a nice 1.2V peak to peak signal whose voltage is relatively insensitive to the speed. Try 10k or so.

You blokes amaze me! Nice.

This solution will give a ramp from zero volts up to the clip level. How will an Arduino react to this on a digital pin? Will it read the value as low until it reaches some value over 2.5v at which time it will set to high? Not sure if the Arduino (Uno or Mega) needs a definite 0 or 5v on a digital pin or whether a slightly varying voltage, as provided by your soltion, will still work? If your method is suitable then I guess I just vary the resistor size to clip the voltage at between 2.5 and 5v?

If a square wave output is better for the Arduino then I could incorporate both ideas. I could use your clipping circuit to limit my AC voltage (currently up to say +/-50v) to something that a Schmitt Trigger could handle (I was led to believe above that a ST would not be able to handle 50v). That output could then be processed by a ST to convert it to a square wave at trigger points set by me by varying the resistor values. Does that sound reasonable?

A couple fo specific questions:

  1. What type of diode for the clipping? Do diodes come in different sizes as do resistors and caps? (sorry...I am very new...)

  2. To make a ST do I just buy a ST chip and add the resistors to make my own complete unit? There has been mention of starting with an op-amp but I have only found bare bones chips not nice complete boards. Any links to parts gratefully accepted lol

Mk1_Oz:
This solution will give a ramp from zero volts up to the clip level. How will an Arduino react to this on a digital pin?

At the 0.7V level it will not react. It needs 2.5-3V to detect high (see data sheet for details on this, if you're interested). This signal is best passed into a Schmidt trigger to make it a 0/+5V signal.

The resistor value is purely to limit current, as a diode has a fixed voltage drop that varies little with current. So the actual resistor value doesn't change how much voltage you get out, it could in principle be any value but low values mean higher current. You want to keep this current low to not affect the sensor, and to prevent heat from building up and so. That's why 10k, but a higher value or a bit lower will do as well. Whatever you have on hand.

  1. What type of diode for the clipping? Do diodes come in different sizes as do resistors and caps? (sorry...I am very new...)

Different sizes - for power/breakdown (reverse) voltage rating.
Different values - not so much (well, there are zener and Schottky diodes - look them up - which have different applications).
Voltage drop over diodes is pretty much the same for all of them, 0.6-0.7V.
A standard 1N4002 will do, or a higher value (1N4003..7) The 2 goes to 100V, the 7 to 1000V reverse breakdown. At 10k resistor value you get just a few mA so no need for high power rating.

  1. To make a ST do I just buy a ST chip and add the resistors to make my own complete unit? There has been mention of starting with an op-amp but I have only found bare bones chips not nice complete boards. Any links to parts gratefully accepted lol

OpAmps usually come in DIP or other solderable package. DIP is very nice for experimenting - do get a solderless breadboard and a set of jumper wires. Makes experimenting a lot easier. Then get some protoboards to build finished projects, so you can properly build it into something.

A Schmidt trigger is normally based on an OpAmp indeed. Very easy to build, just a few external components.

Cool. I think I know enought o get started and do some damage!!!

Is there any decent (and free) electronics simulation software available that could assist me before I blow up components for real? I saw one called 123D Circuits.io but know nothing about it.

Been playing with circuits all arvo. Is it possible to have a non-inverting asymmetric schmitt trigger using an op-amp? I cannot find a reference to this, only to an inverting asymmetric.

Firstly, deepest apologies for posting three items in a row. Don't mean to spam my own thread but I keep having questions as I have been sitting here for around 6 hours straight nutting this out!

I have designed the attached circuit on some software called CircuitLab (a random find). It is based on the help provided in this thread so far. Rather than clip the negative part of the sine wave, I have clipped off the positive. This is solely because I need teh square wave to be positive (high) and this is the only way I could get it to work. I didn't have much luck with non-inverting schmitt triggers. It works........almost!

I have used a clipping circuit that outputs to an inverting schmitt trigger. To be honest my resistor values were complete guesses. I have outputed what the software shows as a simulation based on a 1Hz sine wave that has 8v peak to peak (this simulates the approximate idle speed of the engine on which I will be measuring the RPM). I have run it with a 100v peak to peak and it output the same (that's good). Not sure if simulation software highlights if components are overstressed or not. The clipping diode shown has an output of 3.9v whcih still clips at the low idle speed.

The issues;

  • the square wave output is just over 5v (5.089v). This may be an issue for the Arduino but I do not know how to reduce it. My only thought is to add another zener diode on the output to clip the voltage to 5v or just under.
  • the square wave goes high when the sine wave is a fraction under 0v (around -0.002v) which is fine. However, it then goes low at just over 0v (+0.002v) which is not fine. The actual sine wave I will receive is not continual i.e. it will have a positive peak, negative peak then 0v for a period of time before another set of peaks. Having the square wave go low at over 0v means it will stay positive until the next set of peaks arrives. I guess this isn't technically an issue as I will be telling the Arduino to read the rising edge but it just feels messy. I would rather the square wave goes low at the same voltage point as it went high i.e. just under 0v. Is that possible?

I have tried many times to calculate the trigger points but I never seem to get it to match the simulation (I am of course trusting the simulation is working correctly!!!!!!!)

  1. No problem at all.

  2. You need some hysteresis. Small variations around zero should not trigger a change. The Schmitt trigger should do that. If it isn't then there is something wrong.

  1. Fine for Arduino, it's rated for up to 5.5V. But your output voltage can never be more than the Vcc provided to the OpAmp. If you see anything above 5V (I assume you set Vcc to 5V) then that's a rounding error in CircuitLab's math.

  2. Some hysteresis is good indeed. You may even want a bit more than that - your 0V is never going to be exactly 0V (theres LOTS of RF noise in cars, especially older ones). As long as your signal is symmetrical, hysteresis will simply delay your square wave a little compared to the input sine wave. The wavelength remains the same.

Do look a bit into hysteresis, you can easily find some graphs that show you how it works, and how it won't change the duration of peaks for symmetrical signals.

Changed a few things....

I have now clipped both the +ve and the -ve of the sine wave and added a bias voltage to both.

The switching points are still 0v (set high) and just over 0v (set low) and I just cannot get this to change for some reason. I have read alot about hysterisis and think I understand the theory....putting it into proactice is harder for me :frowning: Feel free to change my circuit if you can work out how to make that change!!!

I bought parts this arvo so will see if I can produce the magic smoke tomorrow :(:frowning:

I know this is an old topic, but there's a chip especially designed for your purpose, look up the Maxim MAX9924, it can operate on signals from millivolts up to 100's of volts and adapts automatically and has zero-crossing detection so you have accurate timing points

Did you ever get your thing going?

1 Like

Thanks for the reply.

I played around for quite some time but ultimately dropped this part of the project. I wanted to try to use this particular sensor as it was what I had but since using hall effect sensors for other things I will just use one of them if ever I get back to the project.