Author Topic: Need some help reading a schematic to work out best way to interface the port.  (Read 29294 times)

BassTeQ

  • Member
  • ***
  • Posts: 4
Hi all, I have a schematic (link at end of post), I'm trying to work out the logic required to read/write to/from the attached devices.

Looking at the info at the LPT port, I'm presuming numbers 1-7 are referring to the DATA register, not the actual PIN number, as pin Number 1 on the LPT is a CONTROL pin not a data pin.
And number 14,16,17 are PIN numbers, and are accessed by the CONTROL register.

The way this looks to work, and please correct me if I'm wrong is when one of the CONTROL pins is pulled high it switches the logic to the connected OPTP block. Eg:
  • set pin 14 high it will enable opto #3 and the DATA pins will need to READ the value
  • set pin 16 high it will  enable opto #1 and the DATA pins will need to WRITE

The PC's BIOS can set the LPT mode to SPP, EPP or ECP, which would be the best option?

With that assumption what would be the best way drive this logic using inpout32?
I've read I need to set bit 5 to 0 or 1 in the CONTROL register depending if we want the data pins to read or write.
Is this just a matter of sending the decimal value of a binary string "00000100" to the LPT+2 ?

So for instance;
  • To read from OPTO block #3, I'd need to send "01000100" to LPT+2 to enable reading on the DATA pins as well as setting PIN 14 (C1) so the correct OPTO is enabled. Now I can READ the DATA pins values
  • To write to OPTO block #1, I'd need to send "00100000" to LPT+2 to enable writing on the DATA pins as well as setting PIN 16 (C2) so the correct OPTO is enabled, then I can WRITE a value to the DATA pins.


I also read that on the CONTROL register BITS 0,1,3 are inverted, so does this mean when usually I'd need to write a 0 it now needs to be 1?

Sorry If I've confused things in my post, but hopefully by looking at the schematic what I've said might make some sense :P
I greatly appreciate any assistance.

http://i34.photobucket.com/albums/d150/BassTeQ/misc/WiringDiagram_zps84fdcfc6.jpg

Thanks
« Last Edit: May 28, 2013, 09:32:52 pm by BassTeQ »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
You'll have to test (use an ohmmeter) to find out if the schematic is correct.

CONTROL register BITS 0,1,3 are inverted - yes.

Use ECP to enable reading the data port's bits.

I believe you're correct about the rest.

BassTeQ

  • Member
  • ***
  • Posts: 4
Thanks for the reply!
Great to know I'm on the right track!

BassTeQ

  • Member
  • ***
  • Posts: 4
Hi just like to check then this logic is correct with inverted bits.

To set ALL bits to LOW I'd need to send "11010000"

To get 5v ONLY from C1, and all other pins remain low I'd need to send "10010000"
To get 5v ONLY from C3, and all other pins remain low I'd need to send "11000000"
To get 5v ONLY from C2, and all other pins remain low I'd need to send "11110000"

Thanks

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
You have it backwards, the LSB is on the right:

To set ALL bits to LOW send "00001011"

You can also read the port and use a logical operator to set or clear one (or more) bits.

To write 0 to C1 to set pin C1 high:

Input = Inp(base address + 2)
Output = Input AND 11111101
« Last Edit: June 03, 2013, 05:55:46 pm by Jan Axelson »

BassTeQ

  • Member
  • ***
  • Posts: 4
Thanks Jan,

I didn't realise in my binary to decimal function I already had logic to reverse the string before calculating the decimal value. I'm thinking left to right as it makes more sense logically to me, and the function corrects it :P

Cheers