Hi everybody, Can you help me. I've got a "little" train (model making) and I would like to know if someone has docs about programming through the paralell port (or serial), because I would like to control the locomotives with a ASM program (or in C/C++ if you have but I prefer ASM). For example, i would like to change the voltage between 2 "pin" (or "spit", I don't know how we must say because in my dictionary, there are thses 2 words). (But you can send me all the help about it) Thanks a lot... Vom-bonjour:-() adr@:Thomas-Vidal@wanadoo.fr
For parallel port info, the place to look first is: http://www.lvr.com/parport.htm Under Win9x, from asm, all you need do to control the IO ports is use the IN and OUT instructions. BUT... I happen to know a bit about your intended application. I once has the model railroad bug myself. It is a bad habit, I was scratch building trolly cars, building track from rails and ties, even building the track switches... PLUS the overhead wire (which had to work as I used it for power). The actual work the computer has to do to control the trains is really minimal, just a very few decisions, perhaps as low as one per second. Using asm to do this is way overkill... I'd honestly suggest VB for rapid development. Where asm COULD be useful is... INSIDE the models themselves. There are systems for off the self sale that drive some large number (like 32) 'locomotive' models off a common steady DC power on the rails. The power source adds a high frequency signal to the DC power, the signal encodes a device number, speed, direction, and whatever else. Each self-moving model has enough electronics inside to decode this signal and control it's own drive motor. So, instead of traditional wiring of block sections to switches, and maybe 2 or 3 power usits being switched in, the same power goes everywhere on the layout. Each train waits it's own signal to move or stay put. This type of small controller needs a different processor. Check www.microchip.com for devices such as the PIC12C508. This is an 8 pin package with a full computer inside, and after adding power and ground this chip can give 6 pins for either input or output (software configured). Quite useful devices indeed. I'll stop here... either I've confused you or missed the mark. But do enjoy and good luck.
I've been playing around some time with software & harware for parallel port I/O, and I guess the parallel port should work fine for this things because it has 8 parallel data outputs (and some more if you need them) which produce output values of 0V or 5V. However, you can draw very little current from the outputs so you will need some extra hardware for this. IN and OUT can be used in win 9x, but this is slow and doesn't work in NT. You can use WinIO (www.internals.com) to use ins and outs, my masm-addition to winio is at www.exagone.f2s.com/tempdata/AsmIO.zip. This works fine for me. More info about the PC's port at www.beyondlogic.org Hope this helps, Thomas
Thank you, I will try...
Hi you, I thank you very mutch, because now I manage to activate 5V to the 8 DATA pins. So I will put 8 LEDs on it, with a prog which shows red or green when I activate the PIN. So when you send 00h to the 378h (LPT1) address port, it reset the 8 PINs (it turn off the 8 LEDs). Byte to Send PINs activated 00h none 01h PIN 2 (because DATA PINs are 2 to 9) 02h PIN 3 04h PIN 4 08h PIN 5 10h PIN 6 20h PIN 7 40h PIN 8 80h PIN 9 To activate the PINs 2 and 5 (i.e) send 09h (01h+08h). To activate the PINs 3 and 8 send 42h (02h+40h). But, to connect a LED, I will not put a resistor because with a resistor 4.7k, the light is very low, so I connect the LED directly. And I was wondering if we can send data on the PINs to make as if it was an interrupt (ON/OFF) ??? Thanks for your help, it was very usefull. Vom-bonjour:-()
Connecting LEDs directly might cause some problems, you can source about 5 mA (if I remember correctly, see beyondlogic.org). I don't know how much current your LEDs use but if you exceed the limit you might damage the parallel port. You'd better use some resistors+transistors to control your LEDs. What do you exactly mean with sending data like an interrupt? Thomas
PLEASE STOP THAT !!!! The pins of your parallel port are not made to drive a LED. You might damage them that way. That would be a tragedy. You need some sort of current buffer between the computer pin and the LED. This could be something like a transistor, a TTL IC, or an Advanced CMOS (personal favorite) IC. I don't know where you are to advice you on which components might be easily available to you. If you give me an idea, I'll make some suggestions. I'd email you some schematics to play with if you email me (see my link there?) with your address.
OK, i'm sorry, I thought i could connect the LEDs directly. So i won't do that. I mean with interrupt : a switch in fact (I didn't know how I should say, i'm French, excuse me) Vom-bonjour:-()
Ah ha, i finally feel like i can contribute :) First off, i totatly recomend BUFFERING your output though a 30cent chip 74LS244 (8-Bit OCTAL BUFFER). Directly wire D0-D7 to chip pins 2,4,6,8,11,13,15,17 respectively. Ground Pins 1, 19. The BUFFERED output pins are d'0-d'7, pins 18,16,14,12,9,7,5,3 respectively. You can power this off your PC if you chose (you will only destroy your 30 chips if you stay in the land of low voltages. (5 volts or so..) Off these outputs, To drive any Led's use 560 or 680 ohm resisters in series with EACH led you use (you can buy resiter packs for this purpose 8 restisters in parallel and one common ground pin all in one package). For input purposes on the same d0-d7 pins, uses ALMOST the same configuation in parallel.. that is add a second set of wires from d0-d7 respectivly off the port to the OUTPUT BUFFERED PINS of another 74LS244 chip, and use the BUFFER INPUT PINS of that chip for all TTL (5 volt) signals to be read as input. THE CATCH IS.. pins 1 and 19, recomended to be grounded for output buffering, are now CONTROL GROUNDED by the cpu on PIN 1 of the parallel port (~STROBE). This is to ensure that the buffer will STOP BUFFERING when the CPU is in the process of reading the data off the port (from an ASM call) ~ thus sorta freeezing time in the ports eyes when reading data in, once done the stobe will fall to gound again and allow buffering to continue. So with 2 chips and a few resisters you got and entire TTL I/O system ready for your disposal. To drive any serious switching AFTER the buffer, i recomend using NPN BJT transisters with Emitters to Ground, Base to the BUFFERD OUTPUTS and Collector in series with a 4.7K resister to 5V. The transisters will invert its input, that is, the voltage on the collector will be 5v if the value is a 0, else ~0.2 v if the output is 1. (Again, remember theses voltages area all referenced with respect to ground). For higher power stuff (ie 120v), buy a relay ~5$ at best, and drive the realys off the transister ( you may need to recalculate collector resistance, depending on the relay ). The relay terminals are then used for power switching. (The reverse is also true for input) Lastly for switching inputs (low voltage), use a 10K resister to 5V and a switch to the inputs like so: 5Volts R R - 10K R Input ---O / SWITCH O I GROUND This will provide a low current input for 5 Volt signals when the switch is open, and alow the chip to sink current to a grounded input when the switch is closed. Anywho.. That should get you up and going.. Good Luck.. PS: Did i hear you all right that IN and OUT will for in a windows environment IE] click on a button and data is on the Parallel Port??? I have been under the understanding for eons now that its RESTICED by microsofts Driver manager stuff?? NaN
Well my spaces got axed on the pic.. but its still good enought, just note the resister is intended to be over the 'o' of the switch (same with the lower ground lead). And a final thought, my only guess work there is the 560ohm 680ohm resister.. I dont remember the min current value of an LED but once this is known chose a resister using ohms laws such that: Resister used ~= 5 Volts / (min Current value*1.10) the 1.10 is to allow for a 10% higher current (basically brighten it a bit)... Again hope this is helpful NaN
Hi everybody, First, I want to thank all the people who helped me, it was very usefull and Thanks for having told me not to wire directly the LED,so I will buy some resistors and others. It was a great help. NaN, you asked if I managed to send data by clicking on a button, YesI managed, I made 16 buttons (2 for each DATA PIN : On & OFF). If you want send me a mail and I will send you the prog. In fact, I used the prog that Thomas made (look above) at www.exagone.f2s.com/tempdata/AsmIO.zip (you must download a library : winio.dll & .lib. It is used for the KeyBoard (I don't remember the address, but I put 378h for the Parallel port 1 and I send DATAs I told about above). In fact, the only problem I had is the translation I have to do (i'm French) of some words but I succeed in it. Thanks. Vom-bonjour:-() PS:Anybody have progs about it made in VB (6 or other) because I prog also in VB, but since I know WinASM32, I let the VB (since a few months.) I prefer now WinASM32, because it hasn't Dlls independant (MSVBVM6.dll, ...) and I find it more rapid. (I'm not sure it's really more rapid but I think).
It happens I wrote an .ocx to do port access from VB. I can't really test it myself because I don't have my my IO hardware now. It's tiny (12K or so) and written in asm. You use it like any other component in VB, In Project | Reference you add it, make a global var for it. Then it lets you Peek (read) or POke (write) bytes, words, or dwords to the IO. (Parallel port only wants bytes I believe). I'll mail it to you. Umm, I'll mail it later, when my mailsever comes back online :-D
vom-bonjour: To make a switch you'd either have to save the last state of a pin, then when you want to swtich, you invert the saved state and output this value. You can also read the current port value with getportval from winio (you can read back the last written output byte), then xor the return byte with the port bit to invert it, and output this with setportval. Thomas