![]() |
|
#1
|
|||
|
|||
need help with printer port buffer !ok so im not the greatest programmer in the world, in fact in only in grade 12 but i am completely stumped on this problem. i need to make a program in c++ that is capable of input/output. the plan is to make a memory device ( a small one... 3bit) that will connect to a digital breadboard and than to the printer port. i got my memory device to work fine and i have a program that works, but as soon as i make an if statement that says if this number has been pressed than open the program it doesnt work. the printer ports buffer is automatically taking the number that is in the if statement and using it as the key.... making my device useless ! how do i get around the buffer ???
|
|
#2
|
|||
|
|||
Re: need help with printer port buffer !Quote:
Does it work or not. When I see a sentence with "but...", I immediately know to disregard everything before the "but". (Just my feeble attempt to keep things light.) But, seriously, maybe you can let us in on what you have done and what you have tried. (In other words, Show Us The Code!) Your description of what you are attempting doesn't give me much information (but maybe that's just me). I would like to think that a little more narrative on what you expect the program to do might help. I like to see projects that want to interact with something other than standard I/O devices, and I am really interested in seeing what it is that you would like to do and how you are approaching the problem. (Note that I'm not promising that I can help, although I will if I can. I'm betting that someone lurking around here might be able to offer some clues.) You might mention what compiler and operating system you are using. In cases like this it will probably make a difference to anyone who would like to help. Regards, Dave |
|
#3
|
|||
|
|||
Re: need help with printer port buffer !ok sorry about that im kinda new to this whole thing. so heres what i want to do. i want to design an electronic security key. using a device that plugs into my computer in the printer port. i have to do the following; 1) write a program that makes the key valid. 2) write a second program that uses the key to continue running or display information. and 3) the key has to use a digital logic circuit that can be plugged into the parallel port. it has to be able to write a small amount of information ( to validate the key) and read information (to use the key). ok so thats what i have to do, and here is what i have done so far. this program is meant to make the key valid.
CPP / C++ / C Code:
ok so those are the two programs that i have made thus far, i am obviously using c++ and i am using visual basic as my compiler, because it shows me what ive done wrong. ok for my device i am going to try to explain it as best i can. i have used three 7400 chips, that contain 4 quad 2 input nand gates. i have connected two of the gates together to form whats called an rs latch. if you go to google and look up the pin layouts the following will be a little easier to understand. i have hooked up pin 2 to pin 6, pin 3 to pin 4. that forms the rs latch, i do not know what to do with pin 1 or pin 5 as of yet. pin 7 goes to zero. i needed to make a buffer so that the computers built in buffers would not make my device null and void. so i hooked up pin 13 and 12, and those were also connected to pin 8. pins 10 and 9 are hooked up together, and than they run back to pin 6, so that the buffer is connected to the rs latch. pin 14 goes to positive. and pin 11 runs to a resistor (330kohms) which runs to an led so that i know if my device is working the way i want it to.. this is therefore my input. ok this is where i am right now. i am a little confused as to what i should do next. i know i need to hook up this device to a digital breadboard. please help me out. i would really really appreciate it. if theres something ive left out that does not make sense to you just say what it is and i will try to fix it, keeping in mind that i am a gr 12 student. thanks Last edited by LuciWiz : 09-Sep-2006 at 05:25.
Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
|
|
#4
|
|||
|
|||
Re: need help with printer port buffer !Quote:
The programs that you showed will not execute on anything after Windows 98, and I am not using any systems with operating systems that old. (So I might not be able to help you debug everything.) If you are running Windows 98 (or DOS or some such thing) and you are still interested, let me know and I will try to walk you through a few things. I can certainly help with the logic operation of the gates, etc., but the first things I need to know are: 1. What operating system are you using? 2. I assume you are running your logic with +5 volts to pin 14 of your chip, since those are the logic levels typical of parallel ports. Exactly what series chip are you using? All 14-pin DIP 7400 family gates have the same pinouts and logic functionality, but there are a few electrical considerations to take into account that may be somewhat different, depending on whether it is a 7400, a 74LS00, a 74C00, a 74HC00, a 74AC00, a 74AHC00 or whatever. Don't panic:any of them can be used; I would just like to have a little more information before you get ready to fire it up. (And I sincerely hope that "fire it up" will remain just a figure of speech. See footnote.) So: what exact device do you have? 3. Is the parallel port built into your motherboard or is it on a separate plug-in card? Do you know if it is bidirectional or not? Really old port cards on really old original PCs can be used, but they have a very limited functionality, whereas everything recent has other modes that are a little easier to use, but might be programmed a little differently for what you have in mind. Note (and this is important) some parallel port components are quite sensitive to external transients and static discharges. It is not really difficult to damage the port by hooking experimental circuitry up to it. Be warned. I have done it from time to time over the years and have not actually destroyed anything, so it is possible to do it safely, but it's also possible to screw up things. (As my ex-fighter pilot neighbor used to say: "No guts --- no glory!") In other words, if you are still going to need that port to use with a printer, then I would recommend trying to find a separate plugin card. On the other hand, I guess many (most?) printers these days are either USB or networked printers, so the parallel port is kind of just sitting there. I still would hate to see it damaged if it is built into the motherboard. 4. You will never see an LED turn on if you really have it connected to the output of a logic gate through a 330 K Ohm resistor. LEDs are typically rated for a maximum of something like 10 milliamps at a voltage of somewhere around 2 volts, but you can see them with as few as 2 or 3 milliamps. It varies, but those are typical values. (330 K Ohms gives you something like 10 microamps.) Something like 330 Ohms would give you a few milliamps, depending on the LED and the logic family. 750 Ohms might be a little more conservative, and most LEDs will work with the current levels you would get. (I am assuming a classical red or green LED, not one of those new-fangled white thingies.) If you connect the cathode of the LED (through a resistor) to a logic output and the anode to +5 volts, the LED will be "on" when the logic output is low and "off" when it is high. If you connect the anode of the LED (through the resistor) to the logic output and the cathode to ground, you the LED will be "on" when the logic output is high. This connection (anode to logic output) will not work very well with a 7400 or a 74LS00, since their ability to supply current from a high logic level is quite limited (only a few hundred microamps typically) compared to their ability to sink current with a low logic level (several milliamps). That's why I asked you what specific device you are using. The CMOS family of gates is pretty symmetric as to their drive characteristics. If you are still interested, I can give some clues as to the remaining logic hookups, and, maybe together we can work out the programming to set the external latch and read its value even if I can't duplicate your setup. There may be other gidforums members who can chip in (a little logic pun here) with some ideas also. Regards, Dave Footnote: It is a little-known fact that all electronic components are manufactured with a certain amount of smoke sealed inside the package. If, by some mischance, you let the smoke out, then it will cease to function. |
|
#5
|
|||
|
|||
Hardware description.Quote:
Pins 1 and 5 can be outputs from your parallel port that set and reset the latch. Make one go low and the other high. Then if you make both signals go high, the latch will retain its state (a one-bit memory). You need to connect the output of your latch to a different pin on the port that can be read by a program at some later time. I have attached a drawing that shows something that is based on your excellent description of the external circuitry. U1A and U2B are the cross-connected gates that make the "latch". I have not shown connections to the parallel port connector, since it's not clear that you can even do what you want with the software you showed. I just wanted to describe some of the effects of the logic connections. (I assume that with a knowledge of truth tables for the NAND gates and with a brief description of the circuit action that you can work your way through the "hows" and "whys". I'll just give the "whats".) The notation is as follows: Q is traditional name of latch or flip-flop output signals (I never figured out why). When Q is logic '1', the latch is said to be "set". When Q is logic '0' the latch is said to be "reset". On the drawing, I gave the other latch output signal the name of "QB". Most people refer to this as "Q-bar" and draw a Q with a line over it (the "bar"). It's easier to write about QB (if you are using text and not some typesetting program) than try to figure out how to show it, so that's what I use . My convention is that signals that are active-high don't have a 'B' at the end and signals that are active-low do have a 'B' at the end. (This is a personal convention, and is not part of any standard notation that you are likely to see anywhere in the solar system. Maybe on Pluto, but we all know what happened to Pluto. See Footnote. The signal "SB" (think of it as S-bar) is used to "set" the latch, and the signal "RB" is used to reset the latch. Since these signals have a 'B' at the end, they are active-low. Note that without any external signals attached, SB and RB are pulled high (inactive). When SB and RB are both high, the latch will stay in its present state. In its stable state, one of the signals, either Q or QB, is high, and the other is low. Now, if RB is inactive and if you make SB active (pull it down to logic zero) the Q output will go high and QB will go low, regardless of the previous state of hte latch. We say that the latch is "set". If you return SB to its inactive state, Q stays high and QB stays low, so the latch stays in its "set" state. If SB is inactive and if you make RB active (pull it down to logic zero) the QB output will go high and the Q output will go low regardless of the previous state of the latch. With Q low, we say that the latch is "reset". If you return RB to its inactive state and SB remains inactive, then the latch remains reset. I have shown U1C connected to the Q output, and the LED, D1, is connected so that when Q is high, (the latch is set), the LED will be on. I showed U1D with its diode connected so that if the signal named "PROBE" is high the LED will be on and if "PROBE" is low, the LED will be off. This spare gate can be used as a logic probe to see the states of all logic signals in this circuit. (Thus the clever signal name.) Resistors R1, R2, R5 are shown and are necessary for CMOS technology devices, since CMOS logic gates should never be left in a "floating" state with no signals attached. A particular application may or may not need these, but I always put them in (at least during development stages). Regards, Dave Footnote about Pluto: I heard that the reason that Pluto was kicked out of the solar system is that posts from Pluto on gidforums never used code tags even after numerous warnings, and somebody finally said, "That's it! You're banned!" Is that correct, Walt? Last edited by davekw7x : 09-Sep-2006 at 15:29.
|
|
#6
|
|||
|
|||
Re: need help with printer port buffer !1) i am using windows 98, because i really do not like using the port talk program, i always mess it up and well windows 98 lets me not have to use it
2) right now i am using a 7400, 14 pin chip, because that was all that i could find, nand gate wise in the store room. 3) i dont know for sure if the parallel port is built into the motherboard or not, but the computer itself is less than a year old... I have no idea what you mean by bidirectional, can you please clarify that. I figured out that this parallel port is sensitive to static charge, because i found that while i was building the above programs and just dry running them to see what they would do, without the device plugged in i was always getting random numbers. so i am presuming that, that has to do with static charge, and the ports sensitivity. Do you think that building a buffer, like i described in my last post is a good thing to do, that would allow current to only go one way, that way static charge should not interfear with my program again. My computer engineering teacher really doesnt care if we accidentally destroy a computer..... but i guess if it can be avoided thats the way i am going to go. lol. i really do appreciate your help, it is clearing up alot of problems that were breaking my mind because i had no idea how to fix them, and as long as your willing to continue helping me i will continue to listen to what you have to say. |
|
#7
|
||||
|
||||
Re: need help with printer port buffer !Quote:
Quote:
Quote:
If your port is built into the motherboard, then one of the BIOS screens will have something about "Integrated Parallel Port" or some such thing. In the BIOS for the computer there is probably a way to select SPP (Standard Parallel Port) or EPP (Extended Parallel Port) or some such thing. (If it's on a separate card that's ok, but you might have to do some experimenting to find the port's address.) The original parallel port (SPP) could not read back the values on the data pins (this functionality is not needed for talking to a standard "Centronics-interface" printer for which the oribinal ports were designed, but it might be useful for other kinds of devices). EPPs, that can read as well write to the data pins, are called "bidirectional". For your experiment, it doesn't really matter, since you can use one of the control port bits to read the state of the latch. Some experiments could be easier or more elaborate with bidirectional ports, but it's not necessary for now. I'm guessing that you have already looked up some of the details on the web. If not, you might start here: http://www.lvr.com/parport.htm. Follow the links that seem most informative. For example http://www.doc.ic.ac.uk/~ih/doc/par/doc/program.html You see, if you hook your latch SB and RB input pins to bits D0 and D1 of the parallel port data register (pins 2 and 3 of the parallel port connector), then you have to hook your latch Q output to somewhere that can be read (for example pin 1 of the connector can be read as D0 of the control register). Set and reset the latch by putting out the proper sequence on D0 and D1 of the data register, Then read the control register and see if D0 changes accordingly (Note that bit D0 of the control port shows the logic inverse of the state of pin 1). I would start by making sure I could get the latch set and reset without being attached to the computer. Just pull the SB signal low and see if the LED comes on (and stays on when you release SB). Then pull RB low and see if the LED goes off (and stays off when you release RB). You can connect the PROBE signal to the QB output and you should see that when SB and RB are both high the "Q" LED and the "QB" LED show opposite logic values. When you see that it's well behaved (and you understand exactly what is happening), then I think you are ready to hook it up to the parallel port. The "base address" of the port is the address of the data register. It can be 0x278, 0x378, or 0x3bc. In each case, the "control register" is two higher. Maybe you already know what it is (if not, you can probably get this information from one of the BIOS screens.) So, if your port is at 0x378 a program might go something like the following: CPP / C++ / C Code:
You could put this in a loop to continuously change latch state every time you press enter. The program could go through the loop a certain number of times, or it could be an "Infinite" loop that won't quit until you hit Ctrl-C. Get the idea? Make sure you can control the latch with program instructions (and that you can read in the value that shows what state it is in at each step). Now, I can't test this, but I hope that it's useful enough to get you started. Quote:
Let us know how it goes. I am really interested. Regards, Dave |
|
#8
|
|||
|
|||
Re: need help with printer port buffer !well a hard days worth of work has gotten me my three latches that i needed to build built. they work on a normal breadboard, i just plugged in the input and output pins into negative and positive switches and messed around to see if the latches work... and they do which is kool. im going to start my programming tomorrow, so i will more than likely have things i need to ask you tomorrow, as for right now i would like to know more about this capacitor idea, is it something i should be adding into what i already have, what i have right now is exaclty what i told you about earlier. how will it make my latch behave better ? i am rather intreagued with this matter, (sorry if i cant spell, im not so good with spelling..lol)
|
|
#9
|
|||
|
|||
Re: need help with printer port buffer !Quote:
Depending on the length of the wires from the +5v and ground to the 7400, changing logic levels of the signals can cause electrical transient noise that can affect the operation and stability of the latches. If everything works OK, don't worry about it (it's not for safety or any kind of electrical protection, but bypassing the power source near the IC is a standard practice.) Experience shows that it's always a good ides, but with simple gates (especially with the old and slow 7400 series devices) you probably won't have any problems. If you get into counters and other more elaborate circuits you might have to revisit the idea of proper grounding and power supply bypassing. The theory may or may not be something you are interested in (or ready for). You could check out sources on the web. Maybe something like this: Bypassing Regards, Dave |
|
#10
|
|||
|
|||
Re: need help with printer port buffer !i was wondering, if you could tell me about arrays, i have used them before but its been a little while and i want to be able to turn a number into binary and i think that using an array would be the best way to do so. i forgot my code at school so i will post it in the morning. but for now could you tell me about arrays, please
|
Recent GIDBlog
NARMY by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| printer / font color / windows programming | nicolas_qc | MS Visual C++ / MFC Forum | 0 | 03-Jan-2006 23:13 |
| Which Printer Do You Recommend ? | onauc | Computer Hardware Forum | 3 | 26-Oct-2005 21:32 |
| Serial port problem | chirayu | MS Visual C++ / MFC Forum | 0 | 07-Jul-2005 03:52 |
| Problem to read on a serial port | collinm | C Programming Language | 2 | 30-Mar-2005 01:42 |
| Bounded Buffering? | pablowablo | C Programming Language | 0 | 17-Jan-2005 05:51 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The