18.07.2013 Views

TEMPERATURE INDICATOR USING AT89C52 - Kits 'n' Spares

TEMPERATURE INDICATOR USING AT89C52 - Kits 'n' Spares

TEMPERATURE INDICATOR USING AT89C52 - Kits 'n' Spares

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

c o n s t r u c t i o n<br />

c o n s t r u c t i o n<br />

temperature indicator<br />

using at89c52<br />

AdityA RAne<br />

Here’s a microcontroller-based tem-<br />

perature indicator that displays the<br />

temperature in the range of –55°C<br />

to 125°C. Besides <strong>AT89C52</strong> microcontroller,<br />

it uses a temperature sensor chip and an<br />

LCD module. The indicator outputs the<br />

calibrated data in digital form. The program<br />

for the microcontroller is written in C and<br />

not in Assembly language. Since C program<br />

has well-defined syntax, it far outweighs<br />

Fig. 2: Circuit diagram of temperature indicator using <strong>AT89C52</strong><br />

electronics for you July 2004<br />

Fig. 1: Block diagram of temperature indicator using <strong>AT89C52</strong><br />

the merits of the Assembly<br />

language program.<br />

the circuit<br />

Fig. 1 shows the block diagram<br />

of the temperature indicator<br />

using microcontroller<br />

<strong>AT89C52</strong>. The power supply<br />

for the circuit is regulated<br />

by IC 7805 and supplied to<br />

different parts of the unit.


Parts List<br />

Semiconductors:<br />

IC1 - 7805 regulator IC<br />

IC2 - <strong>AT89C52</strong> microcontroller<br />

IC3 - DS1621 temperature sensor<br />

D1-D4 - 1N4007 rectifier diodes<br />

LED1 - Red LED<br />

Resistors (all ¼-watt, ±5% carbon,<br />

unless stated otherwise):<br />

R1 - 1-kilo-ohm<br />

R2 - 47-kilo-ohm<br />

R3 - 10-kilo-ohm<br />

R4, R5 - 4.7-kilo-ohm<br />

VR1<br />

Capacitors:<br />

- 1-kilo-ohm preset<br />

C1 - 470µF, 25V electrolytic<br />

capacitor<br />

C2, C3, C4 - 0.1µF ceramic disk<br />

C5 - 10µF, 16V electrolytic<br />

capacitor<br />

C6,C7 - 33pF ceramic capacitor<br />

Miscellaneous:<br />

Transformer - 230V AC primary to 0-9V,<br />

250mA secondary<br />

Crystal - 12 MHz<br />

LCD - 16×1 LCD module<br />

S1 - On/Off SPST switch<br />

DS1621 is the temperature sensor chip. The<br />

microcontroller unit (MCU) reads the temperature<br />

from the sensor. The temperature<br />

data is compared with certain user-defined<br />

temperature values and processed inside<br />

the MCU as per the program and then sent<br />

to the LCD for display.<br />

Fig. 2 shows the circuit of temperature<br />

indicator using microcontroller <strong>AT89C52</strong>.<br />

Working of each section of the circuit is<br />

covered in the following paragraphs.<br />

Power supply. The power supply unit<br />

consists of a step-down transformer (230V<br />

AC primary to 0-9V, 250mA secondary),<br />

bridge rectifier and voltage regulator. The<br />

output of the transformer is fed to bridge rectifier<br />

diodes D1 through D4 (each 1N4007).<br />

The ripple from the output bridge rectifier is<br />

filtered by capacitor C1 and fed to regulator<br />

IC 7805. The regulated output is given to<br />

the temperature sensor, microcontroller unit<br />

and LCD module, respectively.<br />

When switch S1 is closed, LED1 glows<br />

to indicate the presence of power in the<br />

system.<br />

Temperature sensor. Temperature sensor<br />

chip DS1621 (IC3) is an 8-pin DIP IC.<br />

Its pin details are shown in Fig. 3 and the<br />

internal block diagram in Fig. 4. The chip<br />

can measure temperatures from –55°C to<br />

+125°C in 0.5°C increments, which are<br />

read as 9-bit values. It can operate off 2.7V<br />

to 5.5V. Data is read/written via a 2-wire<br />

serial interface. Pins 1 and 2 of the temperature<br />

IC are connected to pins 11 and 10 of<br />

the microcontroller, respectively.<br />

Fig. 3: Pin details of IC<br />

DS1621<br />

The thermal<br />

a l a r m o u t p u t<br />

(T out ) of IC DS1621<br />

activates when<br />

the temperature<br />

exceeds user-<br />

defined high temperature<br />

TH. The<br />

output remains<br />

Fig. 4: Internal block diagram of IC DS1621<br />

Fig. 5: Pin details of IC <strong>AT89C52</strong><br />

active until the temperature drops below<br />

user-defined low temperature TL. User-defined<br />

temperature settings are stored in the<br />

non-volatile memory. Temperature settings<br />

July 2004<br />

c o n s t r u c t i o n<br />

and temperature readings are all communicated<br />

to/from IC DS1621 over a 2-wire<br />

serial cable. The most significant bit (MSB)<br />

of the data is transmitted first and the last<br />

significant bit (LSB) is transmitted last.<br />

Addressing. The chip address of<br />

DS1621 comprises internal preset code nibble<br />

‘1001’ (binary) followed by externally<br />

configurable address pins/bits A2, A1 and<br />

A0. The eighth bit of the address byte is<br />

determined by the type of operation (either<br />

read or write) that is to be performed. For<br />

writing to the device the eighth bit is ‘0’<br />

and for reading from the device the eighth<br />

bit is ‘1.’ In our case, A2, A1 and A0 pins<br />

are grounded and hence the device address<br />

for writing is ‘1001000b’ or 90(hex) and for<br />

reading the device address is ‘10010001b’<br />

or 91(hex).<br />

Configuration/status register. This<br />

register can be accessed for reading or<br />

writing by issuing command byte AC(hex)<br />

from the master (82C52). This register is<br />

particularly required if DS1621 is used for<br />

thermostat control, since it contains flag<br />

bits THF (high-temperature flag) and TLF<br />

(low-temperature flag) which are set to<br />

‘1’ when temperature crosses the respective<br />

limits earlier written into TH and<br />

TL registers. It also contains the flag bit<br />

(Done), which is set to ‘1’ when results<br />

of conversion are available after issuing<br />

of start conversion command EE(hex).<br />

The other bits of configuration register are<br />

defined below:<br />

‘NVB’ is the non-volatile memory busy<br />

electronics for you


c o n s t r u c t i o n<br />

flag, ‘1’ is write to an E 2 memory cell in<br />

progress, ‘0’ indicates that non-volatile<br />

memory is not busy, ‘POL’ is non-volatile<br />

output polarity bit (‘1’=active-high and<br />

‘0’=active-low) and ‘1SHOT’ is one-shot<br />

mode. A copy to E 2 may take up to 10 ms.<br />

If 1SHOT is ‘1,’ DS1621 will perform one<br />

temperature conversion upon reception<br />

of the Start Convert T protocol. If 1SHOT<br />

is ‘0’, DS1621 will continuously perform<br />

Fig. 6: Solder-side PCB layout for temperature indicator<br />

using AT8952<br />

electronics for you July 2004<br />

tabLe i<br />

Ds1621 Command set<br />

temperature conversions. This bit is nonvolatile.<br />

Command Set. Complete command<br />

instruction set for accessing various internal<br />

registers as well as for starting and<br />

stopping of conversion process are<br />

given in Table I. For understanding<br />

the exact sequence in which Start<br />

bit, address byte, acknowledgement bit,<br />

command byte(s) and data byte(s) are to<br />

be sent along the I 2 C bus, please refer to the<br />

datasheet of DS1621, wherein these aspects<br />

have been explained in proper detail. This<br />

will help in understanding the contents of<br />

Fig. 7: Component layout for the PCB<br />

instruction Description Protocol<br />

Read Temperature Reads last converted temperature value from Aah<br />

temperature register.<br />

Read Counter Reads value of count remaining from counter. A8h<br />

Read Slope Reads value of the slope accumulator. A9h<br />

Start Convert T Initiates temperature conversion. EEh<br />

Stop Convert T Halts temperature conversion. 22h<br />

Access TH Reads or writes high temperature limit value into A1h<br />

TH register.<br />

Access TL Reads or writes low temperature limit value into A2h<br />

TL register.<br />

Access Configuration Reads or writes configuration data to configuration ACh<br />

register.<br />

the main program.<br />

Microcontroller unit. Microcontroller<br />

<strong>AT89C52</strong> (IC2) is a 40-pin IC from Atmel.<br />

Its pin details are shown in Fig. 5. Like<br />

AT89C51, it also belongs to the 8031/8051<br />

family. Microcontroller <strong>AT89C52</strong> has a<br />

256×8-bit internal random-access memory<br />

(RAM), eight interrupt sources and 8 kB of<br />

flash memory compared to 128x8-bit internal<br />

RAM, six interrupt sources and 4 kB of<br />

flash memory in AT89C51. By combining<br />

a versatile 8-bit CPU with flash memory<br />

on a monolithic chip, Atmel <strong>AT89C52</strong> is a<br />

powerful, highly flexible and cost-effective<br />

solution to many embedded<br />

control applications.<br />

Ports 0 and 2 are 8-bit<br />

bidirectional input/output<br />

(I/O) ports. These ports<br />

haven’t been used in this<br />

temperature indicator.<br />

Port 1 is an 8-bit bidirectional<br />

I/O port with internal<br />

pull-ups. Ports 1.0<br />

through 1.7 are connected<br />

to pins 7 through 14 of<br />

