I am wondering how to set the data pins on a parallel port high and low. I believe I could use PyParallel for this, but I am unsure how to set a specific pin.
Thanks!
I am wondering how to set the data pins on a parallel port high and low. I believe I could use PyParallel for this, but I am unsure how to set a specific pin.
Thanks!
I've made this function to control the pins individually (code derived from here and here):
You're talking about a software-hardware interface here. They are usually set low and high by assigning a 1-byte value to a register. A parallel port has 8 pins for data to travel across. In a low level language like C, C++, there would be a register, lets call it 'A', somewhere holding 8 bits corresponding to the 8 pins of data. So for example:
Assuming resgister A is setup like pins: [7,6,5,4,3,2,1,0]
C-like pseudocode
This idea follows through with PyParallel
p.setData is the function you're interested in. 0x55 converted to binary is
0b01010101
-or-
[L H L H L H L H]
So now you can set the data to a certain byte, but how would I sent a bunch of data... lets say 3 bytes 0x00, 0x01, 0x02? Well you need to watch the ack line for when the receiving machine has confirmed receipt of whatever was just sent.
A naive implementation:
Ok, that doesn't directly answer your question. Lets say i ONLY want to set pin 5 high or low. Maybe I have an LED on that pin. Then you just need a bit of binary operations.
Now lets clear that bit...
If these binary operations are foreign, I recommend this excellent tutorial over on avrfreaks. I would become intimate with them before progressing further. Embedded software concepts like these are full of bitmasks and bitshifting.