Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Torque sensor Sampling freq and Number of samples

Hi,

 

We are building a motion control application using the following harware, PXI 7352 motion control card, PXI 6251 M-DAQ, UMI 7764 to connect to a Danaher motion AC Servomotor using  S20360 Servo drive. 

 

A torque cell (0 to 10 V => 0 in-lbs to 100 in-lbs) controls the CW, CCW direction of the servomotor between two set limits (say, 4 V and 6 V. The torque sensor is connected to a digital panel meter which displays a BCD output of the torque in in-lbs as well as sends out a 0 - 10 V signal ( @ 50 readings / s) that I am sending into the PXI 6251 via a SCC68 block by connecting the signal in a differential mode across AI 5 - AI 13 (Single channel). The torque sensor itself has a response time of 0.13 ms.

 

I am having issues with my VI, in that I am not having control over my sampling. Currently I am having the values of 1000 Hz and infinite samples and the loop executes has 35 wait in ms. If I am trying to change these values my motor changes direction at other voltage limits (like if lower limit is 4.25 V, it changes direction at 3.5 V and similarly for higher limit). and also at the end, my excel sheet has different number of rows, What I need is if I say 20 samples per second, I want 20 excel rows for a second.

 

What I want help from this forum is some fundementals about sampling.

 

I am also attaching a screen shot of my code and excel output for your reference.

 

Thank you.

Download All
0 Kudos
Message 1 of 4
(3,287 Views)

The way your program is setup to run is to have the card continuously acquire data at the rate specified by your Sampling rate input, so 1000 Hz, and buffer the data.  You then specify how often to read data from the buffer into your program by setting the Number of samples input.  If you leave this value as the default (-1), it will read off all available data every time your loop executes.  However, if you set this to some value, say 50, it will wait until 50 samples are available on the buffer.  At 1000 Hz, this operation should take 50 ms.  Because you affect the timing by adjusting the number of samples, I would recommend getting rid of the wait function in your while loop.  I don't think it will solve your issue, but it will help your code.

 

I'm not sure as to why you are missing data in your Excel file or why your motor is switching direction and different values.  If you want 20 samples a second, set your sampling rate to 20 and set the number of samples appropriately based on how often you want the loop to execute.

 

If you are still having trouble, go ahead and post your code so that we can see everything going on in the loop.

Alex Person
NI-RIO Product Support Engineer
National Instruments
0 Kudos
Message 2 of 4
(3,255 Views)

Thank you Alex for your reply. Your explanation has sort of cleared some of the doubts I had earlier. I made a few changes as you suggested and got some good results. I tried the sampling rate of 100 and number of samples at 50 and got 2 rows of excel data as expected. I am attaching the file for your kind reference. But, still my control part is way off, I mean the limits I want the motor to toggle are not being met when I am playing around with the sampling parameters. I am attaching the code as well for your kind reference. I should warn you the code is a bit messy, I had to try and figure out how to go along LabVIEW as I had no prior experience, so it is my humble request that please do not frown on me. I am very glad to be receiving your help. Thanks a lot.

 

 

Download All
0 Kudos
Message 3 of 4
(3,246 Views)

After looking at your code, one thing really stands out-you have a lot going on in that loop! 🙂

 

I'm guessing that what's happening is that your program is setting the direction of your motor correctly but it's delayed to the point that you're reading some other value on the digital meter when it finally changes direction.

 

The way you can help this is to separate the activities out into their own separate loops.  So, I would start by setting up a producer/consumer architecture for your data acquisition and file I/O.  The DAQmx Read would go in the producer loop and the file I/O would go in the consumer loop.  There is a VI Template that shows this as well as a lot of discussion posts on it so you should be able to find a lot of information on it.  The last thing you would then do is place the motion code and state machine in its own while loop and use a variable to pass data from the DAQmx Read into it.

 

Let me know if I can clarify any of that further.

Alex Person
NI-RIO Product Support Engineer
National Instruments
0 Kudos
Message 4 of 4
(3,226 Views)