Temp-Indicator Using AT89C52
Temp-Indicator Using AT89C52
i ocnt i o n
Temperature Indicator
Using AT89C52
Aditya Rane
The circuit
July 2004
Fig. 1 shows the block diagram of the temperature indicator using microcontroller
AT89C52. The power supply
for the circuit is regulated
by IC 7805 and supplied to
different parts of the unit.
construction
Parts List
Semiconductors:
IC1
- 7805 regulator IC
IC2
- AT89C52 microcontroller
IC3
- DS1621 temperature sensor
D1-D4
- 1N4007 rectifier diodes
LED1
- Red LED
Resistors (all -watt, 5% carbon,
unless stated otherwise):
R1
- 1-kilo-ohm
R2
- 47-kilo-ohm
R3
- 10-kilo-ohm
R4, R5
- 4.7-kilo-ohm
VR1
- 1-kilo-ohm preset
The thermal
alarm output
(Tout) of IC DS1621
activates when
the temperature
exc e e d s u s e r defined high temperature TH. The
output remains
and temperature readings are all communicated to/from IC DS1621 over a 2-wire
serial cable. The most significant bit (MSB)
of the data is transmitted first and the last
significant bit (LSB) is transmitted last.
Addressing. The chip address of
DS1621 comprises internal preset code nibble 1001 (binary) followed by externally
configurable address pins/bits A2, A1 and
Capacitors:
C1
- 470F, 25V electrolytic
capacitor
C2, C3, C4 - 0.1F ceramic disk
C5
- 10F, 16V electrolytic
capacitor
C6,C7
- 33pF ceramic capacitor
Miscellaneous:
Transformer - 230V AC primary to 0-9V,
250mA secondary
Crystal
- 12 MHz
LCD
- 161 LCD module
S1
- On/Off SPST switch
construction
flag, 1 is write to an E2 memory cell in
progress, 0 indicates that non-volatile
memory is not busy, POL is non-volatile
output polarity bit (1=active-high and
Table I
DS1621 Command Set
Instruction
Description
Protocol
Read Temperature
Read Counter
Read Slope
Start Convert T
Stop Convert T
Access TH
Access TL
Access Configuration
Aah
July 2004
A8h
A9h
EEh
22h
A1h
A2h
ACh
The program
The C-language program for microcontroller AT89C52 is compiled using crosscompiler C51 Version 7.10 from Keil Soft-
construction
ware. The demo version of this compiler
is available for free on the Website www.
keil.com. It can compile programs up to
2 kB only, which is sufficient for writing
most programs.
For testing the display, the program
Hello.c is given here. This program, when
loaded to AT89C52, displays Hello! How
R U? on the LCD. The Hello.c program
has nothing to do with temperature. It
just guarantees a perfect communication
between the LCD and the microcontroller.
For temperature indication, the program
Temp52.c is used. The programs Hello.c
and Temp52.c, along with the hex files, are
given at the end of this article.
The communication interface between the temperature sensor and the
microcontroller chip follows the I2C (Inter Integrated Circuit) standard, which
is implemented in C here. I 2C is a
simple master/slave type interface.
Simplicity of the IC system is primarily
due to the bidirectional 2-wire (SDA and
SCL) design and the protocol format.
Bidirectional communication is through
2-wire lines (which are either activelow or passive-high). In the program,
the i2c_stop, i2c_start, i2c_write and
i2c_read functions are used for communicating Clock and Data from DS1621 to
P3.0 and P3.1 of AT89C52, respectively.
Such functions as command, ready and
display in the program are used for driving the LCD.
Program compilation for 8051 family
controller. Keil C51 can compile C programs for most of the Atmel family microcontrollers. It also supports other devices.
Unlike other cross-compilers (Hi-Tech, IAR,
SDCC, etc), Keil C51 offers such features as
fast code generation, strong multitasking
environment, real-time operating system
and inbuilt code optimisation. To enjoy
these features, youll need full version of
the compiler.
Keil C51 has options to generate
Assembly code and all the code listing
supported by 8051 family, but Assembly
language generated cannot be recompiled
on any other assembler. As far as code
generation is concerned, it uses minimum RAM and on-chip flash, allowing
faster and optimised program in IntelHex format, which can be loaded to the
microcontroller using any programmer.
Conversion of C program into Intel-Hex
format takes only a few seconds. In fact,
you dont require all that long Assembly
program in order to generate the output
hex file.
electronics for you
July 2004
construction
Frontline Electronics.) Now integrate the
microcontroller chip into the populated
PCB comprising the temperature sensor
and the LCD module.
Troubleshooting
1. Check the COM port on your PC before
programming.
temp52.c
/* Written By: Aditya Rane
T.E Computer Engg, Lokmanya Tilak College of Engineering, New Bombay, Vashi
E-mail: aditya@orionengg.com
Program for temperature indicator compiled under keil
'C' */
#include<stdio.h>
#include<string.h>
#include<Regx52.h>
//-----------------------------------------------------------------------//Global Variable
//------------------------------------------------------------------------int temperature;
#define
HIGH 0x01 // Active High Signal
#define
LOW 0x00 // Active Low Signal
#define
TRUE 0x01 // Active High State
#define
FALSE 0x00 // Active Low State
//------------------------------------------------------------------------// Functions Prototyping
//------------------------------------------------------------------------void ready (void);
void command (int);
void display (char *);
void i2c_stop (void);
void i2c_start (void);
void i2c_write (unsigned char);
unsigned char i2c_read (void);
void convert (unsigned char);
//------------------------------------------------------------------------// Port Defination
//------------------------------------------------------------------------#define
DATA P3_1
// Serial data
#define
CLOCK P3_0 // Serial clock
//Begining of Main Program
void main (void)
{
int tmp;
char str[16];
bit flag = FALSE;
unsigned char ch;
void command (int);
void display (char *);
command(0x3c);
command(0x0c);
command(0x06);
while(1)
{
i2c_start();
i2c_write(0x90);
i2c_write(0xEE);
i2c_stop();
i2c_start();
i2c_write(0x90);
i2c_write(0xAA);
i2c_start();
i2c_write(0x91);
ch = i2c_read();
i2c_stop();
temperature = 0;
convert(ch);
if(flag == FALSE)
{
flag = TRUE;
}
else
{
tmp = temperature;
if(tmp != temperature)
{
tmp = temperature;
sprintf(str,"%d%s
",temperature," Centigrade");
command(0x01);
command(0x80);
display(str);
}
}
}
}
//Delay Servive Routine
void delay_time (void)
{
unsigned int i;
for(i=0;i<100;i++);
}
//I2C Start Function
void i2c_start (void)
{
DATA = HIGH;
delay_time();
CLOCK = HIGH;
delay_time();
DATA = LOW;
CLOCK = LOW;
}
//I2C Stop Function
void i2c_stop (void)
{
unsigned char i;
CLOCK = LOW;
DATA = LOW;
CLOCK = HIGH;
delay_time();
DATA = HIGH;
i = DATA;
}
//I2C Data Write Function
void i2c_write (unsigned char j)
{
unsigned char i;
for(i=0;i<8;i++)
{
DATA = ((j & 0x80) ? 1 : 0);
j <<= 1;
CLOCK = HIGH;
delay_time();
CLOCK = LOW;
}
i = DATA;
CLOCK = HIGH;
delay_time();
CLOCK = LOW;
}
//I2C Data Read Function
unsigned char i2c_read (void)
{
unsigned char i,j;
j = 0;
i = DATA;
for(i=0;i<8;i++)
{
j <<= 1;
CLOCK = HIGH;
j |= DATA;
delay_time();
CLOCK = LOW;
}
return j;
}
//Binary to Decimal Conversion Function
void convert (unsigned char ch)
{
char x;
unsigned char arr[8]={128,64,32,16,8,4,2,1};
if(((ch & 0x80) ? 1 : 0)==0)
{
for(x=0;x<8;++x)
{
if(((ch & 0x80) ? 1 : 0))
temperature = temperature +
arr[x] * ((ch & 0x80) ? 1 : 0);
ch <<= 1;
}
}
else
{
ch=~ch;
ch=ch+1;
for(x=0;x<8;++x)
{
if(((ch & 0x80) ? 1 : 0))
temperature = temperature +
arr[x] * ((ch & 0x80) ? 1 : 0);
ch <<= 1;
}
temperature=-temperature;
}
}
//Display Ready Check Function
void ready (void)
{
P3_4 = 0x00;
P1 = 0xff;
P3_2 = 0x00;
P3_3 = 0x01;
while(P1_7)
{
P3_4 = 0x00;
P3_4 = 0x01;
}
P3_4 = 0x00;
}
//Display Command Function void command (int a)
{
ready();
P1 = a;
P3_2 = 0x00;
P3_3 = 0x00;
P3_4 = 0x01;
P3_4 = 0x00;
}
//Display Write Function
void display (char *str)
{
unsigned int i;
for(i=0;i<=strlen(str)-1;++i)
{
if(i == 8)
command(0xc0);
if(i == 16)
command(0x80);
ready();
P1 = str[i];
P3_2 = 0x01;
P3_3 = 0x00;
P3_4 = 0x01;
P3_4 = 0x00;
}
}
July 2004
construction
temp52.hex
:100F270025642573002043656E7469677261646583
:090F3700008040201008040201B2
:100DA800C2007F3C7E00120F9A7F0C7E00120F9AC1
:100DB8007F067E00120F9A120F8B7F90120EB87F5B
:100DC800EE120EB8120F6A120F8B7F90120EB87FB8
:100DD800AA120EB8120F8B7F91120EB8120F098F3C
:100DE80034120F6AE4F508F509AF34120CF220004A
:100DF8000AD20085082285092380BCE5236509708D
:100E080004E522650860B08508228509237538FF46
:100E180075390F753A2785083B85093C753DFF757F
:100E28003E0F753F2C7B007A00792412085C7F0105
:100E38007E00120F9A7F807E00120F9A7B007A0044
:080E48007924120E50020DBFC7
:0E0F7C00E4FFFE0FBF00010EEF64644E70F53F
:010F8A002244
:0F0F8B00D2B1120F7CD2B0120F7CC2B1C2B02211
:100F6A00C2B0C2B1D2B0120F7CD2B1A2B1E433F591
:010F7A003541
:010F7B002253
:020EB800AD0784
:100EBA00E4FCED30E703D38001C392B1ED25E0FDF8
:100ECA00D2B0120F7CC2B00CBC08E7A2B1E433FC6A
:070EDA00D2B0120F7CC2B080
:010EE10022EE
:100F0900E4FDA2B1E4FCED25E0FDD2B0A2B1E433E9
:0D0F19004205120F7CC2B00CBC08EBAF0506
:010F260022A8
:020CF2008F353C
:100CF40078377C007D007BFF7A0F79387E007F088F
:100D0400120C2CE53530E7047F0180027F00EF7080
:100D140041F536E53530E7047F0180027F00EF605E
:100D24002374372536F8E6FD7C00E5357E0030E790
:100D3400047F0180027F00120C7FEF2509F509EE84
:100D44003508F508E53525E0F5350536E536B4080A
:100D5400C2226335FF0535E4F536E53530E7047F17
:100D64000180027F00EF602374372536F8E6FD7CAE
:100D740000E5357E0030E7047F0180027F00120C1D
:100D84007FEF2509F509EE3508F508E53525E0F589
:100D9400350536E536B408C2C3E49509F509E4958A
:030DA40008F50847
:010DA7002229
:100F4000C2B47590FFC2B2D2B3309706C2B4D2B465
:050F500080F7C2B4228D
:0E0F9A00120F408F90C2B2C2B3D2B4C2B422C2
:060E50008B358A3689375C
:100E5600E4F538F539AB35AA36A937120F55EF2424
:100E6600FFFFEE34FFFED3E5399FE5389E5042E59D
:100E7600396408453870067FC0FE120F9AE539645A
:100E860010453870067F80FE120F9A120F40AB3560
:100E9600AA36A937853982853883120C52F590D245
:100EA600B2C2B3D2B4C2B40539E53970A8053880E8
:010EB600A497
:010EB7002218
:03000000020FA844
:0C0FA800787FE4F6D8FD758148020DA8A2
:100B5C00E709F608DFFA8046E709F208DFFA803E7B
:100B6C0088828C83E709F0A3DFFA8032E309F60868
:100B7C00DFFA8078E309F208DFFA807088828C83D0
:100B8C00E309F0A3DFFA806489828A83E0A3F60884
:100B9C00DFFA805889828A83E0A3F208DFFA804C5E
:100BAC0080D280FA80C680D4806980F28033801035
:100BBC0080A680EA809A80A880DA80E280CA80339E
:100BCC0089828A83ECFAE493A3C8C582C8CCC58316
:100BDC00CCF0A3C8C582C8CCC583CCDFE9DEE780E6
:100BEC000D89828A83E493A3F608DFF9ECFAA9F065
:100BFC00EDFB2289828A83ECFAE0A3C8C582C8CCBB
:100C0C00C583CCF0A3C8C582C8CCC583CCDFEADED3
:100C1C00E880DB89828A83E493A3F208DFF980CC35
:100C2C0088F0EF60010E4E60C388F0ED2402B4042E
:100C3C000050B9F582EB2402B4040050AF232345D5
:060C4C008223900BAC7343
:100C5200BB010CE58229F582E5833AF583E0225057
:100C620006E92582F8E622BBFE06E92582F8E222A1
:0D0C7200E58229F582E5833AF583E49322BB
:100C7F00EF8DF0A4A8F0CF8CF0A428CE8DF0A42E89
:020C8F00FE2243
:10080000E5442438F8E60544227835300802783883
:10081000E475F001120CBC020C912001EB7F2ED28A
:10082000018018EF540F2490D43440D4FF30050BCE
:10083000EF24BFB41A0050032461FFE545600215A0
:10084000450548E5487002054730080D7835E475E0
:10085000F001120CBCEF020CAA020EE27403D208E3
:100860008003E4C208F5448B358A368937E4F545C0
:10087000F547F548E54560077F2012083B80F57590
:1008800046FFC202C201C203C204C206C207C209B5
:10089000120809FF700D3008057F0012084CAF48A0
:1008A000AE4722B4255FC2D5C205120809FF24D085
:1008B000B40A00501A75F00A784530D50508B6FF1D
:1008C0000106C6A426F620D5047002D20480D924DD
:1008D000CFB41A00EF5004C2E5D205020A4CD2028E
:1008E00080C6D20180C0D20380BCD2D580BAD206E5
:1008F00080B47F2012083B2003077401B5450040F7
:10090000F1120800FF12083B020874D209D20780D6
:1009100095120800FB120800FA120800F94A4B7001
:1009200006791D7A0B7BFF20032EE545602A7E00A9
:100930008E82758300120C5260060EEE654670F0D2
:10094000C2D5EBC0E0EAC0E0E9C0E0EE120A93D005
:10095000E0F9D0E0FAD0E0FB120C91FF60AAEBC006
:10096000E0EAC0E0E9C0E012083BD0E02401F9D0A1
:10097000E03400FAD0E0FBE5460460DCD546D980DF
:10098000877BFF7A0A798FD203809C791080027965
:1009900008C207C2098008D2D5790A8004790AC240
:1009A000D5E546047002F546E4FAFDFEFF120800A4
:1009B000FC7B08200213120800FD7B1030010A1294
:1009C0000800FE120800FF7B20EC3382D592D55040
:1009D00013C3E43001069FFFE49EFEE42002039D62
:1009E000FDE49CFCE4CBF8C202EC700CCFCECDCC85
:1009F000E824F8F870F38017C3EF33FFEE33FEED11
:100A000033FDEC33FCEB33FB994002FB0FD8E9EBF1
:100A1000300205F8D0E0C448B202C0E00AEC4D4E06
:100A20004F78207B0070C2EAB5460040BCC0E0129F
:100A30000A95D0F0D0E0200204C4C0E0C4B202C0E5
:100A4000F0120824D0F0D5F0EB020874120CCC0997
:100A50001153098B5808E24C08DE42098F4F099761
:0F0A60004409974908F743099D550981460981C3
:100A6F00450981470B3D5008E62D08EA2E090D2B4D
:100A7F0008EE23090B200B262A08A64800000905BB
:100A8F003F3F3F00790AA2D5200414300609B91060
:100A9F00020404B9080104A2D52007025001042062
:100AAF0003689203B545005034C0E07F203004192D
:100ABF007F30A20372077206500F120AECC203C2F4
:100ACF0007C206C2097F30800F300603E9C0E0126B
:100ADF00083B300603D0E0F9D0E0B545CC3006171F
:100AEF007F30B9100C12083B7F583005077F788094
:100AFF0003B9080312083B3003057F2D02083B7F23
:100B0F00202009F87F2B2007F322920380CF286E35
:100B1F00756C6C2900D2021208003002F8C20278FC
:100B2F004530D50108F60208A62D50434958120842
:100B3F00002403B405004001E4900B389312082CF5
:0D0B4F00743A12082CD20475450402098B7B
:100F5500E4FFFE120C91600C0FEF70010E09E970B1
:050F6500F20A80EF22FA
:100C9100BB010689828A83E0225002E722BBFE0261
:090CA100E32289828A83E4932294
:100CAA00BB010689828A83F0225002F722BBFE0129
:020CBA00F32223
:100CBC00FAE6FB0808E6F925F0F618E6CA3AF62239
:100CCC00D083D082F8E4937012740193700DA3A3B7
:100CDC0093F8740193F5828883E4737402936860CB
:060CEC00EFA3A3A380DFCB
:100EE200EFB40A07740D120EED740A309811A89926
:100EF200B8130CC2983098FDA899C298B811F63070
:070F020099FDC299F5992247
:00000001FF
Hello.c
#include<stdio.h>
#include<string.h>
#include<Regx52.h>
ready();
P1=a;
P3_2=0x00;
P3_3=0x00;
P3_4=0x01;
P3_4=0x00;
}
void ready(void);
void command(int);
void display(char *);
void main (void)
{
command(0x3c);
command(0x0c);
command(0x06);
command(0x01);
command(0x80);
display("Hello! How R U ?");
while(1);
}
}
}
void command(int a)
{
void ready(void);
P3_4 = 0x01;
P3_4 = 0x00;
void ready(void)
{
P3_4=0x00;
P1=0xff;
P3_2=0x00;
P3_3=0x01;
while(P1_7)
{
P3_4=0x00;
P3_4=0x01;
}
P3_4=0x00;
}
Hello.hex
:0300000002092AC8
:0C092A00787FE4F6D8FD75810E0208AE5F
:1009190048656C6C6F2120486F7720522055203F25
:0109290000CD
:1008AE007F3C7E001209067F0C7E001209067F0631
:1008BE007E001209067F017E001209067F807E00EF
:0E08CE001209067BFF7A09791912080080FED4
:100906008E0D8F0E1208DC850E90C2B2C2B3D2B421
:03091600C2B42246
:060800008B088A09890A39
electronics for you
July 2004
:10080600E4F50BF50CAB08AA09A90A1208F1EF24C6
:10081600FFFFEE34FFFED3E50C9FE50B9E5042E54D
:100826000C6408450B70067FC0FE120906E50C64D1
:1008360010450B70067F80FE1209061208DCAB0815
:10084600AA09A90A850C82850B83120868F590D23D
:10085600B2C2B3D2B4C2B4050CE50C70A8050B80C5
:01086600A4ED
:01086700226E
:1008DC00C2B47590FFC2B2D2B3309706C2B4D2B4D0
:0508EC0080F7C2B422F8
:10086800BB010CE58229F582E5833AF583E0225045
:1008780006E92582F8E622BBFE06E92582F8E2228F
:0D088800E58229F582E5833AF583E49322A9
:1008F100E4FFFE120895600C0FEF70010E09E9701C
:05090100F20A80EF2264
:10089500BB010689828A83E0225002E722BBFE0261
:0908A500E32289828A83E4932294
:00000001FF
construction
July 2004
void openingmenu()
{
window(1,1,80,25);
clrscr();
paintscreen(9);
border();
textcolor(YELLOW);
textbackground(LIGHTBLUE);
gotoxy(25,3);
cprintf(==PC Based Logic Controller==);
gotoxy(30,4);
cprintf(Ver 1.0 (5 I/p,8 O/p));
textcolor(LIGHTGREEN);
gotoxy(25,6);
cprintf(== M A I N M E N U ==);
gotoxy(25,7);
cprintf(**********************);
textcolor(LIGHTRED);
gotoxy(25,9);
cprintf(F1 >- Run a Logic Program);
gotoxy(25,11);
cprintf(F2 >- View/Edit a Logic Program);
gotoxy(25,13);
cprintf(F3 >- View Input/Output Status);
gotoxy(25,15);
cprintf(F4 >- Force Outputs);
gotoxy(25,17);
cprintf(F5 >- Online Help);
gotoxy(25,19);
cprintf(F6 >- Exit);
USERCHOICE:
while(!kbhit())
{}
char userchoice=getch();
switch(userchoice)
{
case (char(59)):runprog();break;
case (char(60)):viewprog();break;
case (char(61)):viewstat();break;
case (char(62)):forceout();break;
case (char(63)):helpu();break;
case (char(64)):exiter();break;
default:goto USERCHOICE;
}
}
//paints the screen with specified colour
void paintscreen(int scrclr)
{
textbackground(scrclr);
for(int x=0;x<82;++x)
{
for(int y=0;y<26;++y)
{
gotoxy(x,y);
cprintf( );
}
}
}
//Draws borders
void border()
{
int i;
textcolor(LIGHTRED);
for(i=3;i<80;i++)//top line
{
gotoxy(i,1);
cprintf(\xcd);
}
gotoxy(79,1);//top left curve
cprintf(\xbb);
for(i=2;i<25;i++)//Right line
{
gotoxy(79,i);
cprintf(\xba);
}
gotoxy(79,25);
cprintf(\xbc); //bottom right curve
for(i=2;i<25;i++)//left line
{
gotoxy(2,i);
cprintf(\xba);
}
gotoxy(2,25);
cprintf(\xc8);//left bottom curve
for(i=3;i<79;i++)
{
gotoxy(i,25);
cprintf(\xcd);
}
gotoxy(2,1);
cprintf(\xc9);//left bottom curve
}
//Run a Logic program
void runprog()
{
char logicfile[15];
char comm[3],in;
int count;
char commn[3];
int par1,par2,par3;
int n,inpu;
int f;
fstream infile;
START:
window(1,1,80,25);
clrscr();
textcolor(YELLOW);
textbackground(LIGHTBLUE);
gotoxy(25,3);
cprintf(==LOGIC CONTROLLER==);
gotoxy(25,4);
cprintf(====================);
gotoxy(25,6);
cprintf(RUN A LOGIC PROGRAM FILE PAGE);
window(10,8,75,8);
textcolor(YELLOW);
clrscr();
textcolor(LIGHTCYAN);
cprintf( Enter the Logic File Name: (****.lgx) - );
scanf(%15s,&logicfile);
infile.open(logicfile,ios::in);
if(infile.fail())
{
window(10,8,70,9);
textcolor(LIGHTGREEN+BLINK);
clrscr();
cprintf(..Error Opening File or File Does not Exist../n/
rPress F3 to Exit,F4 to Renter);
ERROR:
while(!kbhit())
{}
char choice;
choice=getch();
switch(choice)
{
case(char (62)):goto START;break;
case(char(61)):openingmenu();break;
default:goto ERROR;
}
}
window(1,1,80,25);
clrscr();
paintscreen(4);
border();
textcolor(YELLOW);
textbackground(4);
gotoxy(5,3);
cprintf( Run Logic Controller File );
gotoxy(5,4);
cprintf(====================);
textcolor(LIGHTRED);
gotoxy(45,2);
cprintf(F1=StartESC- Exit);
gotoxy(10,6);
textcolor(LIGHTRED);
cprintf(Controller Inputs:);
construction
gotoxy(10,7);
cprintf(==================);
gotoxy(10,8);
cprintf(Input # 1(I1):);
gotoxy(10,9);
cprintf(Input # 2(I2):);
gotoxy(10,10);
cprintf(Input # 3(I3):);
gotoxy(10,11);
cprintf(Input # 4(I4):);
gotoxy(10,12);
cprintf(Input # 5(I5):);
gotoxy(10,13);
textcolor(CYAN);
cprintf(Controller Outputs);
gotoxy(10,14);
cprintf(==================);
gotoxy(10,15);
cprintf(Output # 1(O1):);
gotoxy(10,16);
cprintf(Output # 2(O2):);
gotoxy(10,17);
cprintf(Output # 3(O3):);
gotoxy(10,18);
cprintf(Output # 4(O4):);
gotoxy(10,19);
cprintf(Output # 5(O5):);
gotoxy(10,20);
cprintf(Output # 6(O6):);
gotoxy(10,21);
cprintf(Output # 7(O7):);
gotoxy(10,22);
cprintf(Output # 8(O8):);
textcolor(YELLOW);
gotoxy(40,3);
cprintf(Counter(UP) Preset ACC Done);
gotoxy(40,4);
cprintf(====================
=);
gotoxy(40,5);
cprintf(Counter #1);
gotoxy(40,6);
cprintf(Counter #2);
gotoxy(40,7);
cprintf(Counter #3);
gotoxy(40,8);
cprintf(Counter #4);
gotoxy(40,9);
cprintf(Counter #5);
textcolor(GREEN);
gotoxy(40,10);
cprintf(Counter(DOWN) Preset ACC Done);
gotoxy(40,11);
cprintf(====================
==);
gotoxy(40,12);
cprintf(Counter #1);
gotoxy(40,13);
cprintf(Counter #2);
gotoxy(40,14);
cprintf(Counter #3);
gotoxy(40,15);
cprintf(Counter #4);
gotoxy(40,16);
cprintf(Counter #5);
gotoxy(40,17);
textcolor(LIGHTRED);
cprintf(Timer Enable Preset ACC Done);
gotoxy(40,18);
cprintf(====================
==);
gotoxy(40,19);
cprintf(Timer #1);
gotoxy(40,20);
cprintf(Timer #2);
gotoxy(40,21);
cprintf(Timer #3);
gotoxy(40,22);
cprintf(Timer #4);
gotoxy(40,23);
cprintf(Timer #5);
gotoxy(40,24);
}
r.Reset();
displaystat();
if(kbhit())
{
if ((in = getch())==\x1B)break;
}
}
gotoxy(45,2);
cprintf(ESC =Stop and EXIT);
gotoxy(70,2);
cprintf(Prog=HALT);
while(!kbhit())
{}
choice=getch();
switch(choice)
{
case(char(59)):goto RUN;break;
case(char(27)):openingmenu();break;
default:openingmenu();
}
}
//View/Edit Program
void viewprog()
{
char lfile[15];
char* comm;
char tot[25];
comm=Edit ;
window(1,1,80,25);
clrscr();
paintscreen(4);
border();
textcolor(YELLOW);
textbackground(4);
gotoxy(20,4);
cprintf( View /Edit Controller File );
gotoxy(20,5);
cprintf(====================
==);
window(3,8,75,8);
textcolor(YELLOW);
clrscr();
textcolor(CYAN);
cprintf(Enter the Logic File Name (New or Existing):(????.
lgx) - );
scanf(%15s,&lfile);
strcat(tot,comm);
strcat(tot,lfile);
system(tot);
openingmenu();
}
//View I/P,O/P Status
void viewstat()
{
char in;
int inpu;
int inpuo;
window(1,1,80,25);
clrscr();
paintscreen(4);
border();
textcolor(YELLOW);
textbackground(4);
gotoxy(20,4);
cprintf( Logic Controller Input Output Status );
gotoxy(20,5);
cprintf(====================
==);
gotoxy(25,6);
cprintf(Press ESC TO Exit Status Screen);
gotoxy(20,8);
textcolor(LIGHTRED);
cprintf(Controller Inputs:);
gotoxy(20,9);
cprintf(==================);
gotoxy(20,11);
cprintf(Input # 1(I1):);
gotoxy(20,12);
cprintf(Input # 2(I2):);
gotoxy(20,13);
July 2004
construction
cprintf(Input # 3(I3):);
gotoxy(20,14);
cprintf(Input # 4(I4):);
gotoxy(20,15);
cprintf(Input # 5(I5):);
gotoxy(20,17);
textcolor(CYAN);
cprintf(Controller Outputs);
gotoxy(20,18);
cprintf(==================);
gotoxy(20,20);
cprintf(Output # 1(O1):);
gotoxy(20,21);
cprintf(Output # 2(O2):);
gotoxy(20,22);
cprintf(Output # 3(O3):);
gotoxy(20,23);
cprintf(Output # 4(O4):);
gotoxy(40,11);
cprintf(Output # 5(O5):);
gotoxy(40,12);
cprintf(Output # 6(O6):);
gotoxy(40,13);
cprintf(Output # 7(O7):);
gotoxy(40,14);
cprintf(Output # 8(O8):);
_setcursortype(_NOCURSOR);
for(;;)
{
//scan inputs
inpu=inp(0x379);
if ((inpu & 8)==0){gotoxy(35,11);textcolor(GREEN);
cprintf(ON );}
if ((inpu & 8)==8){gotoxy(35,11);textcolor(YELLOW);
cprintf(OFF);}
if ((inpu & 16)==0){gotoxy(35,12);textcolor(GREEN);
cprintf(ON );}
if ((inpu & 16)==16){gotoxy(35,12);textcolor(YELLOW);
cprintf(OFF);}
if ((inpu & 32)==0){gotoxy(35,13);textcolor(GREEN);
cprintf(ON );}
if ((inpu & 32)==32){gotoxy(35,13);textcolor(YELLOW);
cprintf(OFF);}
if ((inpu & 64)==0){gotoxy(35,14);textcolor(GREEN);
cprintf(ON );}
if ((inpu & 64)==64){gotoxy(35,14);textcolor(YELLOW);
cprintf(OFF);}
if ((inpu & 128)==128){gotoxy(35,15);textcolor(GREEN);
cprintf(ON );}
if ((inpu & 128)==0){gotoxy(35,15);textcolor(YELLOW);
cprintf(OFF);}
//scan outputs
inpuo=inp(0x378);
if ((inpuo & 1)==1){gotoxy(36,20);textcolor(GREEN);
cprintf(ON );}
if ((inpuo & 1)==0){gotoxy(36,20);textcolor(YELLOW);
cprintf(OFF);}
if ((inpuo & 2)==2){gotoxy(36,21);textcolor(GREEN);
cprintf(ON );}
if ((inpuo & 2)==0){gotoxy(36,21);textcolor(YELLOW);
cprintf(OFF);}
if ((inpuo & 4)==4){gotoxy(36,22);textcolor(GREEN);
cprintf(ON );}
if ((inpuo & 4)==0){gotoxy(36,22);textcolor(YELLOW);
cprintf(OFF);}
if ((inpuo & 8)==8){gotoxy(36,23);textcolor(GREEN);
cprintf(ON );}
if ((inpuo & 8)==0){gotoxy(36,23);textcolor(YELLOW);
cprintf(OFF);}
if ((inpuo & 16)==16){gotoxy(56,11);textcolor(GREEN);
cprintf(ON );}
if ((inpuo & 16)==0){gotoxy(56,11);textcolor(YELLOW);
cprintf(OFF);}
if ((inpuo & 32)==32){gotoxy(56,12);textcolor(GREEN);
cprintf(ON );}
if ((inpuo & 32)==0){gotoxy(56,12);textcolor(YELLOW);
cprintf(OFF);}
if ((inpuo & 64)==64){gotoxy(56,13);textcolor(GREEN);
cprintf(ON );}
if ((inpuo & 64)==0){gotoxy(56,13);textcolor(YELLOW);
cprintf(OFF);}
if ((inpuo & 128)==128){gotoxy(56,14);textcolor(GREEN);
electronics for you
July 2004
cprintf(ON );}
if ((inpuo & 128)==0){gotoxy(56,14);textcolor(YELLOW);
cprintf(OFF);}
if(kbhit())
{
if ((in = getch())==\x1B)break;
}
}
openingmenu();
}
//Force Outputs
void forceout()
{
char cho;
char in;
window(1,1,80,25);
clrscr();
paintscreen(4);
border();
textcolor(YELLOW);
textbackground(4);
gotoxy(25,3);
cprintf( Force Controller Outputs );
gotoxy(25,4);
cprintf(====================
==);
gotoxy(10,8);
cprintf(Output # 1- F1);
gotoxy(10,9);
cprintf(Output # 2- F2);
gotoxy(10,10);
cprintf(Output # 3- F3);
gotoxy(10,11);
cprintf(Output # 4- F4);
gotoxy(10,12);
cprintf(Output # 5- F5);
gotoxy(10,13);
cprintf(Output # 6- F6);
gotoxy(10,14);
cprintf(Output # 7- F7);
gotoxy(10,15);
cprintf(Output # 8- F8);
gotoxy(30,7);
cprintf(Output Status>>);
gotoxy(30,18);
cprintf(ESC=Exit to Main..);
_setcursortype(_NOCURSOR);
for(;;)
{
while(!kbhit())
{
textcolor(LIGHTRED);
outp(0x378,0);
gotoxy(35,8);
cprintf(OFF);
gotoxy(35,9);
cprintf(OFF);
gotoxy(35,10);
cprintf(OFF);
gotoxy(35,11);
cprintf(OFF);
gotoxy(35,12);
cprintf(OFF);
gotoxy(35,13);
cprintf(OFF);
gotoxy(35,14);
cprintf(OFF);
gotoxy(35,15);
cprintf(OFF);
}
cho=getch();
textcolor(GREEN);
if(cho==(char(59))){outp(0x378,1);gotoxy(35,8);cp
rintf( ON);};
if(cho==(char(60))){outp(0x378,2);gotoxy(35,9);cp
rintf( ON);};
if(cho==(char(61))){outp(0x378,4);gotoxy(35,10);cp
rintf( ON);};
if(cho==(char(62))){outp(0x378,8);gotoxy(35,11);cp
rintf( ON);};
if(cho==(char(63))){outp(0x378,16);gotoxy(35,12);c
printf( ON);};
if(cho==(char(64))){outp(0x378,32);gotoxy(35,13);c
printf( ON);};
if(cho==(char(65))){outp(0x378,64);gotoxy(35,14);c
printf( ON);};
if(cho==(char(66))){outp(0x378,128);gotoxy(35,15);
cprintf( ON);};
if(cho==(char(27))){openingmenu();};
delay(100);
}
}
//Help Utility
void helpu()
{
window(1,1,80,25);
clrscr();
paintscreen(9);
border();
textbackground(LIGHTBLUE);
textcolor(YELLOW);
gotoxy(25,5);
cprintf(==M A I N H E L P M E N U==);
gotoxy(25,6);
cprintf(++++++++++++++++++++
+);
textcolor(LIGHTRED);
gotoxy(25,8);
cprintf(F1 >- Help on Running a Logic Program);
gotoxy(25,10);
cprintf(F2 >- Help on Viewing/Editing a Logic Program);
gotoxy(25,12);
cprintf(F3 >- Help on Viewing Input/Output Status);
gotoxy(25,14);
cprintf(F4 >- Help on Force Outputs);
gotoxy(25,16);
cprintf(F5 >- About This Program);
gotoxy(25,18);
cprintf(ESC >- Return to Main);
HELPCHOICE:
while(!kbhit())
{}
char userchoiceh=getch();
switch(userchoiceh)
{
case (char(59)):{textcolor(LIGHTRED);displayhelp(
HELPS.PG1);}break;
case (char(60)):{textcolor(LIGHTGREEN);displayhelp
(HELPS.PG2);}break;
case (char(61)):{textcolor(LIGHTCYAN);displayhelp
(HELPS.PG3);}break;
case (char(62)):{textcolor(YELLOW);displayhelp (HELPS.
PG4);}break;
case (char(63)):{textcolor(LIGHTMAGENTA);displayhelp(
HELPS.PG5);}break;
case (char(27)):openingmenu();break;
default:goto HELPCHOICE;
}
getch();
}
//Exit To DOS
void exiter()
{
window(1,1,80,25);
clrscr();
paintscreen(9);
border();
textcolor(YELLOW+BLINK);
textbackground(9);
gotoxy(25,10);
cprintf(Exiting to DOS.....);
delay(2000);
textcolor(YELLOW);
clrscr();
exit(1);
}
//Logic Controller Commands
//Series Contacts
void ser(int inputno)
{
construction
int addr;
switch(inputno)
{
case 1:addr=I1;break;
case 2:addr=I2;break;
case 3:addr=I3;break;
case 4:addr=I4;break;
case 5:addr=I5;break;
case 6:addr=NI1;break;
case 7:addr=NI2;break;
case 8:addr=NI3;break;
case 9:addr=NI4;break;
case 10:addr=NI5;break;
case 11:addr=O1;break;
case 12:addr=O2;break;
case 13:addr=O3;break;
case 14:addr=O4;break;
case 15:addr=O5;break;
case 16:addr=O6;break;
case 17:addr=O7;break;
case 18:addr=O8;break;
case 19:addr=NO1;break;
case 20:addr=NO2;break;
case 21:addr=NO3;break;
case 22:addr=NO4;break;
case 23:addr=NO5;break;
case 24:addr=NO6;break;
case 25:addr=NO7;break;
case 26:addr=NO8;break;
case 27:addr=CDN1;break;
case 28:addr=CDN2;break;
case 29:addr=CDN3;break;
case 30:addr=CDN4;break;
case 31:addr=CDN5;break;
case 32:addr=~CDN1;break;
case 33:addr=~CDN2;break;
case 34:addr=~CDN3;break;
case 35:addr=~CDN4;break;
case 36:addr=~CDN5;break;
case 37:addr=CODN1;break;
case 38:addr=CODN2;break;
case 39:addr=CODN3;break;
case 40:addr=CODN4;break;
case 41:addr=CODN5;break;
case 42:addr=~CODN1;break;
case 43:addr=~CODN2;break;
case 44:addr=~CODN3;break;
case 45:addr=~CODN4;break;
case 46:addr=~CODN5;break;
case 47:addr=TEN1;break;
case 48:addr=TEN2;break;
case 49:addr=TEN3;break;
case 50:addr=TEN4;break;
case 51:addr=TEN5;break;
case 52:addr=~TEN1;break;
case 53:addr=~TEN2;break;
case 54:addr=~TEN3;break;
case 55:addr=~TEN4;break;
case 56:addr=~TEN5;break;
case 57:addr=TDN1;break;
case 58:addr=TDN2;break;
case 59:addr=TDN3;break;
case 60:addr=TDN4;break;
case 61:addr=TDN5;break;
case 62:addr=~TDN1;break;
case 63:addr=~TDN2;break;
case 64:addr=~TDN3;break;
case 65:addr=~TDN4;break;
case 66:addr=~TDN5;break;
case 67:addr=RTDN;break;
case 68:addr=~RTDN;break;
}
res=res&addr;
}
//Parallel Contacts
void par(int inputno)
{
int addr;
switch(inputno)
{
case 1:addr=I1;break;
case 2:addr=I2;break;
case 3:addr=I3;break;
case 4:addr=I4;break;
case 5:addr=I5;break;
case 6:addr=NI1;break;
case 7:addr=NI2;break;
case 8:addr=NI3;break;
case 9:addr=NI4;break;
case 10:addr=NI5;break;
case 11:addr=O1;break;
case 12:addr=O2;break;
case 13:addr=O3;break;
case 14:addr=O4;break;
case 15:addr=O5;break;
case 16:addr=O6;break;
case 17:addr=O7;break;
case 18:addr=O8;break;
case 19:addr=NO1;break;
case 20:addr=NO2;break;
case 21:addr=NO3;break;
case 22:addr=NO4;break;
case 23:addr=NO5;break;
case 24:addr=NO6;break;
case 25:addr=NO7;break;
case 26:addr=NO8;break;
case 27:addr=CDN1;break;
case 28:addr=CDN2;break;
case 29:addr=CDN3;break;
case 30:addr=CDN4;break;
case 31:addr=CDN5;break;
case 32:addr=~CDN1;break;
case 33:addr=~CDN2;break;
case 34:addr=~CDN3;break;
case 35:addr=~CDN4;break;
case 36:addr=~CDN5;break;
case 37:addr=CODN1;break;
case 38:addr=CODN2;break;
case 39:addr=CODN3;break;
case 40:addr=CODN4;break;
case 41:addr=CODN5;break;
case 42:addr=~CODN1;break;
case 43:addr=~CODN2;break;
case 44:addr=~CODN3;break;
case 45:addr=~CODN4;break;
case 46:addr=~CODN5;break;
case 47:addr=TEN1;break;
case 48:addr=TEN2;break;
case 49:addr=TEN3;break;
case 50:addr=TEN4;break;
case 51:addr=TEN5;break;
case 52:addr=~TEN1;break;
case 53:addr=~TEN2;break;
case 54:addr=~TEN3;break;
case 55:addr=~TEN4;break;
case 56:addr=~TEN5;break;
case 57:addr=TDN1;break;
case 58:addr=TDN2;break;
case 59:addr=TDN3;break;
case 60:addr=TDN4;break;
case 61:addr=TDN5;break;
case 62:addr=~TDN1;break;
case 63:addr=~TDN2;break;
case 64:addr=~TDN3;break;
case 65:addr=~TDN4;break;
case 66:addr=~TDN5;break;
case 67:addr=RTDN;break;
case 68:addr=~RTDN;break;
}
res=res|addr;
}
// Outputs
void ope(int outputno)
{
if(res==1)
{
switch(outputno)
{
case 1:O1=1;break;
case 2:O2=1;break;
case 3:O3=1;break;
case 4:O4=1;break;
case 5:O5=1;break;
case 6:O6=1;break;
case 7:O7=1;break;
case 8:O8=1;break;
}
}
if(res==0)
{
switch(outputno)
{
case 1:O1=0;break;
case 2:O2=0;break;
case 3:O3=0;break;
case 4:O4=0;break;
case 5:O5=0;break;
case 6:O6=0;break;
case 7:O7=0;break;
case 8:O8=0;break;
}
}
res=1;
}
//latched output
void opl(int outputno)
{
if(res==1)
{
switch(outputno)
{
case 1:O1=1;break;
case 2:O2=1;break;
case 3:O3=1;break;
case 4:O4=1;break;
case 5:O5=1;break;
case 6:O6=1;break;
case 7:O7=1;break;
case 8:O8=1;break;
}
}
res=1;
}
//Output Unlatch
void opu(int outputno)
{
if(res==1)
{
switch(outputno)
{
case 1:O1=0;break;
case 2:O2=0;break;
case 3:O3=0;break;
case 4:O4=0;break;
case 5:O5=0;break;
case 6:O6=0;break;
case 7:O7=0;break;
case 8:O8=0;break;
}
}
res=1;
}
//Timer Function
int tmr(int tno,int timeset)
{
switch(tno)
{
case(1):T1=timeset;break;
case(2):T2=timeset;break;
case(3):T3=timeset;break;
case(4):T4=timeset;break;
case(5):T5=timeset;break;
}
if(res==1)
{
switch(tno)
{
case(1):if(tmrscan1==0){first1=time(NULL);tmrscan1
=1;};break;
case(2):if(tmrscan2==0){first2=time(NULL);tmrscan2
=1;};break;
case(3):if(tmrscan3==0){first3=time(NULL);tmrscan3
=1;};break;
case(4):if(tmrscan4==0){first4=time(NULL);tmrscan4
=1;};break;
case(5):if(tmrscan1==0){first1=time(NULL);tmrscan1
July 2004
construction
=1;};break;
}
switch(tno)
{
case(1):{second1=time(NULL);};break;
case(2):{second2=time(NULL);};break;
case(3):{second3=time(NULL);};break;
case(4):{second4=time(NULL);};break;
case(5):{second5=time(NULL);};break;
}
switch(tno)
{
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;
}
switch(tno)
{
case(1):if(difftime(second1,first1)==T1){TDN1=1;};
break;
case(2):if(difftime(second2,first2)==T2){TDN2=1;};
break;
case(3):if(difftime(second3,first3)==T3){TDN3=1;};
break;
case(4):if(difftime(second4,first4)==T4){TDN4=1;};
break;
case(5):if(difftime(second5,first5)==T5){TDN5=1;};
break;
}
}
if(res==0)
{
switch(tno)
{
case(1):{TEN1=0;TACC1=0;tmrscan1=0;TDN1=
0;};break;
case(2):{TEN2=0;TACC2=0;tmrscan2=0;TDN2=
0;};break;
case(3):{TEN3=0;TACC3=0;tmrscan3=0;TDN3=
0;};break;
case(4):{TEN4=0;TACC4=0;tmrscan4=0;TDN4=
0;};break;
case(5):{TEN5=0;TACC5=0;tmrscan5=0;TDN5=
0;};break;
}
}
}
//Up Counter
int ctu(int cno,int countset)
{
switch(cno)
{
case(1):C1=countset;break;
case(2):C2=countset;break;
case(3):C3=countset;break;
case(4):C4=countset;break;
case(5):C5=countset;break;
}
if(res==1&&risingedge==0)
{
switch(cno)
{
case(1):if(CDN1!=1){CACC1=CACC1+1;};break;
case(2):if(CDN2!=1){CACC2=CACC2+1;};break;
case(3):if(CDN3!=1){CACC3=CACC3+1;};break;
case(4):if(CDN4!=1){CACC4=CACC4+1;};break;
case(5):if(CDN1!=1){CACC5=CACC5+1;};break;
}
risingedge=1;
electronics for you
July 2004
}
if(res==0&&risingedge==1)risingedge=0;
switch(cno)
{
case(1):if(CACC1==C1)CDN1=1;break;
case(2):if(CACC2==C2)CDN2=1;break;
case(3):if(CACC3==C3)CDN3=1;break;
case(4):if(CACC4==C4)CDN4=1;break;
case(5):if(CACC5==C5)CDN5=1;;break;
}
if(countset==0&&res==1)
{
switch(cno)
{
case(1):{CACC1=0;CDN1=0;};break;
case(2):{CACC2=0;CDN2=0;};break;
case(3):{CACC3=0;CDN3=0;};break;
case(4):{CACC4=0;CDN4=0;};break;
case(5):{CACC5=0;CDN5=0;};break;
}
}
}
//Down Counter
int ctd(int cno,int countset)
{
switch(cno)
{
case(1):{CO1=countset;};break;
case(2):{CO2=countset;};break;
case(3):{CO3=countset;};break;
case(4):{CO4=countset;};break;
case(5):{CO5=countset;};break;
}
if(res==1&&risingedge==0)
{
switch(cno)
{
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;
}
risingedge=1;
}
if(res==0&&risingedge==1)risingedge=0;
switch(cno)
{
case(1):if(CO1==cd1)CODN1=1;break;
case(2):if(CO2==cd2)CODN2=1;break;
case(3):if(CO3==cd3)CODN3=1;break;
case(4):if(CO4==cd4)CODN4=1;break;
case(5):if(CO5==cd5)CODN5=1;;break;
}
if(countset==0&&res==1)
{
switch(cno)
{
case(1):{COACC1=0;CODN1=0;};break;
case(2):{COACC2=0;CODN2=0;};break;
case(3):{COACC3=0;CODN3=0;};break;
case(4):{COACC4=0;CODN4=0;};break;
case(5):{COACC5=0;CODN5=0;};break;
}
}
}
//Real Time Output
int rto(int hourr,int minn)
{
int hr,mn;
if(res==1)
{
gettime(&t);
construction
gotoxy(55,6);
cprintf(%3d,C2);
gotoxy(55,7);
cprintf(%3d,C3);
gotoxy(55,8);
cprintf(%3d,C4);
gotoxy(55,9);
cprintf(%3d,C5);
gotoxy(62,5);
cprintf(%3d,CACC1);
gotoxy(62,6);
cprintf(%3d,CACC2);
gotoxy(62,7);
cprintf(%3d,CACC3);
gotoxy(62,8);
cprintf(%3d,CACC4);
gotoxy(62,9);
cprintf(%3d,CACC5);
gotoxy(68,5);
cprintf(%d,CDN1);
gotoxy(68,6);
cprintf(%d,CDN2);
gotoxy(68,7);
cprintf(%d,CDN3);
gotoxy(68,8);
cprintf(%d,CDN4);
gotoxy(68,9);
cprintf(%d,CDN5);
gotoxy(55,12);
cprintf(%3d,CO1);
gotoxy(55,13);
cprintf(%3d,CO2);
gotoxy(55,14);
cprintf(%3d,CO3);
gotoxy(55,15);
cprintf(%3d,CO4);
gotoxy(55,16);
cprintf(%3d,CO5);
gotoxy(62,12);
cprintf(%3d,COACC1);
gotoxy(62,13);
cprintf(%3d,COACC2);
gotoxy(62,14);
cprintf(%3d,COACC3);
gotoxy(62,15);
cprintf(%3d,COACC4);
gotoxy(62,16);
cprintf(%3d,COACC5);
gotoxy(68,12);
cprintf(%d,CODN1);
gotoxy(68,13);
cprintf(%d,CODN2);
gotoxy(68,14);
cprintf(%d,CODN3);
gotoxy(68,15);
cprintf(%d,CODN4);
gotoxy(68,16);
cprintf(%d,CODN5);
gotoxy(49,19);
cprintf(%d,TEN1);
gotoxy(49,20);
cprintf(%d,TEN2);
gotoxy(49,21);
cprintf(%d,TEN3);
gotoxy(49,22);
cprintf(%d,TEN4);
gotoxy(49,23);
cprintf(%d,TEN5);
gotoxy(57,19);
cprintf(%3d,T1);
gotoxy(57,20);
cprintf(%3d,T2);
gotoxy(57,21);
cprintf(%3d,T3);
gotoxy(57,22);
cprintf(%3d,T4);
gotoxy(57,23);
cprintf(%3d,T5);
gotoxy(64,19);
cprintf(%3d,TACC1);
gotoxy(64,20);
cprintf(%3d,TACC2);
gotoxy(64,21);
cprintf(%3d,TACC3);
gotoxy(64,22);
cprintf(%3d,TACC4);
gotoxy(64,23);
cprintf(%3d,TACC5);
gotoxy(70,19);
cprintf(%d,TDN1);
gotoxy(70,20);
cprintf(%d,TDN2);
gotoxy(70,21);
cprintf(%d,TDN3);
gotoxy(70,22);
cprintf(%d,TDN4);
gotoxy(70,23);
cprintf(%d,TDN5);
gotoxy(56,24);
cprintf(%d,RTDN);
gotoxy(27,23);
cprintf(%.2f,te*1000);
}
//Help File Display
void displayhelp(char helpfilename[10])
{
fstream infile;
textbackground(BLACK);
window(1,1,80,25);
const int max=80;
char buffer[max];
clrscr();
infile.open(helpfilename,ios::in);
if(infile.fail())
{
window(10,8,70,9);
textcolor(YELLOW+BLINK);
clrscr();
cprintf(.....Help not Available or Error Opening File ...\n\
r..Press any Key to Return to Main.....);
getch();
openingmenu();
}
while(!infile.eof())
{
infile.getline(buffer,max);
cout<<buffer;
cout<<endl;
}
infile.close();
getch();
helpu();
} q
July 2004