Sorry folks but I would appreciate some help with writing data to the parallel port. I want to change voltages on two of these pins in order to control a stepper motor driver. I have followed Richard's instructions regarding the use of the parallel port which mentions that:
"... a suitable driver of this kind is InpOut32 which can be downloaded from here."
Unfortunately, clicking the "here" text leads nowhere. Nevertheless I found and downloaded the inpout32.dll on line (96.0 KB) and installed it in the LIB folder. Then when I run the following program ...
SYS "LoadLibrary", @lib$+"inpout32.dll" TO inpout32%
IF inpout32% = 0 ERROR 100, "Cannot load inpout32.dll"
SYS "GetProcAddress", inpout32%, "Inp32" TO `Inp32`
SYS "GetProcAddress", inpout32%, "Out32" TO `Out32`
port%=OPENOUT("LPT1:")
FOR A%=1 TO 5
SYS`Out32`, port%, &FFFF
WAIT 50
SYS`Out32`, port%, &0000
WAIT 50
NEXT
CLOSE#port%
PRINT"Data sent"
END
... it terminates correctly showing "Data sent" and without the "Cannot load inpout32.dll" message but the data pin voltages remain at 5V with respect to ground. Could this be because the dll file I have installed is inappropriate or is there something else I am doing incorrectly?
Any hints will be much appreciated!
Mark
Controlling pins on the Printer Port
Re: Controlling pins on the Printer Port
OPENOUT doesn't return a port address, it returns a channel number.
Use the appropriate port address for the port you want to control (I don't know what that is, but I'm certain Google does!).
It must be a pretty ancient PC to have a parallel port. I hope it's running a similarly ancient version of Windows, otherwise I think this is unlikely to work.
-
- Posts: 11
- Joined: Tue 13 Sep 2022, 09:13
Re: Controlling pins on the Printer Port
Hi Richard,
It is indeed an ancient PC running Windows XP but with the parallel port needed for my application. Thanks for your tips. In Control Panel I find that the port address for LPT1 is tabulated as:
RESOURCE TYPE SETTING
I/O Range 0378 - 037F
I/O Range 0778 - 077B
DMA 03
Google suggests that the parallel port address is usually 378h. I therefore modified my code to be:
SYS "LoadLibrary", @lib$+"inpout32.dll" TO inpout32%
IF inpout32% = 0 ERROR 100, "Cannot load inpout32.dll"
SYS "GetProcAddress", inpout32%, "Inp32" TO `Inp32`
SYS "GetProcAddress", inpout32%, "Out32" TO `Out32`
port%=OPENOUT("378h:")
FOR A%=1 TO 5
SYS`Out32`, port%, &FFFF
WAIT 100
SYS`Out32`, port%, &0000
WAIT 100
NEXT
CLOSE#port%
PRINT"Data sent"
END
Nevertheless, the data pin voltages remain fixed at 5V, rather than switching 0-5-0 etc. Any help with this conundrum would be much appreciated, otherwise I will not be able to control a stepper motor!
It is indeed an ancient PC running Windows XP but with the parallel port needed for my application. Thanks for your tips. In Control Panel I find that the port address for LPT1 is tabulated as:
RESOURCE TYPE SETTING
I/O Range 0378 - 037F
I/O Range 0778 - 077B
DMA 03
Google suggests that the parallel port address is usually 378h. I therefore modified my code to be:
SYS "LoadLibrary", @lib$+"inpout32.dll" TO inpout32%
IF inpout32% = 0 ERROR 100, "Cannot load inpout32.dll"
SYS "GetProcAddress", inpout32%, "Inp32" TO `Inp32`
SYS "GetProcAddress", inpout32%, "Out32" TO `Out32`
port%=OPENOUT("378h:")
FOR A%=1 TO 5
SYS`Out32`, port%, &FFFF
WAIT 100
SYS`Out32`, port%, &0000
WAIT 100
NEXT
CLOSE#port%
PRINT"Data sent"
END
Nevertheless, the data pin voltages remain fixed at 5V, rather than switching 0-5-0 etc. Any help with this conundrum would be much appreciated, otherwise I will not be able to control a stepper motor!
Re: Controlling pins on the Printer Port
Everything I once knew about the printer port I've long since forgotten, but isn't there some initialisation/configuration necessary before you can simply output data? Maybe a mode register and/or a direction register that needs setting, or something?
-
- Posts: 11
- Joined: Tue 13 Sep 2022, 09:13
Re: Controlling pins on the Printer Port
Thanks for your latest comments. Unfortunately this is all beyond me and, unless there is another guru on this forum who can help, I will be using a microcontroller to driver the stepper and communicate with the PC.
-
- Posts: 58
- Joined: Tue 03 Apr 2018, 19:34
Re: Controlling pins on the Printer Port
There's no mention of using OPENOUT in the manual, as i can see.
What happens if you change
to
Svein
What happens if you change
Code: Select all
port%=OPENOUT("378h:")
Code: Select all
port%=&378
-
- Posts: 11
- Joined: Tue 13 Sep 2022, 09:13
Re: Controlling pins on the Printer Port
Svein,
It works, it works, it works!
I really appreciate your making this suggestion. Now I can interface the stepper motor and proceed with my project.
Yippee,
Mark
It works, it works, it works!
I really appreciate your making this suggestion. Now I can interface the stepper motor and proceed with my project.
Yippee,
Mark
-
- Posts: 200
- Joined: Tue 17 Apr 2018, 21:03
Re: Controlling pins on the Printer Port
I have been following this thread with interest, but unfortunately could not offer any input. I am glad that it is sorted and you can now develop your software. I am intrigued as to what you want to control.
Kind regards Ric
Kind regards Ric
Kind Regards Ric.
6502 back in the day, BB4W 2017 onwards, BBCSDL from 2023
6502 back in the day, BB4W 2017 onwards, BBCSDL from 2023