Circuit to detect a modified sinewave

  • Thread starter KHinMS
  • Start date
  • #1
KHinMS
I wander if yo guys can point me in the right direction here. I need to design a circuit that will differentiate a modified sine wave from a pure sine wave.

What I am trying to do here, is design a circuit that will sense when mains is lost and a UPS takes over by monitoring the waveform of the input voltage.

I may be going in the wrong direction, but I have been trying to sense the rise created in the modified sine wave, and feed that pulse into a monostable multivibrator to extend the pulse which will eventually be fed into a arduino as a digital high.

Thanks in advance.
 

Answers and Replies

  • #2
NascentOxygen
Staff Emeritus
Science Advisor
9,244
1,072
A shortcoming of sensing sharper rises is that it is going to be tripped erratically by noise coming in on the mains. If someone starts up an electric drill the monostable may be almost continuously triggered. Is this just a visual display you are wanting, so erratic blinking could be disregarded?
 
  • #3
KHinMS
A shortcoming of sensing sharper rises is that it is going to be tripped erratically by noise coming in on the mains. Is this just a visual display you are wanting, so erratic blinking could be disregarded?
No, not visual. But I could introduce a delay, so that the pulse had to be present for a prolonged period before the event is triggered.
 
  • #4
NascentOxygen
Staff Emeritus
Science Advisor
9,244
1,072
A more reliable way may be to filter and detect one or more of the AC supply harmonics, the distorted wave having consistent significant harmonic content.
 
  • Like
Likes Borek, jim hardy and Asymptotic
  • #5
779
526
design a circuit that will sense when mains is lost and a UPS takes over
Unless you need very fast response - less than the time required to switch a mechanical relay - you could use a pair of 120 VAC control relays (or whatever the mains/UPS AC voltage is).

If only a single digital input is available on the arduino a set of contacts from each would be placed in series, normally closed on the mains-sensing relay, and normally open on the UPS-sensing relay. When mains voltage is available the mains-sensing relay contact is open; when mains is lost, it closes, and (provided the UPS-sensing relay is turned on) will set the digital input true.

If two digital inputs are available, both mains and UPS sense relays could be evaluated separately, and (provided the arduino is powered from another source) could be programmed to detect both mains and UPS loss.
 
  • Like
Likes rbelli1
  • #6
KHinMS
Unless you need very fast response - less than the time required to switch a mechanical relay - you could use a pair of 120 VAC control relays (or whatever the mains/UPS AC voltage is).

If only a single digital input is available on the arduino a set of contacts from each would be placed in series, normally closed on the mains-sensing relay, and normally open on the UPS-sensing relay. When mains voltage is available the mains-sensing relay contact is open; when mains is lost, it closes, and (provided the UPS-sensing relay is turned on) will set the digital input true.

If two digital inputs are available, both mains and UPS sense relays could be evaluated separately, and (provided the arduino is powered from another source) could be programmed to detect both mains and UPS loss.
I understand what you are getting at. The mains and the UPS are each sensed independently. Unfortunately, I need to sample the supply from a single point and differentiate.
 
  • #7
rbelli1
Gold Member
965
365
Most UPS systems will include a method of detecting when they are active. They also usually have a battery low indication that may prove useful.

If you can't use that or it is not available then @Asymptotic's suggestion seems to be the easiest solution. There are other methods using an optical or galvanic isolation or simpler means to achieve the same function.

BoB
 
  • Like
Likes Asymptotic
  • #8
rbelli1
Gold Member
965
365
I need to sample the supply from a single point and differentiate.
What sort of horsepower do you have available in your CPU? you could sample the waveform and do some FFT. The modified sine will likely have a bunch of sharp harmonics where many types of interference will have a more continuous spectrum. I would be very reluctant to base any even safety adjacent functions on this approach.

BoB
 
  • Like
Likes donpacino and Asymptotic
  • #9
