From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I control individual data pins in a parallel port using VISA? i.e i want to use the parallel port as a set of serial ports.

Hi Can you tell me what u mean by a set of serial port? There's a lot examples u can find inside Labview software. Go to "help" menu, then xhoose examples, and find thru parallel or serial port in search.
 
Clement
Message 2 of 13
(3,999 Views)

Hi Astro, what i really want to do is to control few (3-4) of the parallel port data pins independently to send/write chain of bytes/words and clocking them. For example, i want to write a chain of strings to one pin (for exmple D0) of the parallel port and a clock in pin (for example in D1) at the same time. The reference to a serial port came because in a serial port (using serial.vi) you can write a byte/word to the a serial port pin but if you do the same to a parallel port (using serial.vi), the data distributes to (D0-D7) as it should. Any help is appreciated.

Sun

Message 3 of 13
(3,987 Views)
To do what you want, you would have to break up your bytes into bits.  To add a clock, you would have to shift your clock bit to D1 (same as multiply by 2), and then "or" it with the data bits.  This will produce a clock on D1 and data on D0.  However, there is more manipulation to do on the data bit stream.  If you want to clock in the bits, lets say on the clock rising edge, you would have to extend the data bits so that the bit is set on D0 while the clock is low, then keep the same bit while the clock goes high.  Set the next bit on the next clock low.  Here is an example data byte set:
 
Lets say you want to clock in data 0101, with the LSB clocked in first.  The bytes you would have to write to the serial port would be such that data was on D0 and clock was on D1.  It would look like this:
byte1: 0000 0001  - LSB data bit is set on D0, clock on D1 is low
byte2: 0000 0011 - same LSB data bit, but now the clock is high.  This signals the receiving end to read the bit on D0.
byte3: 0000 0000 - next bit on D0, clock low
byte4: 0000 0010 - bit is clocked in
byte5: 0000 0001 - next bit set with clock low
byte6: 0000 0011 - bit is clocked in
byte7: 0000 0000 - last bit is set with clock low
byte8: 0000 0010 - last bit is clocked in
 
So you can see that to clock 4 bits, your need to send 8 bytes.  This is a bit complex to code in Labview but I've done this in the past.  Try it.  Break the bytes into bits and tackle one bit at a time.  Each bit must be joined with clock low and then clock high to form two bytes.  If you have any more questions, post your code and we will look at it.
 
- tbob

Inventor of the WORM Global
Message 4 of 13
(3,974 Views)
tbob is spot on.
 
Built this vi to create the parallel port databyte stream from a string.
 
This will get you started for the D1 and D0 case.
 
Hope this helps
 
David
Message 5 of 13
(3,963 Views)
David thanks a lot for attaching the code. I will look at it and let you know of the results.
Sun
Message 7 of 13
(3,931 Views)
These examples have helped me a lot.  Thank you David, and Bob!

I need my clock signal to be on D0, and my data to be on D1, I will also need a control bit.

What is my best option?  Rearrange the array, or build it in a different way?

I am very new to LabVIEW, so this might be a basic question?  Here is my slightly modified version of Davids example.

But like I said, I need the bits inside the bytes to be in a diff. order.  any suggestions?
Message 8 of 13
(3,813 Views)
Wow, sat a looked at it for a while.  I figured out how it works!  haha, that was pretty simple.

I just multiplied the data by 2 instead of the clock!

Thanks again!
Message 9 of 13
(3,802 Views)

Does the control bit vary between 1 and 0?  If so, then it may be best to build a separate array for control bits.  Send into the loop, and multiply times 4 to put it into the bit2 position.  Feed it into the OR gate that builds the bytes out of the bits.  You can make a three input OR gate by using the Compound Arithmetic function.  Right click to choose OR function and expand to three inputs by dragging the lower border.

If control bit is always 1, just send a 4 into the OR gate.

- tbob

Inventor of the WORM Global
Message 10 of 13
(3,801 Views)