electrodoc Posted February 11, 2004 Report Share Posted February 11, 2004 SAFETY FIRST!!NEVER CONNECT A PROJECT DIRECTLY TO YOUR P.C. ALWAYS USE OPTO ISOLATORS!!! THIS WILL SAVE MOTHERBOARD/PORT DAMAGE!Before trying this, disconect your printer it may damage it!!!!You can use your printer port as a controller for electronic projects. get QBASIC either from a dos disk or windows95/98 cd rom and run it then if you type in "out 888,1". This will send pin 2 of your printer port to +5 volts, to reset it back to 0 volts type in "out 888,0", The port has 8 binary outputs this is controlled by the "out" command. 888 is the number of the port you are addresing (printer port) and the second number corresponds to which of the 8 outputs you want going to +5 volts. to set all of the 8 outputs to + 5 volts type "out 888,255". this is a very handy tip because when i was trying to control a stepper motor from my P.C. i couldn't find anything simple in which to do it but there you go enjoy. also remember that this thing can switch states incredibly fast! and what ever you wish to interface can be done easily with a little basic knowledge of computer programing.There is also the "IN" command which will read the state of the printer ports particular bit so you can have full interaction with your P.C. and your projects, I've never used the "IN" command on a project but i've browsed notes in magazines etc so i know it's possible.Bye.. Rich... ;D Quote Link to comment Share on other sites More sharing options...
MP Posted February 12, 2004 Report Share Posted February 12, 2004 Actually, this needs a little more explanation if it is to work for someone stumbling across this for the first time.If you are controlling a stepper motor or anything else from the parallel port, you will need to fool the port into thinking it is connected to a printer. This is done by tying pin 10 (ACK) and pin 15 (ERROR) to a logic high with a pull-up resistor (4K7 works perfect). Pins 11 (BUSY) and 12 (PAPER_END) should be connected to ground. Pins 18 through 25 should also be connected to ground. I have never used opto-isolators on the data lines, but it is probably a good idea if you are not familiar with what you are doing or do not have limiting protection on your circuits.Now you can communicate through pins D0 through D7. These are pins 2 through 9. Pin 2 is D0, also known as the Least significant bit ot LSB. It represents either a 0 or 1. On a 4 wire stepper you will use 4 data lines per motor, for example, D0 through D3. Sending a 1 to the port brings D0 high, sending a 2 brings D1 high, etc.To make the motor turn, you send Binary numbers 0001, delay, 0010, delay, 0100, delay, 1000....(This was one step)... and repeat this for the total number of steps you need. Do not forget to add delays between these numbers or the motor will miss steps. The computer will send the bits to the port much faster than the motor can use them. You do not have to use binary numbers. You can send 1, delay, 2, delay, 4, delay, 8, delay.....etc. by using lprint chr$ (1);delaylprint chr$ (2);delaylprint chr$ (4);delaylprint chr$ (8);The semicolons tell basic to not add carriage returns or line feeds.How to generate a delay?delay:for x = 1 to 500 (or whatever you decide is a good delay time)next xreturn...and please.....find something better than QBasic.. ::)MP Quote Link to comment Share on other sites More sharing options...
electrodoc Posted February 12, 2004 Author Report Share Posted February 12, 2004 I didn't have to fool the port into thinking anything was connected to it i used a 386 DX 40, a 20 mb hdd with dos on it typed in Qbasic:-10 x = 120 Out 888,x30 pause .540 x = x+x50 if x => 16 then x=1 else goto 20this would revolve the stepper motor until you ended the program. the use doesn't end at stepper driving you could have pin 1 as a clock pulse and pin 2 as a data line.I think qbasic is perfect for this application as it is very much like spectrum/commodor/bbc 1980's programming languages and the help files are really handy with there copy and paste features which help when you're of the self teaching techy + the added advantage of only needing an operating system and the qbasic program itself.you could switch on the whole house from a floppy.I am open to other suggestions as regards a programming language but this was one i stumbled across whilst writing a bingo program and i was led to the "out" function whilst using the afore mentioned help files whilst writing it. Quote Link to comment Share on other sites More sharing options...
MP Posted February 12, 2004 Report Share Posted February 12, 2004 There is another form of basic that compiles your code to an exe file. It is much nicer than Qbasic because you just enter the name of the exe instead of going into the qbasic editor to run your program.In regards to the other: Using a 386 with only Dos loaded onto it is pretty rare for most of us who are reading these things from our tie to the internet. Most users are going to have a higher operating system. In such cases, the information in your tutorial is going to be invalid and cause lots of frustration. Therefore, I added the additional comments to your post. If you have a higher operating system (not dos only) your printer driver takes over the parallel port and you will have problems trying to communicate without fooling the port into thinking the printer is attached. Even when you use a Dos prompt in Windows, your printer drivers control the port.I actually wrote my stepper program in visual basic. There is a lot to be said of the user interface.I will look for the other quick basic and attach it to a post so you can compare.MP Quote Link to comment Share on other sites More sharing options...
MP Posted February 13, 2004 Report Share Posted February 13, 2004 Found it! The program is Quick Basic 4.5. Since it is not freeware, I will not post it. However, it is probably all over the net if you look. ;DWith this, you can copy all of your Qbasic code and paste it into this program editor, then click the compile button and you have an EXE file. This saves you from having to go into the Qbasic code and click run from inside the editor window.MP Quote Link to comment Share on other sites More sharing options...
electrodoc Posted February 13, 2004 Author Report Share Posted February 13, 2004 thanx again Mike. i got QB4.5 but when i try to run my program i'm getting a "String Space Corrupt". it's a shame because i've wanted my bingo program to run as stand alone, I may even make a 8X16 light box to display the numbers from the program to the people who are playing.i wrote this for the spectrum at first in exactly the same way as i have for the p.c. with the two arrays, as you can imagine when the specy got up to the 70th number or so it REALLY slowed down. so i got it to randomize 86 numbers of the full 90 then it only took 5 minutes or so LOL. (just enough time to sell the tickets and work out the winnings) at grandma's boxing day parties. however i was astounded at the low spec p.c. i rewrote it for. You don't even see the "Now randomizing ball number" screen come on! and thats randomizing all 90 numbers!If people out there can see the scope of what interfacing a p.c. and your projects can do, then go out and buy a little 386 or better still get one given you! or a 486 anything that will stand alone and run qbasic. Cheers Rich. Quote Link to comment Share on other sites More sharing options...
electrodoc Posted February 13, 2004 Author Report Share Posted February 13, 2004 If someone can make this an exe file that would be great!please mail it back to me as the stand alone file..you will need Qbasic to run this program and thats available in the win98\tools\oldmsdos directory on 98 cdrom. Qbasic works fine on 98 and all predisesors but i'm not sure about XP or Xtra Problems as i like to call it.There are no printer port commands in this program so no need to disconect your printer etc. p.s. when using the program make sure CAPS lock is on. and don't go selling it to a pub/club ok. 8)bingo.zip Quote Link to comment Share on other sites More sharing options...
electrodoc Posted March 27, 2004 Author Report Share Posted March 27, 2004 Had a bit of spare time so i did a sketch of a simple interface for the printer port.This was an original concept by myself to intergrate both my courses at college (electronics and I.T.) to control stepper motors in the cruedest of ways. It did work though and all the other guys where around my P.C. for .. ohhhh at least five minutes as i'd ask them where they wanted a pencil blue tacked to the top of the motor to point when it came to rest.With gearing however it would be very precise, speed was limited due to relay latency. speeds of appx 3 revs a second where attainable though. and it was only a pencil pointer after all.Ohh BTW this was some time ago and I have a nagging feeling that output 1 maybe the second hole in from the left on the top row. (someone shed light please). haven't time to look got to buy a setee (couch)..Bye Rich. P.S. still needing an exe file for my bingo program in last post ;D Quote Link to comment Share on other sites More sharing options...
electrodoc Posted March 27, 2004 Author Report Share Posted March 27, 2004 I'm Building a 8X8 LED graphics display at the moment ran on the same principle so more posts on this to come. If any one knows how to scan a character and return a value that i can output to the port then that would be most handyto make it clearer i know how to do the opposite ie for the letter L, it would be 1,1,1,1,1,1,1,255. but i need to input that letter then have some code which will scan it and then return that binary result.. Idea's please??? preferably qbasic code if poss.Cheers Rich :-* Quote Link to comment Share on other sites More sharing options...
MP Posted March 27, 2004 Report Share Posted March 27, 2004 Yes, Pin 1 of the Parallel port is the strobe line. Pins 2 through 9 are outputs D0 through D7 respectively.Also, I looked at your bingo program with a text editor and it looked like there were some unremarked comments in it, like the first line was "clear". It might be possible that if you go in and make sure all comments are remarked, it might compile. This was just a quick look and I did not get much farther than that.MP Quote Link to comment Share on other sites More sharing options...
Kevin Weddle Posted March 27, 2004 Report Share Posted March 27, 2004 Is the data transfer in a parallel port unidirectional? Does anybody experience how the newer generation of Windows makes it hard to get to the C: prompt? I have seen limitations using the MSDOS prompt. Sometimes I don't even want Windows to start. Quote Link to comment Share on other sites More sharing options...
electrodoc Posted April 2, 2004 Author Report Share Posted April 2, 2004 Yes there is the IN command ,but i've never played with this command so i'm not sure of the syntax, i'd say it's if in 888,1 >0 then etc etcwhat version of windows are you running kevin? Quote Link to comment Share on other sites More sharing options...
Kevin Weddle Posted April 2, 2004 Report Share Posted April 2, 2004 I am using one of the newest editions of WIndows. I work with XP and Millenium. By in do you mean an in to an out? The printer port can't receive data. Am I right? Quote Link to comment Share on other sites More sharing options...
electrodoc Posted April 2, 2004 Author Report Share Posted April 2, 2004 yes it can Quote Link to comment Share on other sites More sharing options...
Kevin Weddle Posted April 2, 2004 Report Share Posted April 2, 2004 I just read that the PS2 system is bidirectional and that this is an improvement. When they talk about I/O ports they are not implying bidirectional data. Am I right? Quote Link to comment Share on other sites More sharing options...
MP Posted April 2, 2004 Report Share Posted April 2, 2004 Yes. I/O refers to "Input"/ "Output". Ports are capable of two way communication.MP Quote Link to comment Share on other sites More sharing options...
electrodoc Posted April 3, 2004 Author Report Share Posted April 3, 2004 I/O actually stands for input and output so yes it is bidirectional as is the com port and the usb slots. if you can get a 286, 386 or a 486 P.C. (there usually given to you or at the most Quote Link to comment Share on other sites More sharing options...
MP Posted April 3, 2004 Report Share Posted April 3, 2004 Here is the Parallel Port. ;)MP Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.