View Full Version : EPP mode parallel port comms
cncmachineguy
- 29th June 2011, 16:45
Anyone ever do any handshaking and comm stuff with an EPP mode parallel port? I am working up a card to talk to EMC2 in comm mode rather then bit-banging the port and looking for any other efforts in this area.
mister_e
- 30th June 2011, 06:39
I did, the easy way is to use inpout32.dll lib with VB/C# or whatever else floats your boat
http://www.codeproject.com/KB/cs/csppleds.aspx
http://www.lvr.com/parport.htm (they also have a new wrapper for Win7 64 bits)
http://logix4u.net/Legacy_Ports/Parallel_Port/Inpout32.dll_for_Windows_98/2000/NT/XP.html
http://logix4u.net/Legacy_Ports/Parallel_Port/Inpoutx64.dll_for_WIN_XP_64_bit.html
should be enough :D
HenrikOlsson
- 30th June 2011, 08:44
cncmachineguy,
Are you looking for ideas/pointers for the PC-side of things, PIC-side of things or both?
Have you looked at Jon Elsons PPMC system? It uses the port in EPP-mode (I think), I don't know if he supplies the source code for the "EMC-driver" but it might be worth looking into.
Steve, EMC2 runs on Linux with a real-time kernal applied (not easy to know if you're not into the "CNC-thing") so anything Windows specific probably won't work in this case.
Also, in EPP mode the handshaking and transfers are done by the hardware itself, I'm not sure but I don't think INPOUT32 allows that type of control, I think it's more a brute force type of direct interface to the port register - but I might be wrong on that point.
/Henrik.
cncmachineguy
- 30th June 2011, 10:45
Hi steve, thanks for the info, but Henrik is correct.
Henrik, I haven't looked at that (maybe) but will do so. I never thought about getting tips for the Emc driver from here. Of course any help is always good. But I was actually fishing for info about the pic side. Doesn't look to be too hard, there are just a few handshakes and rules but I figured I will check with the vast knowledge here before jumping in to write it.
cncmachineguy
- 30th June 2011, 16:19
Ok, I went and looked at Jon's stuff. I have in fact looked at it before. It seems he has lots of EMC side stuff available there.
For the PIC side I wanted to use the PSP hardware, but I don't think I can. PSP has 3 handshake lines, /CS /RD /WR. As I understand it, EPP port has 4, /WR /DataStrobe /AddressStrobe and Wait.
/WR /DS /AS are inputs to the pic and Wait is output from the PIC. And of course the 8 data lines. /DS and /AS start a transmission as long as wait is low. So it seems to me it would make sense to have /DS & /AS as IOC then do the comm in an ISR. Now I am pretty sure at this point the uP won't be doing anything else while waiting for the PC to start a transfer, at which time data coming in can be sent directly to which ever port it needs to go to and data going out will just be ports reads and send.
I guess this is going to start out as a large I/O card with no smarts to speak of. So maybe just pool the /DS and /AS.
Hmmm... thoughts anyone?
cncmachineguy
- 2nd August 2011, 02:18
I have the comm part pretty well worked out between both PC and PIC. But now I have 2 more questions. First is really a yes or no kind of thing, Anyone know of a bootloader to be used with a parallel port? Even better if linux based.
Now to the harder, but much more conceptual question. I want to make my I/O card somewhat user configurable. At first I am just thinking about the user declaring pins as inputs or outputs. that leads me to the hardware side of how to have it be either. ie, I don't think I want a pull up on an output. Now on the software side I think that is not too hard, basically the user will be setting the TRIS using a GUI. then the correct variables get assigned and volia!
But now lets say they want to have a PWM output on 1 or 2 or eveb 4 of the pins. Any ideas how to code for that? I am not looking for actual code here, I am just stuck as to how to approach this.
mackrackit
- 2nd August 2011, 09:52
Maybe have the PC write to an EEPROM. Then at Pic boot time the EEPROM is read for a set of pre difined parameters ....
cncmachineguy
- 2nd August 2011, 11:27
Thanks Dave, but thats where my brain gets foggy. For instance I can see how I would put a timer value in the EEPROM, then read it at boot time. But what if the user doesn't want to use the timer at all? Do I have an IF NoTimer then skip the timer section? And then would this get checked every time through the loop? that seems like the wrong way to implement it. But I can't think how to do it.
mackrackit
- 2nd August 2011, 22:13
I think this is something like you want. It is quick and dirty with ON INT :eek:
' 18F6680 24FC1025
'<FL_PIC18F6680>'
DEFINE OSC 20
@ __CONFIG _CONFIG1H, _OSC_HS_1H
@ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
@ __CONFIG _CONFIG4L, _LVP_OFF_4L
DEFINE LCD_DREG PORTG
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTE
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTE
DEFINE LCD_EBIT 1
DEFINE LCD_BITS 4
DEFINE LCD_LINES 4
DEFINE LCD_COMMANDUS 3000
DEFINE LCD_DATAUS 150
PAUSE 1000
DPIN VAR PORTB.2 'I2C DATA PIN
CPIN VAR PORTB.1 'I2C CLOCK PIN
ADDR VAR WORD
DATI VAR BYTE[45]
DATO VAR WORD
BOOT:
LCDOUT $FE,1,"BOOTING"
ADDR = 1
'FOR TESTING DO A WRITE/READ TO THE EEPROM
'CHANGE THE VALUE IN I2CWRITE TO TURN THE
'TIMER ON OR OFF... THE SAME CAN BE DONE
'FOR T0CON FOR DIFFERENT PWM
I2CWRITE DPIN,CPIN,$A0,ADDR,[1]
PAUSE 100
I2CREAD DPIN,CPIN,$A0,ADDR,[INT_VAR]
PAUSE 100
INT_VAR VAR BYTE
INTCON.5 = INT_VAR 'ENABLE/DISABLE TMR0
T0CON = %10000000
ON INTERRUPT GOTO TLOOP
MAIN:
LCDOUT $FE,1,"RUNNING"
PAUSE 100
GOTO MAIN
DISABLE
TLOOP:
INTCON.2=0:TOGGLE PORTG.4
RESUME: ENABLE
cncmachineguy
- 3rd August 2011, 14:34
Thanks Dave, starting to have the fog clear a little now.
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.