779
526
I understand what you are getting at. The mains and the UPS are each sensed independently. Unfortunately, I need to sample the supply from a single point and differentiate.
Then an approach along the lines of @NascentOxygen and @rbelli1 may be necessary, along with his safety caveat.

It might seem odd, but another approach to remote detection could be to do the mains/UPS sensing at the UPS, and adapt something along the line of X-10 devices to transmit this information to the arduino location.
 
  • Like
Likes rbelli1
  • #10
KHinMS
No, safety is in no way dependent upon this solution.

Basically, this is for my senior project. I had to think of a problem and then build a solution. So, I am building a device that monitors the input power to a piece of equipment and relays UPS state via ethernet. It does a couple of other things also, that I have already figured out, so not important here.

The equipment will plug into this device, and this device plugs into the UPS. So, power is sampled and the arduino is powered before the power is routed to the equipment.

One thing that is really slowing me down, is that I have no way to simulate a modified waveform. I am using multisim, and I can simulate a pure sine wave and a square wave, or even a pulse, but not a modified sine wave..
 
  • #11
donpacino
Gold Member
1,439
282
I wander if yo guys can point me in the right direction here. I need to design a circuit that will differentiate a modified sine wave from a pure sine wave.

What I am trying to do here, is design a circuit that will sense when mains is lost and a UPS takes over by monitoring the waveform of the input voltage.

I may be going in the wrong direction, but I have been trying to sense the rise created in the modified sine wave, and feed that pulse into a monostable multivibrator to extend the pulse which will eventually be fed into a arduino as a digital high.

Thanks in advance.
How modified is modified?
Are we talking about a slight difference? or a triangle wave?
 
  • #12
donpacino
Gold Member
1,439
282
You could implement a notch filter around the sine frequency, then amplify it. This would only amplify signals not of the sine wave's frequency. Average the voltage over your desired time constant, then compare it to your acceptable limit.

Note: You might want to decrease and isolate the voltage first and this will only solve your modified sine wave problem.
 
Last edited:
  • #13
donpacino
Gold Member
1,439
282
One thing that is really slowing me down, is that I have no way to simulate a modified waveform. I am using multisim, and I can simulate a pure sine wave and a square wave, or even a pulse, but not a modified sine wave..
You can add a square wave and sine wave, or do some other weird things like that
 
  • #14
rbelli1
Gold Member
965
365
No, safety is in no way dependent upon this solution.
I don't want to be a curmudgeon but safety is very much a part of this project. You are working with mains voltages. Please consider safety at every step of working with them. You may only be working with one or two parts in contact with the dangerous voltage but even that can kill if handled improperly.

I'm not saying that safely working with mains voltage is overly complicated but it is very important.

BoB

Edit: During every step please consider any accidental way you can touch the apparatus. Then once the mains voltage parts are completed insulate and/or enclose them them so it is impossible to touch a live conductor at the earliest possible time.

Edit2: Consider it this way. Not all touches to mains voltage are lethal but all lethal touches are only once. Now get off my lawn!
 
Last edited:
  • Like
Likes anorlunda and Asymptotic
  • #15
Tom.G
Science Advisor
3,402
2,151
A couple ideas:

1) Include a sine wave oscillator synchronized to (the zero crossings of?) the incoming power, then subtract that sine wave from the incoming power waveform. This could be implemented in either hardware or software.

2) Instead of synchronizing an oscillator, a few stages of bandpass filters of the incoming power will also yield an acceptable sine wave source. (Watch out for phase shift in the filters though.)
 
  • Like
Likes Asymptotic
  • #17
KHinMS
I don't want to be a curmudgeon but safety is very much a part of this project. You are working with mains voltages. Please consider safety at every step of working with them. You may only be working with one or two parts in contact with the dangerous voltage but even that can kill if handled improperly.

I'm not saying that safely working with mains voltage is overly complicated but it is very important.

BoB

Edit: During every step please consider any accidental way you can touch the apparatus. Then once the mains voltage parts are completed insulate and/or enclose them them so it is impossible to touch a live conductor at the earliest possible time.