the LCD. Port-1 output<br />

buffers can sink/source<br />

four TTL inputs.<br />

Port 3 is an 8-bit bidirectional<br />

I/O port with<br />

internal pull-ups. Ports<br />

3.0 and 3.1 of IC2 are<br />

connected to serial clock<br />

line (SCL) and serial data<br />

line (SDA) of IC3, respectively.<br />

Ports 3.2 through<br />

3.4 are connected to pins<br />

4 through 6 of the LCD,<br />

respectively. Port-3 output<br />

buffers can sink/source<br />

four TTL inputs.<br />

A 12MHz crystal oscillator<br />

is connected to X TAL1<br />

and X TAL2 pins for operation of the microcontroller.<br />

A high pulse on RST pin (pin 9)<br />

while the oscillator is running resets the<br />

microcontroller. In this circuit, this pin is<br />

connected to +Vcc through capacitor C5<br />

(10 µF, 16V). The external-access enable<br />

pin (EA) is connected to +Vcc for internal<br />

program executions. This pin also receives<br />

the 12V programming-enable voltage (V PP )<br />

during flash programming when 12V programming<br />

is selected.<br />

the program<br />

The C-language program for microcontroller<br />

<strong>AT89C52</strong> is compiled using crosscompiler<br />

C51 Version 7.10 from Keil Soft-


c o n s t r u c t i o n<br />

ware. The demo version of this compiler<br />

is available for free on the Website ‘www.<br />

keil.com.’ It can compile programs up to<br />

2 kB only, which is sufficient for writing<br />

most programs.<br />

For testing the display, the program<br />

Hello.c is given here. This program, when<br />

loaded to <strong>AT89C52</strong>, displays “Hello! How<br />

R U?” on the LCD. The Hello.c program<br />

has nothing to do with temperature. It<br />

just guarantees a perfect communication<br />

between the LCD and the microcontroller.<br />

For temperature indication, the program<br />

Temp52.c is used. The programs Hello.c<br />

and Temp52.c, along with the hex files, are<br />

given at the end of this article.<br />

The communication interface between<br />

the temperature sensor and the<br />

microcontroller chip follows the I 2 C (Inter<br />

Integrated Circuit) standard, which<br />

is implemented in ‘C’ here. I 2 C is a<br />

simple master/slave type interface.<br />

Simplicity of the I²C system is primarily<br />

due to the bidirectional 2-wire (SDA and<br />

SCL) design and the protocol format.<br />

Bidirectional communication is through<br />

2-wire lines (which are either activelow<br />

or passive-high). In the program,<br />

the i2c_stop, i2c_start, i2c_write and<br />

i2c_read functions are used for communicating<br />

Clock and Data from DS1621 to<br />

P3.0 and P3.1 of <strong>AT89C52</strong>, respectively.<br />

Such functions as command, ready and<br />

display in the program are used for driving<br />

the LCD.<br />

Program compilation for 8051 family<br />

controller. Keil C51 can compile C programs<br />

for most of the Atmel family microcontrollers.<br />

It also supports other devices.<br />

Unlike other cross-compilers (Hi-Tech, IAR,<br />

SDCC, etc), Keil C51 offers such features as<br />

fast code generation, strong multitasking<br />

environment, real-time operating system<br />

and inbuilt code optimisation. To enjoy<br />

these features, you’ll need full version of<br />

the compiler.<br />

Keil C51 has options to generate<br />

Assembly code and all the code listing<br />

supported by 8051 family, but Assembly<br />

language generated cannot be recompiled<br />

on any other assembler. As far as code<br />

generation is concerned, it uses minimum<br />

RAM and on-chip flash, allowing<br />

faster and optimised program in Intel-<br />

Hex format, which can be loaded to the<br />

microcontroller using any programmer.<br />

Conversion of C program into Intel-Hex<br />

format takes only a few seconds. In fact,<br />

you don’t require all that long Assembly<br />

program in order to generate the output<br />

hex file.<br />

electronics for you July 2004<br />

LCd<br />

tabLe ii<br />

Pin Connections of the LCD<br />

Pin No. Functions<br />

Pin 1 Ground (Gnd)<br />

Pin 2 +Vcc<br />

Pin 3 V0 (display intensity control)<br />

Pin 4 RS (connected to P3.2 of <strong>AT89C52</strong>)<br />

Pin 5 R/W (connected to P3.3 of <strong>AT89C52</strong>)<br />

Pin 6 EN (connected to P3.4 of <strong>AT89C52</strong>)<br />

Pin 7 D0 (connected to P1.0 of <strong>AT89C52</strong>)<br />

Pin 8 D1 (connected to P1.1 of <strong>AT89C52</strong>)<br />

Pin 9 D2 (connected to P1.2 of <strong>AT89C52</strong>)<br />

Pin 10 D3 (connected to P1.3 of <strong>AT89C52</strong>)<br />

Pin 11 D4 (connected to P1.4 of <strong>AT89C52</strong>)<br />

Pin 12 D5 (connected to P1.5 of <strong>AT89C52</strong>)<br />

Pin 13 D6 (connected to P1.6 of <strong>AT89C52</strong>)<br />

Pin 14 D7 (connected to P1.7 of <strong>AT89C52</strong>)<br />

Pin 15 Backlight +Vcc (not used)<br />

Pin 16 Backlight Gnd (not used)<br />

For display, a Lampex make 16x1 LCD<br />

(model GDM1601A) was used. Pin connections<br />

of this LCD are given in Table II.<br />

Pins 15 and 16 haven’t been used. Pin 3 is<br />

connected to the circuit ground through a<br />

1-kilo-ohm preset that is used to control<br />

the light intensity of the LCD. Note that the<br />

Hitachi make 16×1 LCD (HD44780A00)<br />

will not work in this project.<br />

Construction<br />

The circuit of this temperature indicator<br />

using microcontroller <strong>AT89C52</strong> can be<br />

assembled on any general-purpose, singleside<br />

PCB. The microcontroller chip and the<br />

temperature sensor chip are mounted on<br />

the respective IC bases. Ensure a proper<br />

contact between pins of the IC bases and<br />

the solder points on the PCB. Capacitors<br />

C3 and C4 must be connected near IC2<br />

and IC3, respectively. The actual-size,<br />

single-side PCB layout for the circuit and<br />

its component layout are shown in Figs 6<br />

and 7, respectively.<br />

Program compilation<br />

After you’ve installed Keil C51 in your PC,<br />

you can compile C program and generate<br />

hex file in either DOS or Windows<br />

mode. Here, program compilation for the<br />

program Hello.c has been explained. The<br />

same procedure is to be followed for the<br />

temperature indication program Temp52.<br />

c. For more example programs, refer to the<br />

directory in your hard drive where Keil is<br />

installed in the example folder.<br />

DOS mode. 1. Installation of Keil C51<br />

automatically generates ‘Keil’ folder in<br />

your computer’s C drive.<br />

2. Go to ‘C:\Keil\C51\Bin’ folder<br />

inside ‘Keil’ folder.<br />

3. Copy ‘Hello.c’ into ‘Bin’ folder.<br />

4. Copy ‘Regx52.h’ from ‘C:\Keil\<br />

C51\Inc\Atmel’ folder into ‘C:\Keil\C51\<br />

Bin’ folder.<br />

5. Type ‘c51 Hello.c’ against the<br />

prompt and press Enter key.<br />

6. Type ‘bl51 Hello.obj.’ This command<br />

is used for linking the Hello.obj<br />

file created by Keil C51.<br />

7. Type ‘oh51 Hello.’ This command<br />

is used for creating the hex file.<br />

Windows mode. 1. Installation of<br />

Keil C51 software automatically creates<br />

the icon ‘Keil uVision2’ on the desktop.<br />

2. Double-click ‘Keil uVision2.’<br />

3. Suppose you have kept ‘Hello.c’<br />

under ‘C:\Windows\Desktop\Hello’ folder.<br />

Open ‘Hello.c’ from the ‘File’ menu.<br />

4. From the menu bar, select ‘Project/<br />

New Project.’ Name the new project and<br />

save it with extension ‘.uv2.’<br />

5. Select CPU as Atmel/<strong>AT89C52</strong>.<br />

6. Choose ‘Yes’ in the option “Copy standard<br />

8051 code to current project folder.”<br />

7. Choose ‘View/Project Window.’ A<br />

‘Project Workspace’ window appears.<br />

8. Double-click ‘Target 1.’<br />

9. Right-click ‘Source Group1’ and select<br />

“Add files to Group ‘Source Group1.’”<br />

A window appears.<br />

10. Add ‘Hello.c’ and close this window.<br />

11. Double-click ‘Source Group1’ on<br />

the ‘Project Workspace’ window. Now the<br />

file name ‘Hello.c’ appears.<br />

12. From ‘Project’ menu, select ‘Options<br />

for File ‘Hello.c.’ In ‘Properties,’<br />

choose file type as ‘C source file.’<br />

13. Again from ‘Project’ menu, select<br />

‘Options for Target ‘Target1.’” A screen<br />

appears.<br />

14. Choose ‘Output’ and tick on ‘Hex<br />

File’ for generating the hex file. Again<br />

choose ‘Listing’ option and tick on ‘Conditional<br />

and Assembly Code’.<br />

15. Open the Project menu and select<br />

‘Build Target’ or press F7. The compiler<br />

shows “”Hello” 0 Error(s), 0 Warning(s)”<br />

in the output window just below the project<br />

window.<br />

16. Close the screen and go to the<br />

‘Hello’ folder to see the generated hex file<br />

and listing file.<br />

Load the hex file into the microcontroller<br />

