LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Encoder DI only fires once when AI Starts

Solved!
Go to solution

Hello All

 

I have a 9172 DAQ (USB) with a 9203 Analog Current Module and a 9401 Digital Input Module.   I am trying to get 5 forces vs. slide position on a press.

 

The DI has a Absolute Encoder hooked up which works great and sends the encoder values back.

The AI has 5 force transducers hooked up and works great when the press is running.

 

THe problem is when I try and use both the DI and AI at the same time (I have a trigger on the DI set at a value of 7000) the AI will start capturing the forces but I only get the 1st encoder value in the file.

 

Any help would be much appericated.   I am a newbie at Labview.  I have included my file.

 

 

 

 

Thank you

 

Michael

 

0 Kudos
Message 1 of 8
(4,397 Views)

Your Write to Measurement File section "If a file already exists" is set to "Use next available filename".  So each loop iteration, it will try to create a new file.  The files will only have one value in them.  Change this setting to "Append to File".  Then you will capture data from all iterations in one file.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 8
(4,379 Views)

Hi Tbob

 

Thanks for the response.   I changed it to append, but it still gives me a file of all my forces but only 1 encoder value (first line of time, forces, encoder value).       It seems like the AI task takes over and doesn't allow the DI to run.      I tried switch the DI to Continous rather than polled but it says its not allowed with this device.

 

Any suggestions are greatly appreciated!

 

Thank you

 

Mike

0 Kudos
Message 3 of 8
(4,370 Views)

Hi Mike,

 

It looks like you are not building an array of values every time your loop iterates.  When you go through your while loop iteration, you check your encoder readout for a certain readout before sending your case structure to a true case.   But the values are erased every iteration unless you enter the true case, where you write the current values to file.  If you want to build an array of values, you will need to use the Build Array function with an initialized array, and then use a Shift Register to continue building the array through each iteration of your loop.  When you do hit your true case and write data to a file, you can clear the array and start rebuilding your DI inputs on the next iteration, and so forth.  If that sounds like something you are looking to do let me know, or if I missed something I can try to explain or think of a different approach.

Kyle A.
National Instruments
Senior Applications Engineer
0 Kudos
Message 4 of 8
(4,346 Views)

Hi Kyle

 

Thanks for your response.

 

I think you are on the right track with the array idea.   I did experiment with this before your posting but was not succesfull.   I probably was not doing the wiring correctly.   

 

I am interested in only recording to a file the AI measurements (and DI encoder values) when the DI value is greater than a certain number.      

 

As another note, the DI module I found out is not a 9401 (correlated module) but a 9425 digital sync module.       Does this drastically affect the outcome?

 

Thanks for your help.

 

Michael

0 Kudos
Message 5 of 8
(4,328 Views)
Solution
Accepted by topic author cdnbikerdude

Hi Michael,

 

I would imagine you can use a case structure that determines when encoder values are stored and built into the array, while the false case passes nothing through.  Your current DI acquisition is one sample on demand, and your AI measurements is N samples, 300 samples at a rate of 32kHz.  This means when you read your DI value greater than a certain number, it is going to stop and take 300 samples before writing and iterating again.  I'm unsure how many encoder values you wish to save, and at what time, but you will either need to do a similar finite sampling on your DI to get more values per iteration or build an array one sample at a time as mentioned previously.

 

The 9425 is just another DI module, so it should not affect the way you will need to code.  The main difference between the two modules is hardware timing vs software timing.  You are using software timing in your code, so no detriment in performance should be seen.  

Kyle A.
National Instruments
Senior Applications Engineer
0 Kudos
Message 6 of 8
(4,294 Views)

Hi Kyle

 

Thanks for the quick feedback.

 

 

I did make some changes to my program to allow it to write to an array which works okay, except there aren't enough data points.  I think this is because it is running off the CPU's loop time. 

 

I had to change the samples to (1 Sample on Demand) for both the AI and DI so I could do this.      If I set the DI to N samples like you suggested I get an error.   --> Selected lines do not support buffered operations.

 

 

I have included my updated program for reference.

 

I did find a past discussion on this similar task from about a year ago from someone else with the same hardware.   I think I am in the same boat though.

 

http://forums.ni.com/ni/board/message?board.id=170&message.id=412361&query.id=3911242#M412361

 

Thanks again

 

Michael

 

0 Kudos
Message 7 of 8
(4,282 Views)

Hey Michael,

 

Yes, using software timing does slow down the acquistion, and using Express VI's will slow down the software even more.  You may want to consider using an example with standard driver VI's that has the same function as your express VI's, per the suggestion in the forum you linked.  

 

I apologize about the misinformation, but your module is software timing only, so you cannot use the continuous or N sampling modes, only on demand sampling.

 

If you need more data points in a shorter amount of time, consider replacing your Express VI's with examples.   For instance, the example Read Dig Chan.vi can replace your DAQ Assistant express VI, just put the task creation and start task VI outside of the while loop on the left side, and end the task on the outside of the loop on the right side.

 

2010-05-04_111509.png

Kyle A.
National Instruments
Senior Applications Engineer
Message 8 of 8
(4,244 Views)