LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State Machine Implementation

**Updated code with error handling wired.**

I surf therefore I am....
0 Kudos
Message 21 of 34
(577 Views)

I've cleaned up your VI...please take notice the difference, this is a CLD graded requirement

 

  • rt click wire, Cleans up the wire so that it has no loose ends, no hidden wire, and few bends and branches (this can add to the size of your VI) also, will make it easier for the programmer to understand your data flow
  • changed your 1D constant to a 2D and wired that into the select function, which now can display waveform
  • because of the OR function that ties the 2 timers together, you will get 20 reads....
  • again, do not view your controls and indicators as 'icons'...they take up way more space
  • try to design your front panel and block diagram to take up real estate for 1 normal screen size, not a 60" jumbo-tron
  • tie error lines together
  • no need for a sample clock when using USB 600x
0 Kudos
Message 22 of 34
(556 Views)

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. 

I surf therefore I am....
0 Kudos
Message 23 of 34
(541 Views)

@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....

0 Kudos
Message 24 of 34
(532 Views)

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?

I surf therefore I am....
0 Kudos
Message 25 of 34
(518 Views)

I also noticed the waveform chart keeps overwriting the previous samples so I only get one sample displayed at a time.  Why is this?

I surf therefore I am....
0 Kudos
Message 26 of 34
(514 Views)

yes, you can...i modded your vi graph, check your channel assignments....

0 Kudos
Message 27 of 34
(509 Views)

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. 

I surf therefore I am....
0 Kudos
Message 28 of 34
(497 Views)

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?

I surf therefore I am....
0 Kudos
Message 29 of 34
(470 Views)

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?

0 Kudos
Message 30 of 34
(463 Views)