home equipment control using parallel port by lokesh kumar panear

27
HOME APPLIANCE CONTROL USING COMPUTER PARALLEL PORT 2 011 CONTENT S.NO . NAME PAGE NO. I Introduction II Controlling software III Programming IV Interfacing Software between c lang. & port V Operating Circuit VI Used part’s VII Step’s for finding port address VIII Result IX Reference 1

Upload: lokesh-panwar

Post on 03-Dec-2014

111 views

Category:

Documents


3 download

DESCRIPTION

in this document we get output form parallel port using c language

TRANSCRIPT

Page 1: Home equipment control using parallel port by lokesh kumar panear

HOME APPLIANCE CONTROL USING COMPUTER PARALLEL PORT 2 011

CONTENT

S.NO. NAME PAGE NO.

I Introduction

II Controlling software

III Programming

IV Interfacing Software between c lang. & port

V Operating Circuit

VI Used part’s

VII Step’s for finding port address

VIII Result

IX Reference

Introduction: -

1

Page 2: Home equipment control using parallel port by lokesh kumar panear

HOME APPLIANCE CONTROL USING COMPUTER PARALLEL PORT 2 011

Parallel port is a simple and inexpensive tool for building computer

controlled devices and projects. The simplicity and ease of programming makes parallel port

popular in electronics hobbyist world. The parallel port is often used in Computer controlled

robots, Atmel/PIC programmers, home automation etc .In other parallel port is a type of

interface found on computers (personal and otherwise) for connecting various peripherals. In

computing, a parallel port is a parallel communication physical interface. It is also known as

a printer port or Centronics port.

PC parallel port can be very useful I/O channel for

connecting our own circuits to PC. The PC's parallel port can be used to perform some very

amusing hardware interfacing experiments. The port is very easy to use when we first

understand two important points .

1. Before connecting hardware isolate our hardware and parallel port by isolator example

optocoupler.

2. Install any software for input and output interfacing because the orating window is secured

by industries we are not able to pass any value to hardware without installing this software so

we are using port95exe . This software is use to connect the hardware and turbo c for

working.

The Parallel Port is the most commonly used port for interfacing homemade projects. This

Port will allow the input of up to 9 bits or the output of 12 bits at any one given time, thus

requiring minimal external circuitry to implement many simpler tasks. The port is composed

of 4 control lines, 5 status lines and 8 data lines. It's found commonly on the back of your PC

as a D-Type 25 Pin female connector. There may also be a D-Type 25 pin male connector.

This will be a serial RS-232 port and thus, is a totally incompatible port.

Fig no.1 pin dia. Of parallel port

2

Page 3: Home equipment control using parallel port by lokesh kumar panear

HOME APPLIANCE CONTROL USING COMPUTER PARALLEL PORT 2 011

Parallel ports are personal computer interfaces that transfer data (generally) a byte at a time.

This contrasts with serial ports, that transfer data one bit at a time.

Fig no. 2 Comparison between serial & parallel port

Fig no. 3 Block diagram of working

3

Page 4: Home equipment control using parallel port by lokesh kumar panear

HOME APPLIANCE CONTROL USING COMPUTER PARALLEL PORT 2 011

Controlling software:-

For controlling the equipment we are use software in this project we are

disusing about c language. We are using function in c language for controlling.

Outportb (port add, value)

This function of c language it is use for control equipment and this function is present in

dos.h header file. In this function we pass two parameters first is port address and second

value. Value is the any integer value. Port address is finding we discos later.

Fig no.4 Flowchart of program

4

Page 5: Home equipment control using parallel port by lokesh kumar panear

HOME APPLIANCE CONTROL USING COMPUTER PARALLEL PORT 2 011

Programming :-

1. #include<stdio.h>

2. #include<conio.h>

3. #include<dos.h>

4. #include<graphics.h>

5. #include<stdlib.h>

6. void disp();

7. void main()

