12-16-2007 11:47 AM
12-17-2007 09:32 AM
12-17-2007 11:18 AM
12-17-2007 03:07 PM
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
12-17-2007 04:15 PM
12-18-2007 03:53 PM
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.
12-19-2007 06:20 PM
12-20-2007 01:37 PM
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.
12-21-2007 05:41 PM
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.
12-22-2007 05:00 PM