Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Implementing synchronization of Relay Switiching based on the Zero Crossing of Input Line Voltage

Hello,
 
I am trying to implement zero crossing logic in Labview 8.5 using USB 6218 in order to synchronize the switching of relay based on zero crossing of input line voltage.
 
Inputs:
 
1.  Input line voltage 120VAC, 60Hz stepped down to 5VAC RMS fed as an input to USB 6218 AI0 should be displayed on waveform graph/chart.
2. Load Voltage 6mV to 264mV max AC RMS fed to USB 6218 AI1.
 
Output:
 
1. Output will be the zero crossing signal 0 - 5V pulse generated fed to USB 6218 AO0.
 
I have generated logic for zero crossing after monitoring the input line voltage; however it is not working,
 
Can someone help me verify this logic and recommend any suggestions on this code?
 
I would really appreciate valuable inputs as soon as possible.
 
Thanks,
 
Best regards,
Rohit
 
0 Kudos
Message 1 of 13
(4,162 Views)
Have you though about using a solid-state AC relay with zero-crossing turn on feature? They are available off the shelf. When you send it a DC input signal, the output will not turn on until the next zero-crossing point of the AC line voltage occurs.
~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 2 of 13
(4,142 Views)
Thanks for the reply. I am using a 12VDC relay with a relay driver circuit making sure I have enough current to drive the relay coil during each zero crossing. However, controlling the pulse width of the zero crossing signal is also equally important for my application. Each zero crossing, the relay should turn on and thus introducing the fault current i need to monitor using a current transformer. The output of current transformer is in few mV AC rms fed to the USB Module.
I would like to use a digital output pulse to the relay driver circuit for switching the relay based on the zero crossing of input line voltage. I hope this VI works or can you suggest a more efficient way to implement this logic?
 
Appreciate a response.
 
Thanks again,
 
Rohit
0 Kudos
Message 3 of 13
(4,135 Views)

Hello,

I think that there are some better ways to detect zero crossing.  The logic is exampled in the Knowledge Base linked below.   Also take a look at another version in the Developer Zone link.   Both of these links have example code.

AE KB 3QCCI1RX: Zero Crossing PtByPt.vi Gives Incorrect Output

Zero-Crossing in Waveform Charts

 

Samantha
National Instruments
Applications Engineer
0 Kudos
Message 4 of 13
(4,121 Views)
Thanks Samantha. I am trying to implement this in my current VI. Instead of while loop, i believe i should be using a for loop and basically replicate the same zero crossing logic. However I have problems with the data flow types, somehow it produces broken wires. Can you please implement the logic as per (AE KB 3QCCI1RX: Zero Crossing PtByPt.vi Gives Incorrect Output) in my VI?
 
I am having a hard time doing this. I would really appreciate your help in this regards.
 
Thanks in advance,
 
Best regards,
Rohit
0 Kudos
Message 5 of 13
(4,116 Views)

Hello, 

The data type in the program you posted is N Channels N Samples 2D dbl, which produces a 2D array of doubles.  The examples I linked you to are N Channels N Samples 1D waveform.   In addition, in the example you posted you are acquiring from two different channels.  Thus if you change your application to waveform data type you will need to use the Index Waveform Array.vi in place of the Index Array.vi you were previously using.  Please take a look at the Help file for the Index Waveform Array.vi and pair it with DAQmx Read and Write.vi set to waveform data type.

Samantha
National Instruments
Applications Engineer
0 Kudos
Message 6 of 13
(4,088 Views)
Hello Samantha,
 
Thanks for your earlier inputs.
 
I have attached my latest VI with the  N Channels N Samples 1D waveform data type. Also, things seem to be working well as far as the switching of the relay is concerned. Also, I am able to read the input voltage (60Hz Sine wave) on my USB AI0 input on the oscilloscope, however i want to monitor it on a waveform chart in labview but i see a dc constant voltage of 5.43V and cannot reproduce the sine wave which is being read on my Analog Input channel AI0 for some reasons.
 
It looks like either the data type i am using is not correct to monitor my real time sine wave signal or else the sampling rate of the DAQMX Read.vi needs to be set right. I am not sure if the switching  of my relay, is because of the zero crossing logic or due to the input sine wave signal that exists just i am not able to monitor it on the waveform chart.
 
To summarize the issue in brief as below:
1. I should be able to monitor real time 60Hz Sine Wave signal on the waveform chart and be able to validate the switching of the relay on Analog Output AO0 based on the zero 
    crossing logic.
 
Thanks in advance,
 
Best regards,
Rohit
0 Kudos
Message 7 of 13
(4,071 Views)

Hello,

 I ran your code in Highlight Execution and at the DAQmx Read VI you were getting an error message -200279, which is related to the buffer size. 

“Increasing the buffer size, reading the data more frequently, or specifying a fixed number of samples to read instead of reading all available samples might correct the problem.”

I increased the samples per channel from the DAQmx Timing VI and also lowered the number of samples to read at the DAQmx Read VI.  The error you were getting was due to overwriting the buffer or trying to pull from it too fast.  Please take some time to adjust the buffer to your needs.  In addition, the Zero Crossing PtbyPt.VI  that you are using accepts a double and not a waveform of doubles.  I also saw that the chart/graph you have labeled Zero Crossing Output is only taking in one value per loop due to the one data point you are converting into a waveform.  Please spend some more time troubleshooting this code. 

Please don’t expect parts of code from another example with a specific structure to work without some to several modifications in a new VI.  There was a For Loop in the example in the Knowledge Base and this is missing the code in the last post.  This might help with the update.  However, please note that the examples I have previously posted were to provide a starting point for you to modify to your application.  They might not allign with the application you are envisioning.

 

Samantha
National Instruments
Applications Engineer
0 Kudos
Message 8 of 13
(4,054 Views)

Hello,

Okay, I did some more thinking about this issue with a co-worker and have some new information.  The buffer error I was getting was in fact due to running it in Highlight Execution.  Sorry for leading you in the wrong direction there.  In addition, the big picture of your application is using a USB device to react to an input in-order to output to the relays.  The frequency is 60 Hz and considering USB rates and processing time there is going to be a long latency time related to this reactionary approach.  The latency could be from 10-200 ms, which significant in comparison to the 60 Hz signal.  Thus, the output signal being produced is not as reliable as you might think.  I just wanted you to consider this.

A great solution would be set up an analog trigger for the zero value of the input.  However, the USB 6218 does support this type of retriggerable trigger.  So the next option would be to consider a predictive approach rather than a reactive.  This will require some time investment and detailed programming structure.  I will think through this approach and get back with you after the holidays.  Please give me some feedback is this latency delay is acceptable or if you were aware of it and okay with it.

Samantha
National Instruments
Applications Engineer
0 Kudos
Message 9 of 13
(4,033 Views)
Quite apart from the latency of the DAQ system, you should be sure the relay itself is able to respond in a useful amount of time. The fastest will be reed relays which are at least several ms in response time. More ordinary relays will be considerably slower.

You should probably be using something electronic, a power FET or an SCR.
0 Kudos
Message 10 of 13
(4,023 Views)