8. {

9. int gd=DETECT,gm;

10. clrscr();

11. outportb(0x378,0x00);

12. delay(50);

13. initgraph(&gd,&gm,"c:\\tc\\bgi");

14. setcolor(8);

15. rectangle(30,40,600,450);

16. setcolor(10);

17. settextstyle(1,0,7);

18. outtextxy(150,50,"B. K. BIET");

19. setcolor(5);

20. settextstyle(1,0,5);

21. outtextxy(40,150,"HOME APPLANSIS CONTROL");

22. setcolor(1);

23. settextstyle(1,0,1);

24. outtextxy(40,300,"GUID NAME:-");

25. outtextxy(40,350,"DINESH SONI");

26. outtextxy(350,300,"SUBMIT BY:-");

27. outtextxy(350,350,"1.LOKESH KUMAR PANWAR");

28. outtextxy(350,400,"2.RAJESH MALI");

29. delay(5000);

30. a:

31. clrscr();

5

Page 6: Home equipment control using parallel port by lokesh kumar panear

HOME APPLIANCE CONTROL USING COMPUTER PARALLEL PORT 2 011

32. cleardevice();

33. int i=0;

34. setcolor(11);

35. settextstyle(1,0,1);

36. outtextxy(200,100,"ENTER PASWARD");

37. printf("\n\n\n\n\n\n\n\n\t\t\t ");

38. scanf("%d",&i);

39. if(i==007)

40. {

41. disp();

42. }

43. else

44. {

45. goto a;

46. }

47. }

48. void disp()