chip using a programmer. (Here’<br />

we’ve used Atmel Flash Programmer from


Frontline Electronics.) Now integrate the<br />

microcontroller chip into the populated<br />

PCB comprising the temperature sensor<br />

and the LCD module.<br />

troubleshooting<br />

1. Check the COM port on your PC before<br />

programming.<br />

/* Written By: Aditya Rane<br />

T.E Computer Engg, Lokmanya Tilak College of Engineering,<br />

New Bombay, Vashi<br />

E-mail: aditya@orionengg.com<br />

Program for temperature indicator compiled under keil<br />

'C' */<br />

#include<br />

#include<br />

#include<br />

//------------------------------------------------------------------------<br />

//Global Variable<br />

//------------------------------------------------------------------------int<br />

temperature;<br />

#define HIGH 0x01 // Active High Signal<br />

#define LOW 0x00 // Active Low Signal<br />

#define TRUE 0x01 // Active High State<br />

#define FALSE 0x00 // Active Low State<br />

//-------------------------------------------------------------------------<br />

// Functions Prototyping<br />

//------------------------------------------------------------------------void<br />

ready (void);<br />

void command (int);<br />

void display (char *);<br />

void i2c_stop (void);<br />

void i2c_start (void);<br />

void i2c_write (unsigned char);<br />

unsigned char i2c_read (void);<br />

void convert (unsigned char);<br />

//-------------------------------------------------------------------------<br />

// Port Defination<br />

//-------------------------------------------------------------------------<br />

#define DATA P3_1 // Serial data<br />

#define CLOCK P3_0 // Serial clock<br />

//Begining of Main Program<br />

void main (void)<br />

