LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

parallel port pins

Hi everyone. I'm involved in a project where I'm controlling a stepping motor via a Unipolar Stepper Motor Board (manual provided on the link. I only want to controll the direction and the speed of the motor and I'm using a Hall affect detector for the zero position of the motor. (i.e. i'm basically using it as a referanc position)

http://documents.rs-components.com/rs-bin/...900766b802ee6cd

Anyway, my main concern for now is to talk to the Motor controller Board through the parallel port of my PC. I am using Windows 200 Platform (I don't think it would make a differene).

I have previously used LabView when I was involved in a different project but then I used srial port as the link with the hardware I had.

What I really need is to directly controll 3 pins of the parallel port: 1 for direction, 1 for speed and 1 for zero position. Two of the pins will be connected to the motor Board and the third one to the Hall Affect detector.

So, does anyone know how to directly access th parallel port pins through LabView.

Thank you
Message 1 of 9
(3,292 Views)
You asked this question on the LAVA forums (on two different boards). Was the answer given not sufficient? Did you take a look at the examples that ship with LabVIEW? How about the LabVIEW FAQ?
Message 2 of 9
(3,285 Views)

True, but what I was hoping for is to actually access the Parallel port pins as I/O pins. I just need 3 pins, Two as outputs only and One as input only. On top that I am not really that good and experienced in LabView. It would be great if anyone can show me an example of how to do this. Also I am using Windows 2000 at university (in the Laboratory where I'm doing the project) and I read on one of the NI pages that to access the parallel port pins as I/O on Windows 2000 in particular I'm going to have to download an update (or something of that sort).

 

Thank You

0 Kudos
Message 3 of 9
(3,264 Views)

Hi,

  the links on the LAVA forum actually give you the example code that should get you up and running.

The key thing about the parallel port is it's a "port" so it has to be treated by writing to the entire port at once.

I would recommend having one section of code that deals with the writing to the parallel port, and you can read it first then, mask out the pins you don't want to write to, and then write it back with the new data in it (so read the port, then AND that value with a mask value, so 10111111 for the second pin, then OR the result of that with the status you want to drive the new pin and write that value out).

If you try to do this from multiple places in your code that could execute at the same time, you could end up with a race condition (so the read occurs, then the write occurs somewhere else whilst the logic you're performing on the first one goes through, and then you end up writing the wrong value) - you can get around this with locks if necessary (sempahores).

Hope that helps

Thanks

Sacha Emery
National Instruments (UK)

// it takes almost no time to rate an answer Smiley Wink
Message 4 of 9
(3,232 Views)
You can't access the individual pins directly. You can only read/write a byte. This means you have to read the current value of the port, mask it against what you want, and then write out the new value.

I never heard of an update required for Windows 2000. Were you thinking of NT? That requires a kernel-mode driver.



Edit: Sorry for the double post. Was writing the post, got distracted, and when I submitted it saw that answer had already been submitted. Oh well.

Message Edited by smercurio_fc on 10-27-2006 09:01 AM

Message 5 of 9
(3,231 Views)

Hi,

 

find attached a simple Test with LPT - Port    (  !! comments in Diagram !! )  made with LabVIEW 7.1.1

This should give an idea, how to talk to your application. But I think you should have found a lot of this stuff,

if you would have searched for " Parallel Port " in this forum.

Regards

Werner

Message 6 of 9
(3,225 Views)
Thanks to everyone who tried to help me on this, I'm very greatfull to all of you guys.

The example that "wha" uploaded, I think that tries to talk to the memory location straight away rather than talking to the parallel port and then masking the value. and I would like to appologise for asking stupid questions, since I'm very poor when it comes to using LabView. I've got about two weeks before my deadline to hand in my project at university. So, if one of you guys have some time to spend would it be possible to just make a simple example of the below description.

I just need ANY of 1 pin of Parallel port to be INPUT and ANY 2 of the parallel port pins to be Output. The output is going to be used to control a Stepping Motor. One of the pins will be used for the speed and the other for Direction. The INPUT pin will be connected to a "Hall Effect" detector.  Thinnk of it as a Sensor, so as soon as my rotated wheel goes beyond a point it will trigger a HIGH pulse, which would be the input to the PC and the motor will stop at that point. The motor Controler board which I am trying to connect to is located at http://documents.rs-components.com/rs-bin/...900766b802ee6cd.

For those who think that I'm too lazy to do anything please don't think of me that way, since My actuall real project is to build a DFTS (Discrete Fourier Transform Spectroscopy) i.e. what this machine does is measure the dielectric properties of any material (including gas and Water) on THz Band. At the moment I'm a a student doing Electronic Engineering (My last year) in London.  This project is done in conjuction with NPL (National Physics Laboratory). I managed to do most of it (which costed more than £6000) but I'm on my last stage and thats to move this motor, where on the motor a (stainless steel ) corousel wheel is attached where the samples to be measured are then placed.
This was one of the most compicated and time consuming project that I was ever involved in.

Thank you guys in advanced.
Message 7 of 9
(3,207 Views)
Hi,
  the memory location approach is the best way to do this, otherwise someone else has to make a driver for it (which ultimately would talk to the memory address anyway) or go through the VISA layer, and treat it like a sort of serial port.
You can't specify the direction of the port pins on a pin by pin basis.
All you need to do is make sure the parallel port is capable of talking in both directions, and then read from or write to that memory address that the parallel port is attached to and that's it.
The problem you'll have is it will all be software timed.
If you're using a Hall Effect sensor, then I'm assuming the motor has a cog (gear) wheel on it, and you're wanting to use this to track the position of the motor shaft.
This is not going to be a guaranteed thing on a parallel port since you're software timing it, and if the motor goes faster than half the speed of the software then you're going to miss the transitions (remember the parallel port will give you a static read, so the high or low, not the transition point - hence the software has to run at twice the speed of the sensor signal output)
I would definitely recommend going for a data acquisition card with counters on it so you can generate you pulse trains for the clock and also take position measurements from another counter for the hall effect sensor and then some digital lines so you can control direction and enable/disable lines. Perhaps something in the M-series bus powered range? http://www.ni.com/pdf/products/us/cat_mseries_621x.pdf
(Check the number of inputs and outputs you need of what type to get a good match)
 
Hope that helps
 
Thanks
Sacha Emery
National Instruments (UK)

Message Edited by SachaE on 10-30-2006 09:48 AM

// it takes almost no time to rate an answer Smiley Wink
Message 8 of 9
(3,180 Views)

Thats actually exactly what I'm doing, but I am gonna make the software so that it does 1 thing at a time. Meaning that even though Im controlling another motor through GPIB and the Lock-in-amplifier (sr510), I am using the event structures do select which should be controlled first. So, when I try to move the motor that I'm controlling through the Parallel port then the software will only be concetrated on that piece, i.e. I will only run the appropriate coding that only deals with parallel port, allowing me to keep monitoring the port the whole time untill I catch the Hall effect signal. Once the circular disc (using cogs) is placed on the required position than I start controlling the other devices, which is the rest of the coding. I'm not sure if this is the correct approach to it, since I'm short of budget as well, but I thought that this might be the best solution of what I've got to work with here.

 

If its OK with you guys I can upload the whole code here so that atleast you can check if there are any spotted mistakes. My main concern about the whole code is the timing, since this is critical when I do data aquisiton from the Lock-in-amplifier. I used the Property nodes alot of times, and I dont know if that is any good. So if anyone is interested and has some time look at the code than please let me know so I can upload it, and it will help me alot.

 

 

0 Kudos
Message 9 of 9
(3,154 Views)