LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Encoder movement response too slow

I have a USDigital QSB-D USB/serial encoder which uses a serial uart interface at 230.4 kb/s, 8 bits, no parity, 1stop bit.  The USDigital driver (USDQSB.dll) allows me to open/close and read/write to registers and provides get/set functions to set specific modes.  The driver provides StreamEncoderCount function which takes threshold and intervalRate parameters.  The threshold specifies count changes to trigger transmission and the intervalRate is time interval between transfers.  In the attached VI I am attempting to use the StreamEncoderStatus() function to wait for the encoder index pulse which indicates the encoder has passed zero counts.  When the index pulse is detected I would like to use the StreamEncoderCount function to retreive encoder counts as rapidly as possible.  I am setting the threshold to 0 so it will read the count even if it is not moving and intervalRate to 1 which should be sending count value at 1.9 msec intervals.  The for loop count ie 100 which should take 190 msec to read at 1.9 msec.  The for loop takes over 3 sec which means that the sample rate is over 30 msec instead of 1.9 msec. I am using a notification to notify another the other while loop which plots the results.  Everything works as intended except for the slow response of 30 msec per sample instead of 1.9 msec.

 

John

 

0 Kudos
Message 1 of 7
(4,021 Views)

jdcharlton,

 

I have taken a look at your code and I have a test we can run

 

Lets first test the speed of running the DLL by itself to determine the run time of a single instance of your code.  We have a benchmarking VI in the example finder that can be used to determine if your DLL is running at the optimal speed or if the code itself is creating a delay.

 

Lets see how that goes then we can help you further.

 

J Newk
Systems Engineer
National Instruments
0 Kudos
Message 2 of 7
(3,983 Views)

I am attaching an update in QSBEncoder3.vi.

 

Thank you.  I will do the dll speed test later today.  I think the main problem is in the way I am using the StreamEncoderCount() function by calling it repeatedly in a for loop.  I did some testing of the encoder driver using VISA interactively.  The way the StreamEncoderCount works is one call is all that is needed.  From the one call to StreamEncoderCount it sends encoder count readings at the specified time interval until another command is issued such as a non-streaming GetCount() function call which terminates the streaming encoder count mode.  I am looking into doing it with a serial VISA driver which would allow me to write the serial code that will wait till the required number of samples are received.  My first pass in LabView is to take the StreamEncoderCount() out of the for loop and have the for loop follow the StreamEncoderCount() and fill an array with 100 encoder counts but that doesn't work because the for loop just files the array with the first count received and doesn't wait for new encoder counts.

 

John

0 Kudos
Message 3 of 7
(3,954 Views)

For clarification, the VISA test tests the raw serial interface not the USDQSB.dll driver.

0 Kudos
Message 4 of 7
(3,944 Views)

jdcharlton,

 

That makes sense that the repeat calls could be causing the delay, any updates?

 

Regards,

J Newk
Systems Engineer
National Instruments
0 Kudos
Message 5 of 7
(3,915 Views)

I was not able to find your dll benchmark application to do that test but I am beyond that now.  I have found the correct function to read streamed serial input from the encoder which is the USDQSB.dll function: GetCountWithTimeStamp() which apparently just reads the streamed serial input and does not query the count register repeatedly.  The attached QSBEncoder3.vi uses that function and performance is as expected.

 

I have rewritten the encoder application to use the VISA driver.  The encoder is automatically recognized as a serial device by VISA and assigned the instrument ID: ASRL3::INSTR.  The attached QSBEncoder4.vi attempts to access the encoder using VISA but I don't get any response from the encoder serial port.  Any ideas on what I am doing incorrectly?  I am able to access the encoder using the VISA interactive control but when using the LabView QSBEncoder4.vi application I don't see any input coming from the ASRL3::INSTR  device.

 

John

 

Download All
0 Kudos
Message 6 of 7
(3,902 Views)

jdcharlton,

 

Does the same behavior occur using the LabVIEW VISA shipping examples?  They can be found in the example finder under Hardware Input and Output, then VISA.

J Newk
Systems Engineer
National Instruments
0 Kudos
Message 7 of 7
(3,874 Views)