• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Parallel Port Communication

Status
Not open for further replies.

huanyong

New Member
i am curious most applicatoin is using serial communication (interfacing with PC). Is there any method to use parallel communication in PIC(interface with PC)?

most of times i see the word " basic stamp", what does it means?
 

crust

Member
Serial communication is usually easier because it requires less pins and can go longer distances reliably. The basic stamp is a device that incorporates a PIC microcontrollor, a flash memory, and a few other parts. You program it with a basic like language. The pic contains an interpreter to run your program.
 

Hasan

New Member
if ur familiar with visual basic you can do this communcation serial or parrallel very easily tell me if ur interseted i have code in vb for both
 

RichardKhoo

New Member
hasan,
i'm also trying to do communication between my pic16f877A with parallel port using VB.
can you please enlighten me ?
as i've read thru some website, there are 3 types of parallel port. SPP,EPP and ECP.
i got 8 outputs from my PIC to be send into the computer

or u can email me also.. my email is [email protected]

thanks
 

Nigel Goodwin

Super Moderator
Most Helpful Member
RichardKhoo said:
hasan,
i'm also trying to do communication between my pic16f877A with parallel port using VB.
can you please enlighten me ?
as i've read thru some website, there are 3 types of parallel port. SPP,EPP and ECP.
i got 8 outputs from my PIC to be send into the computer

or u can email me also.. my email is [email protected]

thanks
How fast are you wanting to transfer data?, a 9600 baud serial connection will transfer 960 readings a second - and you can easily run PIC's (even in software) much faster than that. 115,000 baud is a standard serial port speed, that would move 11,500 reading a second.

If for some reason you really want to use a parallel port, you will need to use it as an enhanced port, standard parallel ports aren't bi-directional and you need to transfer a byte as two 4 bit nibbles.
 

RichardKhoo

New Member
nigel,
hhmm... i'm getting blur...
i don't need a very fast connection...
actually i also don't know about it..
but at least, i need to communicate with the computer first
then only i will know what is it all about...
 

Dialtone

New Member
Finding a really good and complete info site on parallel port operations is difficult. Beyond Logic seems to be one of the best around at explaning the general differences in SPP, EPP, and ECP port types but the devil is in the details.
SPP ports can be operated in a 2 way byte transfers, but you need to a program to manipulate the data & status registers of the port manually. 8 leads is enough for the data path but not enough for the control and status leads needed to properly operate.
EPP is somewhat easier in that the port has hardware that will perform the read/write operation automaticaly and very fast. All you do with program is read and write special EPP port buffer locations and the port controller generates all the necessary internal register settings for the function operation. In addition to the 8 data leads, only 3 additional external leads are used to send out the instruction (Data Read/Write & Address Read/Write) Just these 4 instruction types are offered but are quite sufficient to move lots of data very fast. I have built a peripheral controller using nothing more than decoder chips and register chips that functions quite well on a EPP port.
ECP is quite complex in its operation. Main advantage over EPP is that it allows for a data compression scheme to be employed and supports DMA data transfers. If you want to use ECP you are definately going to need some intelligence in the device to handle it

Dialtone
 

Exo

Active Member
RichardKhoo said:
nigel,
hhmm... i'm getting blur...
i don't need a very fast connection...
actually i also don't know about it..
but at least, i need to communicate with the computer first
then only i will know what is it all about...
If you dont need a very fast connection then it's best to use a serial connection. It uses only 2 pins of your pic wich is a lot better then 8 or more for parallel transfer.

Examples for both software & hardware serial code can be found at nigel's site
(www.winpicprog.co.uk)
 

Hasan

New Member
For parallel communication in VB, if ur using vb 6.0 u need to put a file in the system folder or sytem 32 folder in the windows section u can put in both ,, i dont remmeber.. now the question what is that file and what does it doo.. along with this is attached a zip file ..extract it and after extraction u will get a win95io.dll file put that file in the place i told u..now seach the net for a parrallel port moniter u will find it easily from that software u can easily see the status of all ur pins(parallel)
now when ur done try writing a code to just play with the parallel port ..ur monitor will give u the status of the bits...for the code u need to add a module and a function the details of which are given in the attached file ..i havet got the code now ..i will send if i find it..do this before u try to attach ur micocontroller with it ..once ur through with this exerxise u can easily figure out how to make some chages to ur code for that case