49. {

50. int l=0,k=0,j=0,h=0,g=0,f=0,d=0,s=0;

51. char u,t;

52. b:

53. clrscr();

54. cleardevice();

55. setcolor(6);

56. settextstyle(1,0,1);

57. outtextxy(200,100,"x.ON/OFF EQUPMENT");

58. outtextxy(200,200,"y.HELP");

59. outtextxy(200,300,"z.EXIT");

60. t=getch();

61. switch(t)

62. {

63. case 'x':

64. p:

65. int inp=0;

6

Page 7: Home equipment control using parallel port by lokesh kumar panear

HOME APPLIANCE CONTROL USING COMPUTER PARALLEL PORT 2 011

66. clrscr();

67. cleardevice();

68. inp=inportb(0x378);

69. setcolor(YELLOW);

70. if(1==l%2)

71. {

72. outtextxy(150,50,"ON");

73. }

74. else

75. {

76. outtextxy(150,50,"OFF");

77. }

78. if(1==k%2)

79. {

80. outtextxy(150,100,"ON");

81. }

82. else

83. {

84. outtextxy(150,100,"OFF");

85. }

86. if(1==j%2)

87. {

88. outtextxy(150,150,"ON");

89. }

90. else

91. {

92. outtextxy(150,150,"OFF");

93. }

94. if(1==h%2)

95. {

96. outtextxy(150,200,"ON");

97. }

98. else

99. {

7

Page 8: Home equipment control using parallel port by lokesh kumar panear

HOME APPLIANCE CONTROL USING COMPUTER PARALLEL PORT 2 011

100. outtextxy(150,200,"OFF");

101. }

102. if(1==g%2)

103. {

104. outtextxy(150,250,"ON");

105. }

106. else

107. {

108. outtextxy(150,250,"OFF");

109. }

110. if(1==f%2)

111. {

112. outtextxy(150,300,"ON");

113. }

114. else

115. {

116. outtextxy(150,300,"OFF");

117. }

118. if(1==d%2)

119. {

120. outtextxy(150,350,"ON");

121. }

122. else

123. {

124. outtextxy(150,350,"OFF");

125. }

126. if(1==s%2)

127. {

128. outtextxy(150,400,"ON");

129. }

130. else

131. {

132. outtextxy(150,400,"OFF");

133. }

8

Page 9: Home equipment control using parallel port by lokesh kumar panear

HOME APPLIANCE CONTROL USING COMPUTER PARALLEL PORT 2 011

134. setcolor(9);

135. outtextxy(50,450,"ENTER 'b' FOR BACK WINDOW");

136. outtextxy(50,50,"PRES q");

137. outtextxy(50,100,"PRES w");

138. outtextxy(50,150,"PRES e");

139. outtextxy(50,200,"PRES r");

140. outtextxy(50,250,"PRES t");

141. outtextxy(50,300,"PRES y");

142. outtextxy(50,350,"PRES u");

143. outtextxy(50,400,"PRES i");

144. u=getche();

145. switch(u)

146. {

147. case 'q':

148. if(0==l%2)

149. {

150. int o1=0;

151. o1=inp+1;

152. outportb(0x378,o1);

153. }

154. else

155. {

156. int o1=0;

157. o1=inp-1;

158. outportb(0x378,o1);

159. }

160. l++;

161. break;

162. case 'w':

163. if(0==k%2)

164. {

165. int o1=0;

166. o1=inp+2;

167. outportb(0x378,o1);

9

Page 10: Home equipment control using parallel port by lokesh kumar panear

HOME APPLIANCE CONTROL USING COMPUTER PARALLEL PORT 2 011

168. }

169. else

170. {

171. int o1=0;

172. o1=inp-2;

173. outportb(0x378,o1);

174. }

175. k++;

176. break;

177. case 'e':

178. if(0==j%2)

179. {

180. int o1=0;

181. o1=inp+4;

182. outportb(0x378,o1);

183. }

184. else

185. {

186. int o1=0;

187. o1=inp-4;

188. outportb(0x378,o1);

189. }

190. j++;

191. break;

192. case 'r':

193. if(0==h%2)

194. {

195. int o1=0;

196. o1=inp+8;

197. outportb(0x378,o1);

198. }

199. else

200. {

201. int o1=0;

10

Page 11: Home equipment control using parallel port by lokesh kumar panear

HOME APPLIANCE CONTROL USING COMPUTER PARALLEL PORT 2 011

202. o1=inp-8;

203. outportb(0x378,o1);

204. }

205. h++;

206. break;

207. case 't':

208. if(0==g%2)

209. {

210. int o1=0;

211. o1=inp+16;

212. outportb(0x378,o1);

213. }

214. else

215. {

216. int o1=0;

217. o1=inp-16;

218. outportb(0x378,o1);

219. }

220. g++;

221. break;

222. case 'y':

223. if(0==f%2)

224. {

225. int o1=0;

226. o1=inp+32;

227. outportb(0x378,o1);

228. }

229. else

230. {

231. int o1=0;

232. o1=inp-32;

233. outportb(0x378,o1);

234. }

235. f++;

11

Page 12: Home equipment control using parallel port by lokesh kumar panear

HOME APPLIANCE CONTROL USING COMPUTER PARALLEL PORT 2 011

236. break;

237. case 'u':

238. if(0==d%2)

239. {

240. int o1=0;

241. o1=inp+64;

242. outportb(0x378,o1);

243. }

244. else

245. {

246. int o1=0;

247. o1=inp-64;

248. outportb(0x378,o1);

249. }

250. d++;

251. break;

252. case 'i':

253. if(0==s%2)

254. {

255. int o1=0;

256. o1=inp+128;

257. outportb(0x378,o1);

258. }

259. else

260. {

261. int o1=0;

262. o1=inp-128;

263. outportb(0x378,o1);

264. }

265. s++;

266. break;

267. case 'b':

268. goto b;

269. break;

12

Page 13: Home equipment control using parallel port by lokesh kumar panear

HOME APPLIANCE CONTROL USING COMPUTER PARALLEL PORT 2 011

270. }

271. goto p;

272. break;

273. case 'y':

274. m:

275. cleardevice();

276. outtextxy(50,250,"ENTER 'b' FOR BACK WINDOW");

277. u=getche();

278. if(u=='b')

279. {

280. goto b;

281. }

282. else

283. {

284. goto m;

285. }

286. break;

287. case 'z':

288. cleardevice();

289. setcolor(1);

290. settextstyle(7,0,5);

291. outportb(0x378,0x00);

292. outtextxy(200,200,"THANK YOU");

293. delay(1000);

294. closegraph();

295. exit(0);

296. break;

297. default:

298. goto b;

299. }

300. }

13

Page 14: Home equipment control using parallel port by lokesh kumar panear

HOME APPLIANCE CONTROL USING COMPUTER PARALLEL PORT 2 011

Parallel port and c language interfacing software:-

According to this name we are think that it is use to

interface. Today we are using so many operating systems in our computer like window 95,

98, 2000, Xp etc. they did not allow to read and write on parallel port. So we install driver for

read and write on parallel port in this project we are using port95.exe.

In other word we can say that it is a software which is use

to interfacing the parallel port and c language. It is necessary to install in our pc for working

on parallel port.

Fig no.5 Port 95 .exe window

Operating circuit:-

The idea of the interface shown above can be expanded to control

some external electronics by simply adding a buffer circuit to the parallel port. For

operatingany equipment we are using relay because operating equipment is work on high

voltage it is necessary isolate to our circuit. By programming we produce signal at the

parallel port this signal is not sufficient for relay operating. So for operating relay we are

using relay drying circuit. Which drying circuit is operating by separate voltage source.

