• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Need experienced programmer with LPT1

stewie

Gawd
Joined
Aug 29, 2000
Messages
701
Hello,
I am currently trying to write a program in Qbasic that sends signals out on the LPT1 to open or close a reed relay by sending a 5 volt signal to a certain pin and a certain time. I have the time set the way i want it, but now, how do i write the code to close all the pins on the lpt 1 that are open, and then open say pins 3-7 each one at a different time? I started using the OUT parport 0 command, but they are all still reading 5 volts without anything changing. Does anyone know the code to turn each pin on differently or how to do it? thanks in advance.
-Josh
 
Why Qbasic?

I'd be suprised if it's even capable of that kinda hardware controll.
 
what other languages would support it that it would be easier? have any reccomendations? thanks
 
stewie said:
what other languages would support it that it would be easier? have any reccomendations? thanks


Console C would do it awesome. What OS do you plan on running this on? WinXP is very particular about parallel port access.
 
fat-tony said:
Console C would do it awesome. What OS do you plan on running this on? WinXP is very particular about parallel port access.
Caveat applies to Win2K as well, and probably NT4 (due to HAL, I believe).

We kept Win98 machines around the labs at school just so we could avoid custom drivers and all that garbage
 
ASM, assembly... maybe?

I've never used ASM for port control though... I'm sure its possible. If you want hardcore control.
 
The point of the project it to hook up a printer cable to a 25 pin female connector, which behind that connector will be 4 wires coming out of 4 different pins with one ground wire. The idea is going to be to create a program to send a 5 volt signal to each pin at different times to close a circuit on a reed relay, which will then power a solinoid to slam a slide gate shut. (creating a velocotron to determine different objects masses and the mixes) I work at a power plant and we are trying to determine various densities of different materials throughout the boiler or cyclone.
Any help or links would be appreciated. there are a few replies, but nothing is telling me how to control the pins seperately.
thanks
Josh
 
I think you can buy kits that do this kinda stuff. like this although not sure what the software side of things is like.

edit: and here is the website for the software. VB by the looks of it. you gotta let the site open the popup window. kinda weird.
 
qbasic won't do it for you. It's unlikely it even gives hardware access, and the fact that it's interpreted will slow things down considerably (when dealing with thousands of a second intervals) and give you shabby precision. You'll want nothing higher than c/c++, which would be rather easy to use. Depending on your task, if you need as best precision as you can get, you'll have to use assembly to drive the port and have c/c++ deal with everything else, or do the whole thing in assembly. Hardware I/O is no easy task.
 
oh yeah, the way the parallel port works. You can't controll the data pins seperatly through different ports or anything of that sort. On the DB pins 0-7, theres a buffer in the controller that you can throw a byte at. Thats how you control the pins. if you want pins 0 and 1 high, you'd throw 0x03, which in binary has bits 0 and 1 high, everything else low. To switch back and forth you have to add up the bits to form the single byte you'll feed to the port.
 
I wouldn't reccomend using it of you can use C or something else, but QBasic will work with the LPT port. If I remember correctly, that's the language that was used in my dusty first edition Robot Builder's Bonanza, with a whole section on LPT port controlling.
 
achtung, the links don't appear, and i'm not using a pop up blocker.
Can someone create a start in c/c++ for this? I think i understand how you need to send binary to the different pins to have the turn on and off (i'm assuming they will be at ~5 volts when on 1, and at 0 they should be ~0 volts) am i correct? thanks again
 
Of course qbasic can output to the parallel port. It's just a matter of sending the right byte to the port. If you wanted pins 0 and 7 on then you would send 10000001b. That applies to any language, though. Assembly could definately handle it, but it would be very tedious. High level languages will do just fine.

I just found a bit of c code that I used to turn a relay off. You can change the value to whatever you want the pins to be. I used this in linux so I could give myself permission to access the port so that wasn't a problem. If you use an NT based windows then you will probably need to use some sort of specialized driver. Though an old 386 with msdos and qbasic would probably be sufficient. Anyway, here is the code.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <asm/io.h>

#define base 0x378           /* printer port base address */
#define value 0            /* numeric value to send to printer port */

main(int argc, char **argv)
{
   if (ioperm(base,1,1))
    fprintf(stderr, "Couldn't get the port at %x\n", base), exit(1);

   outb(value, base);
}
 
Back
Top