for serial communication its much more easier..in the vb environment right click the tab bar u wil get an option to add a componenet..u can also use the menu to add component...once u click it try finding MScom object its a biult in utility for serial com. u can use the msdn to hav more details in case of syntax and other options.. u now only have to write the code whose syntax is avaliable at msdn...
ok actually i am in a hurry i now i will not be avalible for a week do let me know if u guys stil got some problems
 

Attachments

TheAnimus

New Member
If your using windows NT based OS (ie XP/2k/.NET) then you will find you can't directly access the parallel port, this is because the CPU is executing your code in "Protected Mode" (ring 3) This is where the CPU has a table of address (called a bitmap), every time an address is about to be placed on the addres bus, the CPU checks the desired value, and makes sure that the code is allowed to access this. This stops programs going nuts and over writing system code. However, this also stops any program from directly accessing the parallel port. To get around this, you need to change the Input Output Permission Map, this needs a "Service" (a device driver, kernel mode code, call it what you like) to do this. This is fairly well documented in Dr. Dobbs and also on beyoundlogic, with craigs been a more elegant but more complicated implimentation.

If your using VB6.0 while u can't access the parport with any function. Its possible to make your own. Using the CopyMemory functions, you can manualy create the OP-CODES, this has been done somewhere, but i can't remeber were, i am sure google will turn it up, saves you needing a DLL just to do MOV cmd.
 

coma

New Member
I2c

im currently writting a program that writes to the parallel port in a serial manner, its using the I2C protocol, its not completely working but ill get there i hope and soon. but it does send serial data as bytes. if you want it just ask
 

RichardKhoo

New Member
ok guys,
i've started to try on the VB thing with the parallel port...
i'm using ECP parallel port...
i've tried the Data port, but cannot use...
BUT i tried on the Status port... everything is ok...
the Status port, 4 bits always on one... so, i short to ground...
i can see that it turns immediately...
but for Data port... it cannot change the value of the port...
anything i should do to make it change?

i use Parmon to monitor...
 

Dialtone

New Member
If Bios set up parallel port as ECP, then you need to set the ECP ECR (Extended Control Register) register for the mode the port is to run in. I found my system left the mode bits set to "000" meaning SPP output only. ECR register is located at port base address + h'402. Mode is in bits 7-5. settings values for bits 7-5 are as follows:
000=Standard Mode
001=Byte Mode (Bi-Directional)
010 Parallel Port FIFO mode
011=ECP FIFO Mode
100 EPP Mode
101=reserved
110 FIFO Test
111 Configuration Mode
Of all the modes, EPP is easiest to use. Only has 4 instructions and you do not need to worry about how the port does the work as it does it automatically. Program simply reads or writes to the EPP buffer hardware locations and the port controller does the rest of getting the data in or out.
If you want all the details go to Http://www.beyondlogic.org and dump/read all the articles on parallel port modes and it will become clear to you how to do things.
Dialtone
 

tektronica

New Member
Adapting interfaces

Hello. I'm posting this message to ask you for help on interfacing an 8 bits ADC (ADC08161) with my Athlon XP computer. My mother supports SPP, EPP and ECP; and for what i've read so far, I think EPP would be the best way to interface it. I've thought of a 16f870 microcontroller for working as a parallel register, but also a protocol translator. Do you have any ideas :idea: on the way to do it.

Another question, I've read te BeyondLogic article and now understand how my pc-program has to communicate to the port, but my question is how to set the port to work in the EPP mode, do i just need to do what Dialtone says, or anything else :?:

Thanks in advance to you all :D

PD here's the ADC datasheet
http://www.electro-tech-online.com/custompdfs/2003/12/ADC08161.pdf
 

Dialtone

New Member
Tek:
You have 2 choices to get things working EPP Mode
1. Set Port mode in BIOS to EPP (if that is a choice)
2. Set BIOS as ECP type and write the mode into ECR extended control register as described. BaseAddress + h'402
Either way, once the port is set up properly you simply write or read PortBaseAddress + 3 or 4 to get the 4 functions desired from an EPP port. I am doing it now on a project I am building and it works sweet. I am getting port data thruput in excess of 2 MBits/sec and that includes the O/S overhead. Running in pure DOS environment ups this to around 3-3.5 depending on the system.
A simple EPP order decoder can be built from a 74ls138 (or equivalent) 3/8 decoder chip by interfacing the Write/ AStrobe and DStrobe leads into the decoder inputs.
Dialtone
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top