{<br />

int tmp;<br />

char str[16];<br />

bit flag = FALSE;<br />

unsigned char ch;<br />

void command (int);<br />

void display (char *);<br />

command(0x3c);<br />

command(0x0c);<br />

command(0x06);<br />

while(1)<br />

{<br />

i2c_start();<br />

i2c_write(0x90);<br />

i2c_write(0xEE);<br />

i2c_stop();<br />

i2c_start();<br />

i2c_write(0x90);<br />

i2c_write(0xAA);<br />

i2c_start();<br />

i2c_write(0x91);<br />

ch = i2c_read();<br />

i2c_stop();<br />

temperature = 0;<br />

convert(ch);<br />

if(flag == FALSE)<br />

{<br />

flag = TRUE;<br />

}<br />

else<br />

{<br />

tmp = temperature;<br />

if(tmp != temperature)<br />

{<br />

2. In case there is no message even if<br />

all the connections are correct, adjust the<br />

intensity control potentiometer (VR1) for<br />

display.<br />

3. Check whether your hex file<br />

matches with the hex file given below in<br />

the article.<br />

4. If the LCD shows wrong characters,<br />

replace it with another make LCD.<br />

temP52.C<br />

tmp = temperature;<br />

sprintf(str,"%d%s<br />

",temperature," Centigrade");<br />

command(0x01);<br />

command(0x80);<br />

display(str);<br />

}<br />

}<br />

}<br />

}<br />

//Delay Servive Routine<br />

void delay_time (void)<br />

{<br />

unsigned int i;<br />

for(i=0;i


c o n s t r u c t i o n<br />

:100F270025642573002043656E7469677261646583<br />

:090F3700008040201008040201B2<br />

:100DA800C2007F3C7E00120F9A7F0C7E00120F9AC1<br />

:100DB8007F067E00120F9A120F8B7F90120EB87F5B<br />

:100DC800EE120EB8120F6A120F8B7F90120EB87FB8<br />

:100DD800AA120EB8120F8B7F91120EB8120F098F3C<br />

:100DE80034120F6AE4F508F509AF34120CF220004A<br />

:100DF8000AD20085082285092380BCE5236509708D<br />

:100E080004E522650860B08508228509237538FF46<br />

:100E180075390F753A2785083B85093C753DFF757F<br />

:100E28003E0F753F2C7B007A00792412085C7F0105<br />

:100E38007E00120F9A7F807E00120F9A7B007A0044<br />

:080E48007924120E50020DBFC7<br />

:0E0F7C00E4FFFE0FBF00010EEF64644E70F53F<br />

:010F8A002244<br />

:0F0F8B00D2B1120F7CD2B0120F7CC2B1C2B02211<br />

:100F6A00C2B0C2B1D2B0120F7CD2B1A2B1E433F591<br />

:010F7A003541<br />

:010F7B002253<br />

:020EB800AD0784<br />

:100EBA00E4FCED30E703D38001C392B1ED25E0FDF8<br />

:100ECA00D2B0120F7CC2B00CBC08E7A2B1E433FC6A<br />

:070EDA00D2B0120F7CC2B080<br />

:010EE10022EE<br />

:100F0900E4FDA2B1E4FCED25E0FDD2B0A2B1E433E9<br />

:0D0F19004205120F7CC2B00CBC08EBAF0506<br />

:010F260022A8<br />

:020CF2008F353C<br />

:100CF40078377C007D007BFF7A0F79387E007F088F<br />

:100D0400120C2CE53530E7047F0180027F00EF7080<br />

:100D140041F536E53530E7047F0180027F00EF605E<br />

:100D24002374372536F8E6FD7C00E5357E0030E790<br />

:100D3400047F0180027F00120C7FEF2509F509EE84<br />

:100D44003508F508E53525E0F5350536E536B4080A<br />

:100D5400C2226335FF0535E4F536E53530E7047F17<br />

:100D64000180027F00EF602374372536F8E6FD7CAE<br />

:100D740000E5357E0030E7047F0180027F00120C1D<br />

:100D84007FEF2509F509EE3508F508E53525E0F589<br />

:100D9400350536E536B408C2C3E49509F509E4958A<br />

:030DA40008F50847<br />

:010DA7002229<br />

:100F4000C2B47590FFC2B2D2B3309706C2B4D2B465<br />

:050F500080F7C2B4228D<br />

:0E0F9A00120F408F90C2B2C2B3D2B4C2B422C2<br />

:060E50008B358A3689375C<br />

:100E5600E4F538F539AB35AA36A937120F55EF2424<br />

:100E6600FFFFEE34FFFED3E5399FE5389E5042E59D<br />

:100E7600396408453870067FC0FE120F9AE539645A<br />

:100E860010453870067F80FE120F9A120F40AB3560<br />

#include<br />

#include<br />

#include<br />

void ready(void);<br />

void command(int);<br />

void display(char *);<br />

void main (void)<br />

{<br />

command(0x3c);<br />

command(0x0c);<br />

command(0x06);<br />

command(0x01);<br />

command(0x80);<br />

display("Hello! How R U ?");<br />

while(1);<br />

}<br />

void command(int a)<br />

{<br />

void ready(void);<br />

:0300000002092AC8<br />

:0C092A00787FE4F6D8FD75810E0208AE5F<br />

:1009190048656C6C6F2120486F7720522055203F25<br />

:0109290000CD<br />

:1008AE007F3C7E001209067F0C7E001209067F0631<br />

:1008BE007E001209067F017E001209067F807E00EF<br />

:0E08CE001209067BFF7A09791912080080FED4<br />

:100906008E0D8F0E1208DC850E90C2B2C2B3D2B421<br />

:03091600C2B42246<br />

:060800008B088A09890A39<br />

electronics for you July 2004<br />

ready();<br />

P1=a;<br />

P3_2=0x00;<br />

P3_3=0x00;<br />

P3_4=0x01;<br />

P3_4=0x00;<br />

}<br />

temP52.Hex<br />

:100E9600AA36A937853982853883120C52F590D245<br />

:100EA600B2C2B3D2B4C2B40539E53970A8053880E8<br />

:010EB600A497<br />

:010EB7002218<br />

:03000000020FA844<br />

:0C0FA800787FE4F6D8FD758148020DA8A2<br />

:100B5C00E709F608DFFA8046E709F208DFFA803E7B<br />

:100B6C0088828C83E709F0A3DFFA8032E309F60868<br />

:100B7C00DFFA8078E309F208DFFA807088828C83D0<br />

:100B8C00E309F0A3DFFA806489828A83E0A3F60884<br />

:100B9C00DFFA805889828A83E0A3F208DFFA804C5E<br />

:100BAC0080D280FA80C680D4806980F28033801035<br />

:100BBC0080A680EA809A80A880DA80E280CA80339E<br />

:100BCC0089828A83ECFAE493A3C8C582C8CCC58316<br />

:100BDC00CCF0A3C8C582C8CCC583CCDFE9DEE780E6<br />

:100BEC000D89828A83E493A3F608DFF9ECFAA9F065<br />

:100BFC00EDFB2289828A83ECFAE0A3C8C582C8CCBB<br />

:100C0C00C583CCF0A3C8C582C8CCC583CCDFEADED3<br />

:100C1C00E880DB89828A83E493A3F208DFF980CC35<br />

:100C2C0088F0EF60010E4E60C388F0ED2402B4042E<br />

:100C3C000050B9F582EB2402B4040050AF232345D5<br />

:060C4C008223900BAC7343<br />

:100C5200BB010CE58229F582E5833AF583E0225057<br />

:100C620006E92582F8E622BBFE06E92582F8E222A1<br />

:0D0C7200E58229F582E5833AF583E49322BB<br />

:100C7F00EF8DF0A4A8F0CF8CF0A428CE8DF0A42E89<br />

:020C8F00FE2243<br />

:10080000E5442438F8E60544227835300802783883<br />

:10081000E475F001120CBC020C912001EB7F2ED28A<br />

:10082000018018EF540F2490D43440D4FF30050BCE<br />

:10083000EF24BFB41A0050032461FFE545600215A0<br />

:10084000450548E5487002054730080D7835E475E0<br />

:10085000F001120CBCEF020CAA020EE27403D208E3<br />

:100860008003E4C208F5448B358A368937E4F545C0<br />

:10087000F547F548E54560077F2012083B80F57590<br />

:1008800046FFC202C201C203C204C206C207C209B5<br />

:10089000120809FF700D3008057F0012084CAF48A0<br />

:1008A000AE4722B4255FC2D5C205120809FF24D085<br />

:1008B000B40A00501A75F00A784530D50508B6FF1D<br />

:1008C0000106C6A426F620D5047002D20480D924DD<br />

:1008D000CFB41A00EF5004C2E5D205020A4CD2028E<br />

:1008E00080C6D20180C0D20380BCD2D580BAD206E5<br />

:1008F00080B47F2012083B2003077401B5450040F7<br />

:10090000F1120800FF12083B020874D209D20780D6<br />

:1009100095120800FB120800FA120800F94A4B7001<br />

:1009200006791D7A0B7BFF20032EE545602A7E00A9<br />

:100930008E82758300120C5260060EEE654670F0D2<br />

:10094000C2D5EBC0E0EAC0E0E9C0E0EE120A93D005<br />

HeLLo.C<br />

void display(char *str)<br />

{<br />

unsigned int i;<br />

for(i=0;i


c o n s t r u c t i o n<br />

SoURCe Code FoR PRoGRAmmABLe LoGiC ContRoLLeR (PC BASed)<br />

#include <br />

#include <br />

#include <br />

#include <br />

#include <br />

#include <br />

#include <br />

#include <br />

#include <br />

#include <br />

#include <br />

#include <br />

#include <br />

//Global Sub routines<br />

void runprog();//Run program<br />

void viewprog();//Display Program<br />

void viewstat();//Display status<br />

void forceout();//Force outputs<br />

void helpu(); //Help<br />

void exiter();//Exit to Dos<br />

void openingmenu();//Opening menu<br />

void paintscreen(int scrclr);//Paint screen<br />

void border(); //Draw borders<br />

void displaystat();//Display status<br />

void displayhelp(char helpfilename[10]);//Display a<br />

Help File<br />

//Logic commands<br />

void ser(int inputno);//series contact<br />

void par(int inputno);//Parallel Contacts<br />

void ope(int outputno);//Output<br />

void opl(int outputno);//Output latch<br />

void opu(int outputno);//Output unlatch<br />

int tmr(int tno,int timeset);//timer<br />

int ctu(int cno,int countset);//Counter Up<br />

int ctd(int cno,int countset);//Counter Down<br />

int rto(int hourr,int minn);//real time Output<br />

//Read Inputs And Energise Outputs<br />

void inputread();//read input port<br />

void setoutputs();//set outputs<br />

//Global variables<br />

//Inputs and Outputs Image table<br />

int I1,I2,I3,I4,I5,O1,O2,O3,O4,O5,O6,O7,O8;<br />

int NI1,NI2,NI3,NI4,NI5,NO1,NO2,NO3,NO4,NO5,<br />

NO6,NO7,NO8;<br />

//Counters Up<br />

int C1,C2,C3,C4,C5;<br />

int CACC1,CACC2,CACC3,CACC4,CACC5;<br />

int CDN1,CDN2,CDN3,CDN4,CDN5;<br />

int risingedge;<br />

//Counters Down<br />

int CO1,CO2,CO3,CO4,CO5;<br />

int COACC1,COACC2,COACC3,COACC4,COACC5;<br />

int CODN1,CODN2,CODN3,CODN4,CODN5;<br />

int cd1,cd2,cd3,cd4,cd5;<br />

//Timers<br />

int T1,T2,T3,T4,T5;<br />

int TACC1,TACC2,TACC3,TACC4,TACC5;<br />

int TEN1,TEN2,TEN3,TEN4,TEN5;<br />

int TDN1,TDN2,TDN3,TDN4,TDN5;<br />

int tmrscan1,tmrscan2,tmrscan3,tmrscan4,tmrscan5;<br />

//Results Register<br />

int res;<br />

//Real Time Output<br />

int RTDN;<br />

struct time t;<br />

class TTimer r;<br />

//For the scan timer<br />

double te,se;<br />

time_t first1,second1,first2,second2,first3,second3,first4,<br />

second4,first5,second5;<br />

//Command And Parameter Register<br />

int commno[1000];<br />

int para1[1000],para2[1000];<br />

//Start of main<br />

void main()<br />

{<br />

openingmenu();<br />

}<br />

//Opening menu<br />

electronics for you July 2004<br />

void openingmenu()<br />

{<br />

window(1,1,80,25);<br />

clrscr();<br />

paintscreen(9);<br />

border();<br />

textcolor(YELLOW);<br />

textbackground(LIGHTBLUE);<br />

gotoxy(25,3);<br />

cprintf(“==PC Based Logic Controller==”);<br />

gotoxy(30,4);<br />

cprintf(“Ver 1.0 (5 I/p,8 O/p)”);<br />

textcolor(LIGHTGREEN);<br />

gotoxy(25,6);<br />

cprintf(“== M A I N M E N U ==”);<br />

gotoxy(25,7);<br />

cprintf(“**********************”);<br />

textcolor(LIGHTRED);<br />

gotoxy(25,9);<br />

cprintf(“F1 >- Run a Logic Program”);<br />

gotoxy(25,11);<br />

cprintf(“F2 >- View/Edit a Logic Program”);<br />

gotoxy(25,13);<br />

cprintf(“F3 >- View Input/Output Status”);<br />

gotoxy(25,15);<br />

cprintf(“F4 >- Force Outputs”);<br />

gotoxy(25,17);<br />

cprintf(“F5 >- Online Help”);<br />

gotoxy(25,19);<br />

cprintf(“F6 >- Exit”);<br />

USERCHOICE:<br />

while(!kbhit())<br />

{}<br />

char userchoice=getch();<br />

switch(userchoice)<br />

{<br />

case (char(59)):runprog();break;<br />

case (char(60)):viewprog();break;<br />

case (char(61)):viewstat();break;<br />

case (char(62)):forceout();break;<br />

case (char(63)):helpu();break;<br />

case (char(64)):exiter();break;<br />

default:goto USERCHOICE;<br />

}<br />

}<br />

//paints the screen with specified colour<br />

void paintscreen(int scrclr)<br />

{<br />

textbackground(scrclr);<br />

for(int x=0;x


gotoxy(10,7);<br />

cprintf(“==================”);<br />

gotoxy(10,8);<br />

cprintf(“Input # 1(I1):”);<br />

gotoxy(10,9);<br />

cprintf(“Input # 2(I2):”);<br />

gotoxy(10,10);<br />

cprintf(“Input # 3(I3):”);<br />

gotoxy(10,11);<br />

cprintf(“Input # 4(I4):”);<br />

gotoxy(10,12);<br />

cprintf(“Input # 5(I5):”);<br />

gotoxy(10,13);<br />

textcolor(CYAN);<br />

cprintf(“Controller Outputs”);<br />

gotoxy(10,14);<br />

cprintf(“==================”);<br />

gotoxy(10,15);<br />

cprintf(“Output # 1(O1):”);<br />

gotoxy(10,16);<br />

cprintf(“Output # 2(O2):”);<br />

gotoxy(10,17);<br />

cprintf(“Output # 3(O3):”);<br />

gotoxy(10,18);<br />

cprintf(“Output # 4(O4):”);<br />

gotoxy(10,19);<br />

cprintf(“Output # 5(O5):”);<br />

gotoxy(10,20);<br />

cprintf(“Output # 6(O6):”);<br />

gotoxy(10,21);<br />

cprintf(“Output # 7(O7):”);<br />

gotoxy(10,22);<br />

cprintf(“Output # 8(O8):”);<br />

textcolor(YELLOW);<br />

gotoxy(40,3);<br />

cprintf(“Counter(UP) Preset ACC Done”);<br />

gotoxy(40,4);<br />

cprintf(“====================<br />

=”);<br />

gotoxy(40,5);<br />

cprintf(“Counter #1”);<br />

gotoxy(40,6);<br />

cprintf(“Counter #2”);<br />

gotoxy(40,7);<br />

cprintf(“Counter #3”);<br />

gotoxy(40,8);<br />

cprintf(“Counter #4”);<br />

gotoxy(40,9);<br />

cprintf(“Counter #5”);<br />

textcolor(GREEN);<br />

gotoxy(40,10);<br />

cprintf(“Counter(DOWN) Preset ACC Done”);<br />

gotoxy(40,11);<br />

cprintf(“====================<br />

==”);<br />

gotoxy(40,12);<br />

cprintf(“Counter #1”);<br />

gotoxy(40,13);<br />

cprintf(“Counter #2”);<br />

gotoxy(40,14);<br />

cprintf(“Counter #3”);<br />

gotoxy(40,15);<br />

cprintf(“Counter #4”);<br />

gotoxy(40,16);<br />

cprintf(“Counter #5”);<br />

gotoxy(40,17);<br />

textcolor(LIGHTRED);<br />

cprintf(“Timer Enable Preset ACC Done”);<br />

gotoxy(40,18);<br />

cprintf(“====================<br />

==”);<br />

gotoxy(40,19);<br />

cprintf(“Timer #1”);<br />

gotoxy(40,20);<br />

cprintf(“Timer #2”);<br />

gotoxy(40,21);<br />

cprintf(“Timer #3”);<br />

gotoxy(40,22);<br />

cprintf(“Timer #4”);<br />

gotoxy(40,23);<br />

cprintf(“Timer #5”);<br />

gotoxy(40,24);<br />

cprintf(“RTO Timer Done:”);<br />

gotoxy(10,23);<br />

textcolor(YELLOW);<br />

cprintf(“Last Scan(msec):”);<br />

gotoxy(10,24);<br />

textcolor(LIGHTBLUE);<br />

cprintf(“File Name:”);<br />

gotoxy(21,24);<br />

textcolor(LIGHTBLUE);<br />

cprintf(“%15s”,logicfile);<br />

//Starting To Read The File<br />

count=0;<br />

while(!infile.eof())<br />

{<br />

infile>>comm;<br />

if(stricmp(comm,”ser”)==0){commno[count]=1;infile<br />

>> para1[count];}<br />

if(stricmp(comm,”par”)==0){commno[count]=2;infil<br />

e>> para1[count];}<br />

if(stricmp(comm,”ope”)==0){commno[count]=3;infil<br />

e>> para1[count];}<br />

if(stricmp(comm,”opl”)==0){commno[count]=4;infil<br />

e>> para1[count];}<br />

if(stricmp(comm,”opu”)==0){commno[count]=5;infil<br />

e>> para1[count];}<br />

if(stricmp(comm,”tmr”)==0){commno[count]=6;infile<br />

>> para1[count];infile>>para2[count];}<br />

if(stricmp(comm,”ctu”)==0){commno[count]=7;infile<br />

>> para1[count];infile>>para2[count];}<br />

if(stricmp(comm,”ctd”)==0){commno[count]=8;infile<br />

>> para1[count];infile>>para2[count];}<br />

if(stricmp(comm,”rto”)==0){commno[count]=9;infile<br />

>> para1[count];infile>>para2[count];}<br />

count=count+1;<br />

}<br />

infile.close();<br />

//Running The Program<br />

while(!kbhit())<br />

{}<br />

char choice;<br />

choice=getch();<br />

switch(choice)<br />

{<br />

case(char(59)):goto RUN;break;<br />

case(char(27)):openingmenu();break;<br />

}<br />

RUN:<br />

textcolor(YELLOW+BLINK);<br />

_setcursortype(_NOCURSOR);<br />

for(;;)<br />

{<br />

res=1;<br />

inputread();<br />

for(n=0;n=100)<br />

{<br />

f=0;<br />

te=r.Time();<br />

}<br />

r.Reset();<br />

displaystat();<br />

if(kbhit())<br />

{<br />

if ((in = getch())==’\x1B’)break;<br />

}<br />

}<br />

gotoxy(45,2);<br />

cprintf(“ESC =Stop and EXIT”);<br />

gotoxy(70,2);<br />

cprintf(“Prog=HALT”);<br />

while(!kbhit())<br />

{}<br />

choice=getch();<br />

switch(choice)<br />

{<br />

case(char(59)):goto RUN;break;<br />

case(char(27)):openingmenu();break;<br />

default:openingmenu();<br />

}<br />

July 2004<br />

c o n s t r u c t i o n<br />

}<br />

//View/Edit Program<br />

void viewprog()<br />

{<br />

char lfile[15];<br />

char* comm;<br />

char tot[25];<br />

comm=”Edit “;<br />

window(1,1,80,25);<br />

clrscr();<br />

paintscreen(4);<br />

border();<br />

textcolor(YELLOW);<br />

textbackground(4);<br />

gotoxy(20,4);<br />

cprintf(“— View /Edit Controller File —”);<br />

gotoxy(20,5);<br />

cprintf(“====================<br />

==”);<br />

window(3,8,75,8);<br />

textcolor(YELLOW);<br />

clrscr();<br />

textcolor(CYAN);<br />

cprintf(“Enter the Logic File Name (New or Existing):(????.<br />

lgx) - “);<br />

scanf(“%15s”,&lfile);<br />

strcat(tot,comm);<br />

strcat(tot,lfile);<br />

system(tot);<br />

openingmenu();<br />

}<br />

//View I/P,O/P Status<br />

void viewstat()<br />

{<br />

char in;<br />

int inpu;<br />

int inpuo;<br />

window(1,1,80,25);<br />

clrscr();<br />

paintscreen(4);<br />

border();<br />

textcolor(YELLOW);<br />

textbackground(4);<br />

gotoxy(20,4);<br />

cprintf(“— Logic Controller Input Output Status —”);<br />

gotoxy(20,5);<br />

cprintf(“====================<br />

==”);<br />

gotoxy(25,6);<br />

cprintf(“Press ESC TO Exit Status Screen”);<br />

gotoxy(20,8);<br />

textcolor(LIGHTRED);<br />

cprintf(“Controller Inputs:”);<br />

gotoxy(20,9);<br />

cprintf(“==================”);<br />

gotoxy(20,11);<br />

cprintf(“Input # 1(I1):”);<br />

gotoxy(20,12);<br />

cprintf(“Input # 2(I2):”);<br />

gotoxy(20,13);<br />

electronics for you


c o n s t r u c t i o n<br />

cprintf(“Input # 3(I3):”);<br />

gotoxy(20,14);<br />

cprintf(“Input # 4(I4):”);<br />

gotoxy(20,15);<br />

cprintf(“Input # 5(I5):”);<br />

gotoxy(20,17);<br />

textcolor(CYAN);<br />

cprintf(“Controller Outputs”);<br />

gotoxy(20,18);<br />

cprintf(“==================”);<br />

gotoxy(20,20);<br />

cprintf(“Output # 1(O1):”);<br />

gotoxy(20,21);<br />

cprintf(“Output # 2(O2):”);<br />

gotoxy(20,22);<br />

cprintf(“Output # 3(O3):”);<br />

gotoxy(20,23);<br />

cprintf(“Output # 4(O4):”);<br />

gotoxy(40,11);<br />

cprintf(“Output # 5(O5):”);<br />

gotoxy(40,12);<br />

cprintf(“Output # 6(O6):”);<br />

gotoxy(40,13);<br />

cprintf(“Output # 7(O7):”);<br />

gotoxy(40,14);<br />

cprintf(“Output # 8(O8):”);<br />

_setcursortype(_NOCURSOR);<br />

for(;;)<br />

{<br />

//scan inputs<br />

inpu=inp(0x379);<br />

if ((inpu & 8)==0){gotoxy(35,11);textcolor(GREEN);<br />

cprintf(“ON “);}<br />

if ((inpu & 8)==8){gotoxy(35,11);textcolor(YELLOW);<br />

cprintf(“OFF”);}<br />

if ((inpu & 16)==0){gotoxy(35,12);textcolor(GREEN);<br />

cprintf(“ON “);}<br />

if ((inpu & 16)==16){gotoxy(35,12);textcolor(YELLOW);<br />

cprintf(“OFF”);}<br />

if ((inpu & 32)==0){gotoxy(35,13);textcolor(GREEN);<br />

cprintf(“ON “);}<br />

if ((inpu & 32)==32){gotoxy(35,13);textcolor(YELLOW);<br />

cprintf(“OFF”);}<br />

if ((inpu & 64)==0){gotoxy(35,14);textcolor(GREEN);<br />

cprintf(“ON “);}<br />

if ((inpu & 64)==64){gotoxy(35,14);textcolor(YELLOW);<br />

cprintf(“OFF”);}<br />

if ((inpu & 128)==128){gotoxy(35,15);textcolor(GREEN);<br />

cprintf(“ON “);}<br />

if ((inpu & 128)==0){gotoxy(35,15);textcolor(YELLOW);<br />

cprintf(“OFF”);}<br />

//scan outputs<br />

inpuo=inp(0x378);<br />

if ((inpuo & 1)==1){gotoxy(36,20);textcolor(GREEN);<br />

cprintf(“ON “);}<br />

if ((inpuo & 1)==0){gotoxy(36,20);textcolor(YELLOW);<br />

cprintf(“OFF”);}<br />

if ((inpuo & 2)==2){gotoxy(36,21);textcolor(GREEN);<br />

cprintf(“ON “);}<br />

if ((inpuo & 2)==0){gotoxy(36,21);textcolor(YELLOW);<br />

cprintf(“OFF”);}<br />

if ((inpuo & 4)==4){gotoxy(36,22);textcolor(GREEN);<br />

cprintf(“ON “);}<br />

if ((inpuo & 4)==0){gotoxy(36,22);textcolor(YELLOW);<br />

cprintf(“OFF”);}<br />

if ((inpuo & 8)==8){gotoxy(36,23);textcolor(GREEN);<br />

cprintf(“ON “);}<br />

if ((inpuo & 8)==0){gotoxy(36,23);textcolor(YELLOW);<br />

cprintf(“OFF”);}<br />

if ((inpuo & 16)==16){gotoxy(56,11);textcolor(GREEN);<br />

cprintf(“ON “);}<br />

if ((inpuo & 16)==0){gotoxy(56,11);textcolor(YELLOW);<br />

cprintf(“OFF”);}<br />

if ((inpuo & 32)==32){gotoxy(56,12);textcolor(GREEN);<br />

cprintf(“ON “);}<br />

if ((inpuo & 32)==0){gotoxy(56,12);textcolor(YELLOW);<br />

cprintf(“OFF”);}<br />

if ((inpuo & 64)==64){gotoxy(56,13);textcolor(GREEN);<br />

cprintf(“ON “);}<br />

if ((inpuo & 64)==0){gotoxy(56,13);textcolor(YELLOW);<br />

cprintf(“OFF”);}<br />

if ((inpuo & 128)==128){gotoxy(56,14);textcolor(GREEN);<br />

electronics for you July 2004<br />

cprintf(“ON “);}<br />

if ((inpuo & 128)==0){gotoxy(56,14);textcolor(YELLOW);<br />

cprintf(“OFF”);}<br />

if(kbhit())<br />

{<br />

if ((in = getch())==’\x1B’)break;<br />

}<br />

}<br />

openingmenu();<br />

}<br />

//Force Outputs<br />

void forceout()<br />

{<br />

char cho;<br />

char in;<br />

window(1,1,80,25);<br />

clrscr();<br />

paintscreen(4);<br />

border();<br />

textcolor(YELLOW);<br />

textbackground(4);<br />

gotoxy(25,3);<br />

cprintf(“— Force Controller Outputs —”);<br />

gotoxy(25,4);<br />

cprintf(“====================<br />

==”);<br />

gotoxy(10,8);<br />

cprintf(“Output # 1- F1”);<br />

gotoxy(10,9);<br />

cprintf(“Output # 2- F2”);<br />

gotoxy(10,10);<br />

cprintf(“Output # 3- F3”);<br />

gotoxy(10,11);<br />

cprintf(“Output # 4- F4”);<br />

gotoxy(10,12);<br />

cprintf(“Output # 5- F5”);<br />

gotoxy(10,13);<br />

cprintf(“Output # 6- F6”);<br />

gotoxy(10,14);<br />

cprintf(“Output # 7- F7”);<br />

gotoxy(10,15);<br />

cprintf(“Output # 8- F8”);<br />

gotoxy(30,7);<br />

cprintf(“Output Status>>”);<br />

gotoxy(30,18);<br />

cprintf(“ESC=Exit to Main..”);<br />

_setcursortype(_NOCURSOR);<br />

for(;;)<br />

{<br />

while(!kbhit())<br />

{<br />

textcolor(LIGHTRED);<br />

outp(0x378,0);<br />

gotoxy(35,8);<br />

cprintf(“OFF”);<br />

gotoxy(35,9);<br />

cprintf(“OFF”);<br />

gotoxy(35,10);<br />

cprintf(“OFF”);<br />

gotoxy(35,11);<br />

cprintf(“OFF”);<br />

gotoxy(35,12);<br />

cprintf(“OFF”);<br />

gotoxy(35,13);<br />

cprintf(“OFF”);<br />

gotoxy(35,14);<br />

cprintf(“OFF”);<br />

gotoxy(35,15);<br />

cprintf(“OFF”);<br />

}<br />

cho=getch();<br />

textcolor(GREEN);<br />

if(cho==(char(59))){outp(0x378,1);gotoxy(35,8);cp<br />

rintf(“ ON”);};<br />

if(cho==(char(60))){outp(0x378,2);gotoxy(35,9);cp<br />

rintf(“ ON”);};<br />

if(cho==(char(61))){outp(0x378,4);gotoxy(35,10);cp<br />

rintf(“ ON”);};<br />

if(cho==(char(62))){outp(0x378,8);gotoxy(35,11);cp<br />

rintf(“ ON”);};<br />

if(cho==(char(63))){outp(0x378,16);gotoxy(35,12);c<br />

printf(“ ON”);};<br />

if(cho==(char(64))){outp(0x378,32);gotoxy(35,13);c<br />

printf(“ ON”);};<br />

if(cho==(char(65))){outp(0x378,64);gotoxy(35,14);c<br />

printf(“ ON”);};<br />

if(cho==(char(66))){outp(0x378,128);gotoxy(35,15);<br />

cprintf(“ ON”);};<br />

if(cho==(char(27))){openingmenu();};<br />

delay(100);<br />

}<br />

}<br />

//Help Utility<br />

void helpu()<br />

{<br />

window(1,1,80,25);<br />

clrscr();<br />

paintscreen(9);<br />

border();<br />

textbackground(LIGHTBLUE);<br />

textcolor(YELLOW);<br />

gotoxy(25,5);<br />

cprintf(“==M A I N H E L P M E N U==”);<br />

gotoxy(25,6);<br />

cprintf(“++++++++++++++++++++<br />

+”);<br />

textcolor(LIGHTRED);<br />

gotoxy(25,8);<br />

cprintf(“F1 >- Help on Running a Logic Program”);<br />

gotoxy(25,10);<br />

cprintf(“F2 >- Help on Viewing/Editing a Logic Program”);<br />

gotoxy(25,12);<br />

cprintf(“F3 >- Help on Viewing Input/Output Status”);<br />

gotoxy(25,14);<br />

cprintf(“F4 >- Help on Force Outputs”);<br />

gotoxy(25,16);<br />

cprintf(“F5 >- About This Program”);<br />

gotoxy(25,18);<br />

cprintf(“ESC >- Return to Main”);<br />

HELPCHOICE:<br />

while(!kbhit())<br />

{}<br />

char userchoiceh=getch();<br />

switch(userchoiceh)<br />

{<br />

case (char(59)):{textcolor(LIGHTRED);displayhelp(<br />

“HELPS.PG1”);}break;<br />

case (char(60)):{textcolor(LIGHTGREEN);displayhelp<br />

(“HELPS.PG2”);}break;<br />

case (char(61)):{textcolor(LIGHTCYAN);displayhelp<br />

(“HELPS.PG3”);}break;<br />

case (char(62)):{textcolor(YELLOW);displayhelp (“HELPS.<br />

PG4”);}break;<br />

case (char(63)):{textcolor(LIGHTMAGENTA);displayhelp(<br />

“HELPS.PG5”);}break;<br />

case (char(27)):openingmenu();break;<br />

default:goto HELPCHOICE;<br />

}<br />

getch();<br />

}<br />

//Exit To DOS<br />

void exiter()<br />

{<br />

window(1,1,80,25);<br />

clrscr();<br />

paintscreen(9);<br />

border();<br />

textcolor(YELLOW+BLINK);<br />

textbackground(9);<br />

gotoxy(25,10);<br />

cprintf(“Exiting to DOS.....”);<br />

delay(2000);<br />

textcolor(YELLOW);<br />

clrscr();<br />

exit(1);<br />

}<br />

//Logic Controller Commands<br />

//Series Contacts<br />

void ser(int inputno)<br />

{


int addr;<br />

switch(inputno)<br />

{<br />

case 1:addr=I1;break;<br />

case 2:addr=I2;break;<br />

case 3:addr=I3;break;<br />

case 4:addr=I4;break;<br />

case 5:addr=I5;break;<br />

case 6:addr=NI1;break;<br />

case 7:addr=NI2;break;<br />

case 8:addr=NI3;break;<br />

case 9:addr=NI4;break;<br />

case 10:addr=NI5;break;<br />

case 11:addr=O1;break;<br />

case 12:addr=O2;break;<br />

case 13:addr=O3;break;<br />

case 14:addr=O4;break;<br />

case 15:addr=O5;break;<br />

case 16:addr=O6;break;<br />

case 17:addr=O7;break;<br />

case 18:addr=O8;break;<br />

case 19:addr=NO1;break;<br />

case 20:addr=NO2;break;<br />

case 21:addr=NO3;break;<br />

case 22:addr=NO4;break;<br />

case 23:addr=NO5;break;<br />

case 24:addr=NO6;break;<br />

case 25:addr=NO7;break;<br />

case 26:addr=NO8;break;<br />

case 27:addr=CDN1;break;<br />

case 28:addr=CDN2;break;<br />

case 29:addr=CDN3;break;<br />

case 30:addr=CDN4;break;<br />

case 31:addr=CDN5;break;<br />

case 32:addr=~CDN1;break;<br />

case 33:addr=~CDN2;break;<br />

case 34:addr=~CDN3;break;<br />

case 35:addr=~CDN4;break;<br />

case 36:addr=~CDN5;break;<br />

case 37:addr=CODN1;break;<br />

case 38:addr=CODN2;break;<br />

case 39:addr=CODN3;break;<br />

case 40:addr=CODN4;break;<br />

case 41:addr=CODN5;break;<br />

case 42:addr=~CODN1;break;<br />

case 43:addr=~CODN2;break;<br />

case 44:addr=~CODN3;break;<br />

case 45:addr=~CODN4;break;<br />

case 46:addr=~CODN5;break;<br />

case 47:addr=TEN1;break;<br />

case 48:addr=TEN2;break;<br />

case 49:addr=TEN3;break;<br />

case 50:addr=TEN4;break;<br />

case 51:addr=TEN5;break;<br />

case 52:addr=~TEN1;break;<br />

case 53:addr=~TEN2;break;<br />

case 54:addr=~TEN3;break;<br />

case 55:addr=~TEN4;break;<br />

case 56:addr=~TEN5;break;<br />

case 57:addr=TDN1;break;<br />

case 58:addr=TDN2;break;<br />

case 59:addr=TDN3;break;<br />

case 60:addr=TDN4;break;<br />

case 61:addr=TDN5;break;<br />

case 62:addr=~TDN1;break;<br />

case 63:addr=~TDN2;break;<br />

case 64:addr=~TDN3;break;<br />

case 65:addr=~TDN4;break;<br />

case 66:addr=~TDN5;break;<br />

case 67:addr=RTDN;break;<br />

case 68:addr=~RTDN;break;<br />

}<br />

res=res&addr;<br />

}<br />

//Parallel Contacts<br />

void par(int inputno)<br />

{<br />

int addr;<br />

switch(inputno)<br />

{<br />

case 1:addr=I1;break;<br />

case 2:addr=I2;break;<br />

case 3:addr=I3;break;<br />

case 4:addr=I4;break;<br />

case 5:addr=I5;break;<br />

case 6:addr=NI1;break;<br />

case 7:addr=NI2;break;<br />

case 8:addr=NI3;break;<br />

case 9:addr=NI4;break;<br />

case 10:addr=NI5;break;<br />

case 11:addr=O1;break;<br />

case 12:addr=O2;break;<br />

case 13:addr=O3;break;<br />

case 14:addr=O4;break;<br />

case 15:addr=O5;break;<br />

case 16:addr=O6;break;<br />

case 17:addr=O7;break;<br />

case 18:addr=O8;break;<br />

case 19:addr=NO1;break;<br />

case 20:addr=NO2;break;<br />

case 21:addr=NO3;break;<br />

case 22:addr=NO4;break;<br />

case 23:addr=NO5;break;<br />

case 24:addr=NO6;break;<br />

case 25:addr=NO7;break;<br />

case 26:addr=NO8;break;<br />

case 27:addr=CDN1;break;<br />

case 28:addr=CDN2;break;<br />

case 29:addr=CDN3;break;<br />

case 30:addr=CDN4;break;<br />

case 31:addr=CDN5;break;<br />

case 32:addr=~CDN1;break;<br />

case 33:addr=~CDN2;break;<br />

case 34:addr=~CDN3;break;<br />

case 35:addr=~CDN4;break;<br />

case 36:addr=~CDN5;break;<br />

case 37:addr=CODN1;break;<br />

case 38:addr=CODN2;break;<br />

case 39:addr=CODN3;break;<br />

case 40:addr=CODN4;break;<br />

case 41:addr=CODN5;break;<br />

case 42:addr=~CODN1;break;<br />

case 43:addr=~CODN2;break;<br />

case 44:addr=~CODN3;break;<br />

case 45:addr=~CODN4;break;<br />

case 46:addr=~CODN5;break;<br />

case 47:addr=TEN1;break;<br />

case 48:addr=TEN2;break;<br />

case 49:addr=TEN3;break;<br />

case 50:addr=TEN4;break;<br />

case 51:addr=TEN5;break;<br />

case 52:addr=~TEN1;break;<br />

case 53:addr=~TEN2;break;<br />

case 54:addr=~TEN3;break;<br />

case 55:addr=~TEN4;break;<br />

case 56:addr=~TEN5;break;<br />

case 57:addr=TDN1;break;<br />

case 58:addr=TDN2;break;<br />

case 59:addr=TDN3;break;<br />

case 60:addr=TDN4;break;<br />

case 61:addr=TDN5;break;<br />

case 62:addr=~TDN1;break;<br />

case 63:addr=~TDN2;break;<br />

case 64:addr=~TDN3;break;<br />

case 65:addr=~TDN4;break;<br />

case 66:addr=~TDN5;break;<br />

case 67:addr=RTDN;break;<br />

case 68:addr=~RTDN;break;<br />

}<br />

res=res|addr;<br />

}<br />

// Outputs<br />

void ope(int outputno)<br />

{<br />

if(res==1)<br />

{<br />

switch(outputno)<br />

{<br />

case 1:O1=1;break;<br />

case 2:O2=1;break;<br />

case 3:O3=1;break;<br />

case 4:O4=1;break;<br />

case 5:O5=1;break;<br />

case 6:O6=1;break;<br />

July 2004<br />

c o n s t r u c t i o n<br />

case 7:O7=1;break;<br />

case 8:O8=1;break;<br />

}<br />

}<br />

if(res==0)<br />

{<br />

switch(outputno)<br />

{<br />

case 1:O1=0;break;<br />

case 2:O2=0;break;<br />

case 3:O3=0;break;<br />

case 4:O4=0;break;<br />

case 5:O5=0;break;<br />

case 6:O6=0;break;<br />

case 7:O7=0;break;<br />

case 8:O8=0;break;<br />

}<br />

}<br />

res=1;<br />

}<br />

//latched output<br />

void opl(int outputno)<br />

{<br />

if(res==1)<br />

{<br />

switch(outputno)<br />

{<br />

case 1:O1=1;break;<br />

case 2:O2=1;break;<br />

case 3:O3=1;break;<br />

case 4:O4=1;break;<br />

case 5:O5=1;break;<br />

case 6:O6=1;break;<br />

case 7:O7=1;break;<br />

case 8:O8=1;break;<br />

}<br />

}<br />

res=1;<br />

}<br />

//Output Unlatch<br />

void opu(int outputno)<br />

{<br />

if(res==1)<br />

{<br />

switch(outputno)<br />

{<br />

case 1:O1=0;break;<br />

case 2:O2=0;break;<br />

case 3:O3=0;break;<br />

case 4:O4=0;break;<br />

case 5:O5=0;break;<br />

case 6:O6=0;break;<br />

case 7:O7=0;break;<br />

case 8:O8=0;break;<br />

}<br />

}<br />

res=1;<br />

}<br />

//Timer Function<br />

int tmr(int tno,int timeset)<br />

{<br />

switch(tno)<br />

{<br />

case(1):T1=timeset;break;<br />

case(2):T2=timeset;break;<br />

case(3):T3=timeset;break;<br />

case(4):T4=timeset;break;<br />

case(5):T5=timeset;break;<br />

}<br />

if(res==1)<br />

{<br />

switch(tno)<br />

{<br />

case(1):if(tmrscan1==0){first1=time(NULL);tmrscan1<br />

=1;};break;<br />

case(2):if(tmrscan2==0){first2=time(NULL);tmrscan2<br />

=1;};break;<br />

case(3):if(tmrscan3==0){first3=time(NULL);tmrscan3<br />

=1;};break;<br />

case(4):if(tmrscan4==0){first4=time(NULL);tmrscan4<br />

=1;};break;<br />

case(5):if(tmrscan1==0){first1=time(NULL);tmrscan1<br />

electronics for you


c o n s t r u c t i o n<br />

=1;};break;<br />

}<br />

switch(tno)<br />

{<br />

case(1):{second1=time(NULL);};break;<br />

case(2):{second2=time(NULL);};break;<br />

case(3):{second3=time(NULL);};break;<br />

case(4):{second4=time(NULL);};break;<br />

case(5):{second5=time(NULL);};break;<br />

}<br />

switch(tno)<br />

{<br />

case(1):if(TDN1!=1){TEN1=1,TACC1=second1first1;};break;case(2):if(TDN2!=1){TEN2=1;TACC2=second2first2;};break;case(3):if(TDN3!=1){TEN3=1;TACC3=second3first3;};break;case(4):if(TDN4!=1){TEN4=1;TACC4=second4first4;};break;case(5):if(TDN5!=1){TEN5=1;TACC5=second5first5;};break;<br />

}<br />

switch(tno)<br />

{<br />

case(1):if(difftime(second1,first1)==T1){TDN1=1;};<br />

break;<br />

case(2):if(difftime(second2,first2)==T2){TDN2=1;};<br />

break;<br />

case(3):if(difftime(second3,first3)==T3){TDN3=1;};<br />

break;<br />

case(4):if(difftime(second4,first4)==T4){TDN4=1;};<br />

break;<br />

case(5):if(difftime(second5,first5)==T5){TDN5=1;};<br />

break;<br />

}<br />

}<br />

if(res==0)<br />

{<br />

switch(tno)<br />

{<br />

case(1):{TEN1=0;TACC1=0;tmrscan1=0;TDN1=<br />

0;};break;<br />

case(2):{TEN2=0;TACC2=0;tmrscan2=0;TDN2=<br />

0;};break;<br />

case(3):{TEN3=0;TACC3=0;tmrscan3=0;TDN3=<br />

0;};break;<br />

case(4):{TEN4=0;TACC4=0;tmrscan4=0;TDN4=<br />

0;};break;<br />

case(5):{TEN5=0;TACC5=0;tmrscan5=0;TDN5=<br />

0;};break;<br />

}<br />

}<br />

}<br />

//Up Counter<br />

int ctu(int cno,int countset)<br />

{<br />

switch(cno)<br />

{<br />

case(1):C1=countset;break;<br />

case(2):C2=countset;break;<br />

case(3):C3=countset;break;<br />

case(4):C4=countset;break;<br />

case(5):C5=countset;break;<br />

}<br />

if(res==1&&risingedge==0)<br />

{<br />

switch(cno)<br />

{<br />

case(1):if(CDN1!=1){CACC1=CACC1+1;};break;<br />

case(2):if(CDN2!=1){CACC2=CACC2+1;};break;<br />

case(3):if(CDN3!=1){CACC3=CACC3+1;};break;<br />

case(4):if(CDN4!=1){CACC4=CACC4+1;};break;<br />

case(5):if(CDN1!=1){CACC5=CACC5+1;};break;<br />

}<br />

risingedge=1;<br />

electronics for you July 2004<br />

}<br />

if(res==0&&risingedge==1)risingedge=0;<br />

switch(cno)<br />

{<br />

case(1):if(CACC1==C1)CDN1=1;break;<br />

case(2):if(CACC2==C2)CDN2=1;break;<br />

case(3):if(CACC3==C3)CDN3=1;break;<br />

case(4):if(CACC4==C4)CDN4=1;break;<br />

case(5):if(CACC5==C5)CDN5=1;;break;<br />

}<br />

if(countset==0&&res==1)<br />

{<br />

switch(cno)<br />

{<br />

case(1):{CACC1=0;CDN1=0;};break;<br />

case(2):{CACC2=0;CDN2=0;};break;<br />

case(3):{CACC3=0;CDN3=0;};break;<br />

case(4):{CACC4=0;CDN4=0;};break;<br />

case(5):{CACC5=0;CDN5=0;};break;<br />

}<br />

}<br />

}<br />

//Down Counter<br />

int ctd(int cno,int countset)<br />

{<br />

switch(cno)<br />

{<br />

case(1):{CO1=countset;};break;<br />

case(2):{CO2=countset;};break;<br />

case(3):{CO3=countset;};break;<br />

case(4):{CO4=countset;};break;<br />

case(5):{CO5=countset;};break;<br />

}<br />

if(res==1&&risingedge==0)<br />

{<br />

switch(cno)<br />

{<br />

case(1):if(CODN1!=1){cd1=cd1+1;COACC1=CO1cd1;};break;case(2):if(CODN2!=1){cd2=cd2+1;COACC2=CO2cd2;};break;case(3):if(CODN3!=1){cd3=cd3+1;COACC3=CO3cd3;};break;case(4):if(CODN4!=1){cd4=cd4+1;COACC4=CO4cd4;};break;case(5):if(CODN3!=1){cd5=cd5+1;COACC5=CO5cd5;};break;<br />

}<br />

risingedge=1;<br />

}<br />

if(res==0&&risingedge==1)risingedge=0;<br />

switch(cno)<br />

{<br />

case(1):if(CO1==cd1)CODN1=1;break;<br />

case(2):if(CO2==cd2)CODN2=1;break;<br />

case(3):if(CO3==cd3)CODN3=1;break;<br />

case(4):if(CO4==cd4)CODN4=1;break;<br />

case(5):if(CO5==cd5)CODN5=1;;break;<br />

}<br />

if(countset==0&&res==1)<br />

{<br />

switch(cno)<br />

{<br />

case(1):{COACC1=0;CODN1=0;};break;<br />

case(2):{COACC2=0;CODN2=0;};break;<br />

case(3):{COACC3=0;CODN3=0;};break;<br />

case(4):{COACC4=0;CODN4=0;};break;<br />

case(5):{COACC5=0;CODN5=0;};break;<br />

}<br />

}<br />

}<br />

//Real Time Output<br />

int rto(int hourr,int minn)<br />

{<br />

int hr,mn;<br />

if(res==1)<br />

{<br />

gettime(&t);<br />

if(hourr==t.ti_hour && minn==t.ti_min)<br />

{<br />

RTDN=1;<br />

}<br />

if(hourr==0 && minn==0)<br />

{<br />

RTDN=0;<br />

}<br />

}<br />

}<br />

//Reading From And Sending Outputs<br />

void inputread()<br />

{<br />

int inpval;<br />

inpval=inp(0x379);<br />

if((inpval&8)==0)I1=1;<br />

if((inpval&8)==8)I1=0;<br />

if((inpval&16)==0)I2=1;<br />

if((inpval&16)==16)I2=0;<br />

if((inpval&32)==0)I3=1;<br />

if((inpval&32)==32)I3=0;<br />

if((inpval&64)==0)I4=1;<br />

if((inpval&64)==64)I4=0;<br />

if((inpval&128)==0)I5=0;<br />

if((inpval&128)==128)I4=1;<br />

NI1=~I1;<br />

NI2=~I2;<br />

NI3=~I3;<br />

NI4=~I4;<br />

NI5=~I5;<br />

NO1=~O1;<br />

NO2=~O2;<br />

NO3=~O3;<br />

NO4=~O4;<br />

NO5=~O5;<br />

NO6=~O6;<br />

NO7=~O7;<br />

NO8=~O8;<br />

}<br />

//Sending Output To The Port<br />

void setoutputs()<br />

{<br />

int outval;<br />

outval=1*O1+2*O2+4*O3+8*O4+16*O5+32*O6+6<br />

4*O7+128*O8;<br />

outp(0x378,outval);<br />

}<br />

//Display Status On Screen<br />

void displaystat()<br />

{<br />

textcolor(YELLOW);<br />

gotoxy(25,8);<br />

cprintf(“%d”,I1);<br />

gotoxy(25,9);<br />

cprintf(“%d”,I2);<br />

gotoxy(25,10);<br />

cprintf(“%d”,I3);<br />

gotoxy(25,11);<br />

cprintf(“%d”,I4);<br />

gotoxy(25,12);<br />

cprintf(“%d”,I5);<br />

gotoxy(26,15);<br />

cprintf(“%d”,O1);<br />

gotoxy(26,16);<br />

cprintf(“%d”,O2);<br />

gotoxy(26,17);<br />

cprintf(“%d”,O3);<br />

gotoxy(26,18);<br />

cprintf(“%d”,O4);<br />

gotoxy(26,19);<br />

cprintf(“%d”,O5);<br />

gotoxy(26,20);<br />

cprintf(“%d”,O6);<br />

gotoxy(26,21);<br />

cprintf(“%d”,O7);<br />

gotoxy(26,22);<br />

cprintf(“%d”,O8);<br />

gotoxy(55,5);<br />

cprintf(“%3d”,C1);


gotoxy(55,6);<br />

cprintf(“%3d”,C2);<br />

gotoxy(55,7);<br />

cprintf(“%3d”,C3);<br />

gotoxy(55,8);<br />

cprintf(“%3d”,C4);<br />

gotoxy(55,9);<br />

cprintf(“%3d”,C5);<br />

gotoxy(62,5);<br />

cprintf(“%3d”,CACC1);<br />

gotoxy(62,6);<br />

cprintf(“%3d”,CACC2);<br />

gotoxy(62,7);<br />

cprintf(“%3d”,CACC3);<br />

gotoxy(62,8);<br />

cprintf(“%3d”,CACC4);<br />

gotoxy(62,9);<br />

cprintf(“%3d”,CACC5);<br />

gotoxy(68,5);<br />

cprintf(“%d”,CDN1);<br />

gotoxy(68,6);<br />

cprintf(“%d”,CDN2);<br />

gotoxy(68,7);<br />

cprintf(“%d”,CDN3);<br />

gotoxy(68,8);<br />

cprintf(“%d”,CDN4);<br />

gotoxy(68,9);<br />

cprintf(“%d”,CDN5);<br />

gotoxy(55,12);<br />

cprintf(“%3d”,CO1);<br />

gotoxy(55,13);<br />

cprintf(“%3d”,CO2);<br />

gotoxy(55,14);<br />

cprintf(“%3d”,CO3);<br />

gotoxy(55,15);<br />

cprintf(“%3d”,CO4);<br />

gotoxy(55,16);<br />

cprintf(“%3d”,CO5);<br />

gotoxy(62,12);<br />

cprintf(“%3d”,COACC1);<br />

gotoxy(62,13);<br />

cprintf(“%3d”,COACC2);<br />

gotoxy(62,14);<br />

cprintf(“%3d”,COACC3);<br />

gotoxy(62,15);<br />

cprintf(“%3d”,COACC4);<br />

gotoxy(62,16);<br />

cprintf(“%3d”,COACC5);<br />

gotoxy(68,12);<br />

cprintf(“%d”,CODN1);<br />

gotoxy(68,13);<br />

cprintf(“%d”,CODN2);<br />

gotoxy(68,14);<br />

cprintf(“%d”,CODN3);<br />

gotoxy(68,15);<br />

cprintf(“%d”,CODN4);<br />

gotoxy(68,16);<br />

cprintf(“%d”,CODN5);<br />

gotoxy(49,19);<br />

cprintf(“%d”,TEN1);<br />

gotoxy(49,20);<br />

cprintf(“%d”,TEN2);<br />

gotoxy(49,21);<br />

cprintf(“%d”,TEN3);<br />

gotoxy(49,22);<br />

cprintf(“%d”,TEN4);<br />

gotoxy(49,23);<br />

cprintf(“%d”,TEN5);<br />

gotoxy(57,19);<br />

cprintf(“%3d”,T1);<br />

gotoxy(57,20);<br />

cprintf(“%3d”,T2);<br />

gotoxy(57,21);<br />

cprintf(“%3d”,T3);<br />

gotoxy(57,22);<br />

cprintf(“%3d”,T4);<br />

gotoxy(57,23);<br />

cprintf(“%3d”,T5);<br />

gotoxy(64,19);<br />

cprintf(“%3d”,TACC1);<br />

gotoxy(64,20);<br />

cprintf(“%3d”,TACC2);<br />

gotoxy(64,21);<br />

cprintf(“%3d”,TACC3);<br />

gotoxy(64,22);<br />

cprintf(“%3d”,TACC4);<br />

gotoxy(64,23);<br />

cprintf(“%3d”,TACC5);<br />

gotoxy(70,19);<br />

July 2004<br />

c o n s t r u c t i o n<br />

cprintf(“%d”,TDN1);<br />

gotoxy(70,20);<br />

cprintf(“%d”,TDN2);<br />

gotoxy(70,21);<br />

cprintf(“%d”,TDN3);<br />

gotoxy(70,22);<br />

cprintf(“%d”,TDN4);<br />

gotoxy(70,23);<br />

cprintf(“%d”,TDN5);<br />

gotoxy(56,24);<br />

cprintf(“%d”,RTDN);<br />

gotoxy(27,23);<br />

cprintf(“%.2f”,te*1000);<br />

}<br />

//Help File Display<br />

void displayhelp(char helpfilename[10])<br />

{<br />

fstream infile;<br />

textbackground(BLACK);<br />

window(1,1,80,25);<br />

const int max=80;<br />

char buffer[max];<br />

clrscr();<br />

infile.open(helpfilename,ios::in);<br />

if(infile.fail())<br />

{<br />

window(10,8,70,9);<br />

textcolor(YELLOW+BLINK);<br />

clrscr();<br />

cprintf(“.....Help not Available or Error Opening File ...\n\<br />

r..Press any Key to Return to Main.....”);<br />

getch();<br />

openingmenu();<br />

}<br />

while(!infile.eof())<br />

{<br />

infile.getline(buffer,max);<br />

cout

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!