07-08-2014 12:04 PM
Dear all
I have as a part of my code a portion that inputs two signals from two sensors and then calculate the difference between them after that i want to output the difference between the two signals. How can I do it using the DAQmx?
also I would like to know how can I speed up my code excution?
In the attachments you can find my code
Thanks
07-08-2014 12:45 PM
There is no way to create a calculated channel, but if all you are looking for is the difference AND you are using sensors with high-level single-ended voltage inputs, you might be able to fake it by configuring a channel as a differential input and tieing one channel to the + input and the other channel to the - input.
Mike...
07-09-2014 07:41 PM
Hello FaisalF,
Unless I am misunderstanding, the other option would be to subtract the values you read from your sensors in software and then output that subtracted voltage. This will not be ideal if you are trying to run control loops, however, because control decisions will be software timed on the Windows side.
Does the above fit with what you are trying to do? I was not sure if my interpretation or Mike's fit with what you wanted.
Can you clarify what you mean by "speed up my code execution"? Are you seeing slow performance? If so, where, and how have you benchmarked this? I do not see anything in your code that stands out as someting that would slow it down - though you are only reading or writing a finite number of samples once; I was not sure if this was intended (versus sampling continuously)?
07-11-2014 10:28 AM
Hello National Burritos
Yes what you have said is exactly right. I have two laser sensors that gives and output that ranges from 1 to 5 volts. I want to input these two sensors outputs' into the lab view and then calculate the differnece between the (voltages) and then output the calculated difference. In other words I need to feed the difference of the two sensors into a valve that will open or close depending on the value of the two sensors.
The other thing I am using a PCIe-6123 card that have an internal clock. and in my code timing settings I am using the onboard clock. The software excution time should not depend on the PC and/or the windows timing. Am I right?
Finally, I am a beginner in LabVIEW and I would like to speed up my my code processing in general so I would like to know any tips or hints that could increase the speed of excution of the code.
p.s. I used the attached VI to know the time that my code use to excute one loop. What I have done is separating my code into two halfes and measure the excution time for one loop.
Looking forward to hear from you
Many Thanks
07-11-2014 10:37 AM
Hello Mike
I didnt understand what do you mean by "sensors with high-level single-ended voltage inputs"
I am using two fiber optic laser sensors that detects the position of a moving object. So these two sensors are exactly the same but are opposite to each other. They measure measure the position of an oscilating object between them. so when ever the object moves towards a direction one of the sensors will give higher voltage gradually and the other one will decrease in voltage. and then when the object moves again to the opposite direction vice versa will happen.
So basically I have to have the deffirence betwwen the two sensors' voltages and the feed that difference to a valve that open and close depending on this difference.
I hope my explination is clear. Looking forward to hear from you
Many thanks
07-11-2014 10:53 AM
What i meant was what it sounds like you have. The idea I offered wouldn't work with low-level signal like accelerometers or thermocouples, or signals that themselves required differential input - at least not without signal conditioning in place.
It sounds like the sensors you have (which are identical?) would be ideal for this technique.
Mike...
07-11-2014 10:57 AM
Aha perfect
So what should I do exactly to output their differnce? and how can I do it?
Thanks sir
07-11-2014 11:02 AM
Take the voltage signal from one sensor and connect it to the positive side of a differential input and the voltage from the other sensor and connect it to the negative side of the same differential input. To test the setup, use the "test panels" in MAX to observe what you are getting.
Mike
07-11-2014 11:10 AM
Aha
And how do I output the deffirence between the two signals?
Thanks for your patience and fast response
07-11-2014 11:23 AM
The output from the differential channel is the difference.
Mike...