Edit2: Consider it this way. Not all touches to mains voltage are lethal but all lethal touches are only once. Now get off my lawn!

I meant that if the equipment didn't work properly, it wouldn't cause an unsafe condition, such as loss of flight controls, etc.
 
  • #18
KHinMS
Thank you all, I am going to experiment with some of these suggestions. I'll update.
 
  • #19
jim hardy
Science Advisor
Gold Member
2019 Award
Dearly Missed
9,839
4,879
Look up 'distortion meter"

Those meters work by measuring harmonic content of the wave, and there's several ways to do it that have already been suggested in prior posts.

So in your first post, what you called 'sense the rise' was a step in the right direction. Most approximations of a sinewave are rich in harmonics .

So if you find your source is rich in harmonics, you can infer either:
1. you're on the inveter
or
2. the electric company is having a bad day.
 
  • Like
Likes AlexCaledin
  • #20
donpacino
Gold Member
1,439
282
Look up 'distortion meter"

Those meters work by measuring harmonic content of the wave, and there's several ways to do it that have already been suggested in prior posts.

So in your first post, what you called 'sense the rise' was a step in the right direction. Most approximations of a sinewave are rich in harmonics .

So if you find your source is rich in harmonics, you can infer either:
1. you're on the inveter
or
2. the electric company is having a bad day.
What is a distortion meter? does it just display the THD? if it does thats a handy piece of equipment
 
  • #23
jim hardy
Science Advisor
Gold Member
2019 Award
Dearly Missed
9,839
4,879
I built my own distortion analyzer for the techs to use. I
Wow what fun ! How'd it work ? Was it analog ?

Somebody on PF posted a home-made ESR meter for measuring filter capacitors.
 
  • #24
eq1
165
62
KHinMS, If I understand your ultimate goal correctly perhaps I can recommend an alternative solution. Monitor the input and output of the UPS. Probably the best way would be with power measurements. Measuring power can likely be done with a number of pretty cheap instrumentation options depending on your specific setup (especially if you only need to know it's non-zero) Anyway, if the UPS input power is zero and the output power is non-zero then it has switched over.
 
  • Like
Likes Asymptotic and donpacino
  • #25
donpacino
Gold Member
1,439
282
Wow what fun ! How'd it work ? Was it analog ?

Somebody on PF posted a home-made ESR meter for measuring filter capacitors.
Unfortunately it was not analog, although that would have been a fun project.
We had some recurring field failures in some of our 3 phase motor controllers. These failures, while not an immediate critical failure, would drastically decrease the life of our system and cause other failures in the future. We found that the failures (part of the inverter switching circuity) caused an increase in THD by about 10% in certain operating modes. There wasn't an easy way for your typical field tech to tell if the failure occurred on said unit.

The solution was we a box providing electrical connection and isolation hooked up to the inverter and provided a connection to a second instrument that did the thd calculation and display. The comparison was done by taking an FFT in a FPGA, then comparing the spectrum data with one of the baselines we loaded. The operator can select which baseline based on which combination of engine model and controller the system was. Then the THD was calculated and displayed. If the THD was over a certain amount, it flagged a high likelihood the failure was occurring on said model. We couldnt rely on every tech and operator being able to read an oscilloscope, which would have worked as well

TLDR: Used digital logic to do an FFT of the waveform, then compared it to and displayed the THD.
 
  • Like
Likes Asymptotic

Related Threads on Circuit to detect a modified sinewave

  • Last Post
Replies
2
Views
3K
  • Last Post
Replies
9
Views
5K
Replies
6
Views
742
Replies
2
Views
533
  • Last Post
Replies
9
Views
2K
Replies
21
Views
1K
  • Last Post
Replies
2
Views
5K
  • Last Post
Replies
3
Views
3K
  • Last Post
3
Replies
54
Views
8K
  • Last Post
Replies
5
Views
7K
Top