LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

parallelism on single core

HI 

I am using a shaft encoder which gives a pulse every ½ degree and a pulse every full revolution. On each ½ degree pulse I would like to take 3 simultaneous voltage readings from 3 different volatge sources. It needs to write to file the 3 voltage readings per ½ pulse and a full revolution pulse to a file simulataneously.

 

I have just done the ni core 1 and 2 course but find starting this hard - i cannot think of how i can accomplish this on a single core machine. The writing to file will be easiest but setting up the simulataneous action i am finding hard.

 

I tried using 3 multiple while loops which each took a DAQmx start vi for the analogue voltage inputs which were used the counter line (720 pulse) as the source on the individual sample clocks for each while loop - but got a shared resources error of -50103.

 

Any ideas?

 

many thanksSmiley Happy

Notay

0 Kudos
Message 1 of 7
(2,834 Views)

I had an application similar to that.

 

I just used one while loop and sychronized the analog input clock to take a measurement on every clock pulse.  This worked very well.

 

This is the messy version of the code but it showed what I did.

 

Encoder test_BD.png

Dan Shangraw, P.E.


   

0 Kudos
Message 2 of 7
(2,821 Views)

I forgot to mention for this to work you need to remove the duplicate counter measurements.  I used an OpenG VI

 

Example_VI_BD.png

 

In this example I was only interested when the counter changed.  You also need to sample faster than what your encoder.  This method might not work for really fast applications.

Dan Shangraw, P.E.


   

0 Kudos
Message 3 of 7
(2,816 Views)

Hi ASTDan - thanks for your reply

 

I am trying to figure out how exactly i would incorporate you idea into my vi - of which i have attached the picture.

 

The shaft encoder is actually going to be attached to a crank of an engine so we are expecting speed in excess of 5000rpm - a lot of counts! (bearing in mind i will only run the program for at most 5 seconds)

 

The way i thought it did it was logical to me but will not work in labview because of the shared resource.

On highlight execution i actually get two errors; -200279 @ the DAQmx read in the upper while loop and -50103 @ DAQmx start vi just outside the lower loop. I am guessing the former error is occuring due to the sample rate being low possibly due to the highlight execution being on.

 

Also I have just noticed that sometime the error of -50103 jumps to the DAQmx start vi for the upper loop on some program starts - i think the reason it is doing this it because there is no order for execution of tasks/data - this is understandable but I would like parallel system

 

Any suggestions?

 

Thanks - Notay

0 Kudos
Message 4 of 7
(2,792 Views)

You can't have 2 instances of Analog input.  You need to have only 1 instance of an analog input task and then read N Channels N samples for your analog read.  Then index the analog input channels you want.  That I beleive is the -50103 error.

 

The other error can be caused by highlight excution being on.  It is basiclly saying your buffer is full.  You need to read the data out of the buffer faster.  I think you will run into this with highlight excution being off because you are only reading 1 point out of the buffer/while loop interation.  I would recomend reading more samples/iteration.

Dan Shangraw, P.E.


   

0 Kudos
Message 5 of 7
(2,780 Views)

Hi

I have change the analogue read to multiple channels - multiple samples - 2d DBL as suggested. I have added an additional 2 physical channels but i do not how to index them into the physical channels input of the daqmx create channel vi.

 

Thought about using a bundle cluster to bundle them together but then the output of the cluster becomes a string which clearly cannot be wired into the create channels vi.

 

I have searched the  functions pallete for something suitable but have failed. Which vi should i use?

 

Also would this mean that at the data end of the read vi i would get an array of 3 data sets?

 

I really appreciate you help. Thank you - Notay

0 Kudos
Message 6 of 7
(2,764 Views)

Here is a few ways to index Analog Input channels

 

You can expand the index array primitive by just grabbing the bottom and expanding it.

 

Example_VI_BD.png

Dan Shangraw, P.E.


   

0 Kudos
Message 7 of 7
(2,756 Views)