14

Page 15: Home equipment control using parallel port by lokesh kumar panear

HOME APPLIANCE CONTROL USING COMPUTER PARALLEL PORT 2 011

Operating circuit

Fig no. 6 Circuit diagram

Isolated relay driving circuit:-

If you want to have a very good protection and of the parallel port and more

drive capacity you might consider optoisolation using the following type of circuit: The

opto-isolator is there to protect the port. Note that there are no connections between the port's

electrical contacts. The circuit is powered from external power supply which is not connected

to PC if there is no need for that. This arrangement prevents any currents on the external

circuits from damaging the parallel port.

15

Page 16: Home equipment control using parallel port by lokesh kumar panear

HOME APPLIANCE CONTROL USING COMPUTER PARALLEL PORT 2 011

USED COMPONENT

1.NPN switching transistors 2N2222; 2N2222A

FEATURES

· High current (max. 800 mA)

· Low voltage (max. 40 V).

APPLICATIONS

· Linear amplification and switching.

DESCRIPTION

NPN switching transistor in a TO-18 metal package.

PNP complement: 2N2907A.

2. OPTOCOUPLER [EL817 Series]

Description

The EL817 series contains a infrared emitting diode optically coupled to a phototransistor. It

is packaged in a 4-pin DIP package and available in wide-lead spacing and SMD option.

Features:

16

Page 17: Home equipment control using parallel port by lokesh kumar panear

HOME APPLIANCE CONTROL USING COMPUTER PARALLEL PORT 2 011

• Current transfer ratio

(CTR:MIN.50% at IF =5mA ,VCE =5V)

• High isolation voltage

between input and output (Viso=5000 V rms )

Fig no. 7 optocoupler IC EL817 Series

Applications

• Computer terminals

• System appliances, measuring instruments

• Registers, copiers, automatic vending machines

• Cassette type recorder

• Electric home appliances, such as fan heaters, etc.

• Signal transmission between circuits of different potentials and impedances

17

Page 18: Home equipment control using parallel port by lokesh kumar panear

HOME APPLIANCE CONTROL USING COMPUTER PARALLEL PORT 2 011

Fig no. 8 Internal diagram of optocoupler IC EL817

3. Parallel port:-

A parallel interface for connecting an external device such as a printer. Most

personal computers have both a parallel port and at least one serial port.

On PCs, the parallel port uses a 25-pin connector (type DB-25) and is used to connect

printers, computers and other devices that need relatively high bandwidth. It is often called

a Centronics interface after the company that designed the original  standard  for  parallel

communication between a computer and printer. (The modern parallel interface is based on a

design by Epson.) A newer type of parallel port, which supports the same connectors as the

Centronics interface, is the EPP (Enhanced Parallel Port) or ECP (Extended Capabilities

Port). Both of these parallel ports support bi-directional communication and transfer rates ten

times as fast as the Centronics port.

4. RESISTANCE’S

18

Page 19: Home equipment control using parallel port by lokesh kumar panear

HOME APPLIANCE CONTROL USING COMPUTER PARALLEL PORT 2 011

SNO VALUE QUANTITY

I 470 ohm ,0.25 w 2

II 4.7 kilo ohm ,0.25 w 1

Finding port adders:-

STEP 1: Right click on my computer and go to properties.

STEP 2: And go to Hardware and click on Device manager

STEP 3: After select ports (COM & LPT) and go to Printer ports

19

Page 20: Home equipment control using parallel port by lokesh kumar panear

HOME APPLIANCE CONTROL USING COMPUTER PARALLEL PORT 2 011

STEP4: Now click on Resources and given below window will appear and choose port

address (like 0378)

20

Page 21: Home equipment control using parallel port by lokesh kumar panear

HOME APPLIANCE CONTROL USING COMPUTER PARALLEL PORT 2 011

Result:-

We have successfully implemented this software and hardware. It is working as per

our requirement. This software had been made using C language programming. For making

this software easy and interactive we have used graphics in C language. Hardware operate by

9 volt dc battery supply and for isolating purpose we have used optocoupler which isolate

parallel port and external supply.

Reference:-

www.google.com

www.codeproject.com

www.hardwaresecrets.com

www.electrofriends.com

www.wikipedia.com

Parallel port complete: programming, interfacing & using the PC's by Jan Axelson

Programming the parallel port: interfacing the PC for data ... by Dhananjay V. Gadre

21