04-22-2013 11:20 AM
**Updated code with error handling wired.**
04-22-2013 01:03 PM - edited 04-22-2013 01:13 PM
I've cleaned up your VI...please take notice the difference, this is a CLD graded requirement
04-22-2013 01:57 PM - edited 04-22-2013 02:04 PM
Apok,
Thank you for the tips and I will handle the code accordingly in the future. I am noticing an odd response from the analog inputs. AI0 seems to be not reading correctly. If I turn off any two digital lines, the corresponding analog input reads correct. In the case of two or three, I get incorrect readings as if the digital lines are not high at all. I have retested the hardware with a simple program I wrote previously and know there is no issue with my electronics. Any ideas? I'm thinking the output of the daq read vi is not in a format I understand. I assume it is double format, 2D array where each row is an individual analog input channel.
04-22-2013 02:19 PM - edited 04-22-2013 02:31 PM
@surferEE wrote:
I assume it is double format, 2D array where each row is an individual analog input channel.
you are correct...
I've checked on my end here and it seems to be working, check your connections to it making sure everything is tied down and tight....
04-22-2013 03:30 PM
Ok, the analog inputs needed to be configured single ended. Attached updated code. What I need to do now is pick of the data points for each of the three channels at 1 second and 20 seconds. Take the difference and run those 3 resultant deltas through some logic to drive the LED's. I guess I can do this operation on the entire 2D array outside the state machine?
04-22-2013 03:45 PM
I also noticed the waveform chart keeps overwriting the previous samples so I only get one sample displayed at a time. Why is this?
04-22-2013 03:57 PM
yes, you can...i modded your vi graph, check your channel assignments....
04-22-2013 05:02 PM
Apok,
Ok here is my updated code. I removed the waveform chart. I only need it to view the data trend over the 20 second sample period and is not necessary for the end product. Likewise with the table but I need to keep it on the front panel for now to make sure I am extracting the correct samples. I modified the while loop wait constant to 1000 ms as before I was getting 50e-3 X 20 samples in the output array. I put two more double indicators on the front panel to see what the 20th and 2nd sample are after the 'read' state is complete. I am not getting any values from the array. The cascaded 'array index' vi's are used to pull the samples I need. Am I missing something here? Thank you again for your assistance.
04-23-2013 09:22 AM
Apok,
Here is my proposed solution. I cannot get the first sample to return true. The 20th is reading out fine but my logic may be incorrect. I am implementing the first-call vi to accomplish this. I just need the first (or second sample is fine also) sample to provide the delta calculation. Thoughts?
04-23-2013 09:40 AM
remember and becareful......
First Call? returns TRUE the first time the VI runs after the first top-level caller starts running, such as when the Run button is clicked or the Run VI method executes. If a second top-level caller calls the VI while the first top-level caller is still running, First Call? does not return TRUE a second time.
did you try the last mod from me?