Sunday, December 20, 2009

How to program pararel port with delphi


I believe this topic has been write so many times in internet and you can find so many articles about it, but i want to share my experience programming pararel port with delphi. I started to do this project when i was doing some vision system project in printing company. When i got this project i started to learn about programming pararel port with delphi. One good source that i´ve found is http://et.nmsu.edu/~etti/fall96/computer/printer/printer.html This is very good source. ( but it use C language ).
The easiest port to control and access in the computer is pararel port ( LPT1, LPT2, LPT3 ). You can use this port to control your home appliance, electricity , robotic and also you can use it to make data acquisition. This port come in with female DB25 connector ( ussualy ) pic like image below :


Pin # Pin Name Pin Description and Function
1 /STROBE Strobe
2 D0 Data Bit 0
3 D1 Data Bit 1
4 D2 Data Bit 2
5 D3 Data Bit 3
6 D4 Data Bit 4
7 D5 Data Bit 5
8 D6 Data Bit 6
9 D7 Data Bit 7
10 /ACK Acknowledge
11 BUSY Busy
12 PE Paper End
13 SEL Select
14 /AUTOFD Autofeed
15 /ERROR Error
16 /INIT Initialize
17 /SELIN Select In
18 GND Strobe Ground
19 GND Data bit 1 and 2 Ground
20 GND Data bit 3 and 4 Ground
21 GND Data bit 5 and 6 Ground
22 GND Data bit 7 and 8 Ground
23 GND Busy and Fault Ground
24 GND Paper out, Select, and Acknowledge Ground
25 GND AutoFeed, Select input and Initialize Ground

Today computer ussualy come with 1 pararel port and 1 address, but last time it can came with 3 pararel port and 3 address.The address of pararel port listed like below :
       Printer         Data Port     Status          Control 
           LPT1                    0x03bc                0x03bd                0x03be        
               LPT2                   0x0378                0x0379                 0x037a        
               LPT3                   0x0278                0x0279                 0x027a
My experience pararel port address is using $378 for data port and $379 for status and $37A for control port.
in order to make my program easier i use io.dll. an io.dll is small dll program that you can download it from internet. it is free and easy to use ( even i use it on win-xp operating system ). This program is small procedure / function to connecting your delphi program and your pararel port. Please put this io.dll in one folder with your application program.

The electronic things
we can use simple electronic circuit like schematic below to test our program. if you dont have electronic experience you can ask your friend who know about electronic circuit to assembly this schematic.
Programming
Write simple program in delphi like code below :

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Button1: TButton;
Button2: TButton;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
input1:integer;

implementation

function PortIn(Port:Word):Byte;stdcall;external'io.dll';
procedure PortOut(Port:Word;Data:Byte); stdcall; external'io.dll';

{$R *.dfm}
// this procedure to light on LED on port 378
procedure TForm1.Button1Click(Sender: TObject);
begin
PortOut($378,$01); //this will light on 1 LED on pin number 2, you can change this value
end;
//this procedure is to read any value from port 379
procedure TForm1.Button2Click(Sender: TObject);
begin
input1:= PortIn($379) xor $80;
Edit1.Text:= IntToStr(input1);
end;

end.

you can make some experiment with this circuit and programming with any programming language, in this story i use delphi.

Thursday, December 17, 2009

First Computer


What is this?...
it is first computer. what...???? yes it is first computer. iḿ surprise to see this first computer. today i surf the net and want to see whatś look like first computer. and finally i found this picture. So huge i think. like a bus size ha ha ha. comparing with my pc. This first PC called ENIAC ( Electronic Numerical Integrator And Computer ). Itś announce on 1946. First PC ENIAC contained 17,468 vacuum tubes, 7,200 crystal diodes, 1,500 relays, 70,000 resistors, 10,000 capacitors and around 5 million hand-soldered joints. It weighed 30 short tons (27 t), was roughly 8.5 by 3 by 80 feet (2.6 m × 0.9 m × 26 m), took up 680 square feet (63 m2), and consumed 150 kW of power. Wow it is so big, so heavy and so consume more power compare with today PC.

W32 / Virut experience

Long time never facing virus problem, until one day my friend ask me to help him to fix his PC. This PC came with very slow and cannot login. i restarted and try to login again and same problem coming. i suspect there is some virus there that may be destroy login application in WIN-XP. After take its hardisk and scan with AVG 9 and aha i knew it. yes its infected with W32/Virut virus. I ask my friend to perform clean install of WIN XP to get better and free from virus. He done what i said, but one of wrong step make this virus come back again, so terrible. Actually this virus still in drive D woah....finnaly i perform clean install of WIN XP and directly install antivirus there, after that install driver and application. and everything goes well. I said, i never facing virus experience anymore since i use linux. :)

Wednesday, June 17, 2009

Linux and me

Its, long time story. i know linux and try since in the college, at that time my friend trying to install red hat in his computer. At that time install linux is so difficult and its text base :). Fiuhhh need a lot of time. After sucessfull, we try it... and finnaly i dont understand anything. So i left it and forget about linux for several years. Last year, it around 10 years after i know about linux, i try my self.

My first trial is Mandriva, and then ubuntu, after that kubuntu, from all of this distro i choose PCLOS. Why i choose this ? because it is simple and easy to use..

Thursday, May 7, 2009

Internet Connection with W660i and PCLOS2007

I have search many times in internet to find tips or trick or tutorial how to connect internet with my Sony Ericson W660i and my komputer which using PCLOS2007 as operating system. And i cannot find any tutorial about this. I try to finding and collect many articles how to connect cellular phone with PCLOS2007 but none of them explain how to connect W660i ...( nearly surrender ). Until one day i found how to connect internet with my W660i and PCLOS2007 with little knowledge about PCLOS2007 and some cookies beside me and a cup of javanese coffee, i'm ready to explore this PCLOS2007. follow me how i do this.

  1. Step 1.
In your PCLOS2007 go to kmenu->internet->remoteaccess->KPPP just click on that menu it will show KPPP windows like this picture

  1. Step2
  2. Step3
  3. Step4