LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Control LPT using Labview

Hello,

 

   I am controlling a stepper motor using labview program that uses VISA. How ever I am not able to attain speed ( freq) over 500Hz. I think its because of the open visa resource and close visa that happens for every loop that limits the speed of the motor. 

 

Is there any other way to control the motor apart from VISA. The motor should be able to run at 1600Hz max. Like I mentioned, I am not able to go over 500Hz with the program I developed. Please find the attached to find the program.

Abhilash S Nair

Research Assistant @ Photonic Devices and Systems lab

[ LabView professional Development System - Version 11.0 - 32-bit ]

LabView Gear:
1. NI PXI-7951R & NI 5761
2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021

OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
MEMORY - [ 16.0 GB RAM ]
GPU - [ NVIDIA GeForce GT 530 ]
0 Kudos
Message 1 of 9
(5,999 Views)

Hi abhi,

 

your VI refuses to obey any LabVIEW standard or style guide...

 

- You use too much local variables and sequences.

- You use wrong datatypes.

- You use functions in wrong places...

 

See cleaned up attachment (just cleaning up the locals and removing the sequence structure).

There still is a big bug in: In each iteration you close the VISA port, but you never open the port again!

You only need to open the port once before the loop and you only need to close the port once after the loop!

 

Then I think your VI will never run fast enough nor will the underlying hardware driver be fast enough to support sending data to the LPT port with 1000Hz or so. Atleast when trying to send single byte command. Also windows task scheduler will make your life much harder as it will steal away the CPU from your task sooner or later...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 9
(5,986 Views)

Thank you !! ... This VI looks so much cleaner and tidy and logical than mine.

 

I went through the block diagram you sent me. The VISA writes again inside each loop doesnt it. This should again affect the timing right. And why do we need another VISA write outside the for loop ?

 

I am sorry. But I am just trying to learn.

 

Thanks

Abhi

Abhilash S Nair

Research Assistant @ Photonic Devices and Systems lab

[ LabView professional Development System - Version 11.0 - 32-bit ]

LabView Gear:
1. NI PXI-7951R & NI 5761
2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021

OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
MEMORY - [ 16.0 GB RAM ]
GPU - [ NVIDIA GeForce GT 530 ]
0 Kudos
Message 3 of 9
(5,981 Views)

Hi abi,

 


The VISA writes again inside each loop doesnt it. This should again affect the timing right.


What do you mean by "doesn't it"?

 


And why do we need another VISA write outside the for loop ?


Well, it has been there before in your original VI too. You should know why it has been there...

 

Each VISA-Write sends out those 8bit data as a single byte.

The last VISA-Write sends out a zero, in your original VI you used a boolean array constant for this purpose.

 

Did you remove those silly VISA-Close in the loop?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 9
(5,974 Views)

Yes I removed the VISA close in the loop. Like you advised there should be only one visa open and one visa close before and after loop. 

 

Attached is my VI which is the new one I edited. 

Thanks,

Abhi

Abhilash S Nair

Research Assistant @ Photonic Devices and Systems lab

[ LabView professional Development System - Version 11.0 - 32-bit ]

LabView Gear:
1. NI PXI-7951R & NI 5761
2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021

OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
MEMORY - [ 16.0 GB RAM ]
GPU - [ NVIDIA GeForce GT 530 ]
0 Kudos
Message 5 of 9
(5,971 Views)

Even if you control the parallel port direclty through Port IO functions will you be limited in speed. 1000 Hz on average should be possible, BUT there is no guarantee under Windows. When a Windows network driver or other kernel device driver decides it needs the CPU and/or memory bus to transfer a package of memory it gets that resource assigned and whatever user space application is running has to wait for whatever time the driver feels appropriate. This means that your application can get randomly suspended for several milliseconds without any chance to do a single CPU cycle.

 

With VISA there are several more layers of userspace drivers atop the kernel port IO driver and that makes it significantly slower. It probably is able to do 1000 single byte writes per second on a modern computer, but the timing will be way off from a regular 1ms interval. But even with direct Port IO VIs it won't be really a clean 1ms interval at all. Also direct Port IO is not available for Windows 64 Bit systems so if you run on that or plan to move to that in the future it's not an option.

 

Since your loop timing directly seems to control the motor speed, I'm afraid you will never be able to get the motor to operate at a constant speed under normal Windows. These kinds of things call for either a realtime operating system or dedicated hardware that takes care of the faster timing signals all on its own and only needs to be controlled by the computer through commands to change the parameters and start and stop the motor.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 6 of 9
(5,940 Views)

Hi,

 

it is possible that you convert the vi to labview 2010 and post it again?

 

Thank you

Labview 2010
0 Kudos
Message 7 of 9
(5,873 Views)

Hi Andre_H,

 

This copy of the VI should be in LabVIEW 2010.

 

Regards,


Alexandra Valiton

 

National Instruments
Applications Engineer
0 Kudos
Message 8 of 9
(5,851 Views)

Thx

Labview 2010
0 Kudos
Message 9 of 9
(5,825 Views)