# Conversion of low amplitude sine wave to square wave for PLC

Discussion in 'The Projects Forum' started by piashaw, Jan 23, 2014.

1. ### piashaw Thread Starter New Member

Apr 20, 2013
12
0
Have been looking around for a way to convert a sinewave (minimum pk to pk of 80mV) to a square wave of 0-24V (realistically need above 18V to definitely register a high) for PLC input, maximum input however can be greater than 12V pk to pk. Specs for the anemometer are at
http://www.renewablenrgsystems.com/products/1900.aspx#

Was thinking of using LM393 comparator but don't know if it will trigger at such low signal strength. Frequency will be between 1Hz to 200Hz and then how to protect it with the higher peak to peak voltages.

I would run the circuit from a +24V DC supply.

Most circuits show it using the inverting input. Why is this? I would prefer to use the non-inverting.

Many thanks

2. ### ericgibbs AAC Fanatic!

Jan 29, 2010
2,590
390
hi,
Do you require the square wave to have 50/50 mark/space.?
Also is required to be thru zero voltage detect on the sinewave input.?

The 80mV should not be a problem for the LM393, but it is also possible to use one half of the LM393 as a low frequency amplifier, using the 2nd half as a comparator.

Many apps require the output sense to be the same as the input sense to the LM393 , thats why non inverting is used.
E

3. ### piashaw Thread Starter New Member

Apr 20, 2013
12
0
Thanks Eric.

I need to measure frequency in the PLC on an interrupt, so i only need to work on a rising or falling edge, so mark/space ratio is irrelevant. As is zero voltage detect in this particular requirement.

I agree with the non-inverting preference, just happens that many of teh circuits i saw use the inverting for some reason.

Regards
P

4. ### ericgibbs AAC Fanatic!

Jan 29, 2010
2,590
390
hi P,
Do you have a draft circuit you could post,? I could run a LTSpice simulation for you.
E

5. ### piashaw Thread Starter New Member

Apr 20, 2013
12
0
Not yet. Thanks for the offer.

I was just trying to find out if the comparator for this simple conversion were the best or if I should go with a trigger or just using Transistors.

Not certain how to cope with such a wide input pk to pk voltage range.

I was slightly incorrect in my statement about using rising or falling edges, basically I will count when the PLC input is a HIGH or a LOW. The actual duration in whichever state is irrelevant to me.

P

6. ### ericgibbs AAC Fanatic!

Jan 29, 2010
2,590
390
hi P,
A LM393 would be easier to build IMO rather than using transistors, a LM393 is about 20p UK.
The LM393 will have no problem with a 80mV signal.

E.

Jul 22, 2009
65
15
8. ### Alec_t AAC Fanatic!

Sep 17, 2013
5,971
1,135
The max signal input of the 393 is quoted as 36V and can exceed the supply voltage, so you should be ok.

9. ### piashaw Thread Starter New Member

Apr 20, 2013
12
0

Do you reckon there is any point in using the first half as pre amplifier?

10. ### ericgibbs AAC Fanatic!

Jan 29, 2010
2,590
390
hi P,
Look at these two options.
E

File size:
42.4 KB
Views:
61
File size:
21.5 KB
Views:
33
• ###### AAesp05.gif
File size:
44.9 KB
Views:
67

Jul 18, 2013
10,838
2,512
The link for the Anemometer also shows a signal conditioning add on, it doesn't appear to show the nature of the output, will this be of any use to condition the signal for your PLC?
I assume this is a PLC in the industrial sense (not microcontroller), some will have the option of rising edge detection for counting purposes.
Max.

12. ### piashaw Thread Starter New Member

Apr 20, 2013
12
0
Thanks Eric, very interesting.

My electronics is somewhat rusty as I haven't used it since the mid 80's properly......

Why do I need the Vref, as opposed to just using Ground?
How does one define the correct vref for different input voltages? Or does it not change?

I am looking at the circuit just using a comparator rather than a preamp followed by a comparator.

Thanks

Peter

13. ### piashaw Thread Starter New Member

Apr 20, 2013
12
0
Yes it is an industrial PLC.

The add-on only goes up to 15V MAX output.

Trying to resolve an issue where the wrong anemometer has been used. Had a 40H (Hall effect ) version been bought, I wouldn't have to be trying to resolve this.

P

14. ### ericgibbs AAC Fanatic!

Jan 29, 2010
2,590
390
hi Peter.
A LM393 can have either a negative or positive 'self offset', so its advisable to fix a defined Vref threshold voltage for the comparator.

The Vref is set to about +20mV, it should stay at this value, so every time the input signal rises above +20mV the comp will switch, whatever the amplitude of the input signal.

I am assuming from from your first post that the 80mVppk swings thru 0V.
ie: +/-40mVpk.
E

15. ### piashaw Thread Starter New Member

Apr 20, 2013
12
0
Yes it is a self generating sinewave from magnets, so yes fluctiation +-40mV.

Ah now I understand the purpose of the Vref.

In my case, as it is crossing zero, what benefit do I have of defining the vref rather than not caring about the internal offset and tying it to ground (0V)? (Unless the offset is likely to be close to or greater than the peak of the signal.)

If you set a Vref manually, do you have to take the Internal offset into account at all or will you get exactly the Vref you set?

For my reference, do they define they tell you the maximum possible offset in the datasheet and if so, what do I look for?
Is it "Low Input Offset Voltage: 5.0 mV (max) LM293/393"

Thanks

P

Last edited: Jan 23, 2014

Jul 18, 2013
10,838
2,512
I may be off on this, but wouldn't simple half wave rectification do it?
Then just Schmidt trigger the output up?
Max.

17. ### Alec_t AAC Fanatic!

Sep 17, 2013
5,971
1,135
If the input signal goes below ground you will need to limit it, or offset it, so that the '393 input pin doesn't go below -0.3V (the rated minimum).

18. ### vk6zgo Active Member

Jul 21, 2012
677
85
Retro-style would be to just amplify it & put it through a bi-directional clipper circuit -----An overdriven amplifier,going into saturation at one extreme,& cutoff at the other would do it!