07-25-2011 05:47 PM
I am working on a project for school to count the number of poeple that enter and exit our library. I have gotten the circuit to work. I have gotten the code to run. When I put the two together in multisim and build i get error can't include file reg51.h no such file or directory. I do have the file and directory in the project folder though. please help 🙂
07-26-2011 09:57 AM
Hi ssotek,
Is it possible for you to upload the files. I will take a look to see what is going on.
07-27-2011 11:35 PM
Here is the code for both the reg51 file and the program file
Reg51.h files
#ifndef REG51_H
#define REG51_H
/* BYTE Register */
sfr at 0x80 P0 ;
sfr at 0x90 P1 ;
sfr at 0xA0 P2 ;
sfr at 0xB0 P3 ;
sfr at 0xD0 PSW ;
sfr at 0xE0 ACC ;
sfr at 0xF0 B ;
sfr at 0x81 SP ;
sfr at 0x82 DPL ;
sfr at 0x83 DPH ;
sfr at 0x87 PCON ;
sfr at 0x88 TCON ;
sfr at 0x89 TMOD ;
sfr at 0x8A TL0 ;
sfr at 0x8B TL1 ;
sfr at 0x8C TH0 ;
sfr at 0x8D TH1 ;
sfr at 0x8E AUXR ;
sfr at 0xA8 IE ;
sfr at 0xB8 IP ;
sfr at 0x98 SCON ;
sfr at 0x99 SBUF ;
/* BIT Register */
/* PSW */
sbit at 0xD7 CY ;
sbit at 0xD6 AC ;
sbit at 0xD5 F0 ;
sbit at 0xD4 RS1 ;
sbit at 0xD3 RS0 ;
sbit at 0xD2 OV ;
sbit at 0xD0 P ;
/* TCON */
sbit at 0x8F TF1 ;
sbit at 0x8E TR1 ;
sbit at 0x8D TF0 ;
sbit at 0x8C TR0 ;
sbit at 0x8B IE1 ;
sbit at 0x8A IT1 ;
sbit at 0x89 IE0 ;
sbit at 0x88 IT0 ;
/* IE */
sbit at 0xAF EA ;
sbit at 0xAC ES ;
sbit at 0xAB ET1 ;
sbit at 0xAA EX1 ;
sbit at 0xA9 ET0 ;
sbit at 0xA8 EX0 ;
/* IP */
sbit at 0xBC PS ;
sbit at 0xBB PT1 ;
sbit at 0xBA PX1 ;
sbit at 0xB9 PT0 ;
sbit at 0xB8 PX0 ;
/* P3 */
sbit at 0xB7 RD ;
sbit at 0xB6 WR ;
sbit at 0xB5 T1 ;
sbit at 0xB4 T0 ;
sbit at 0xB3 INT1 ;
sbit at 0xB2 INT0 ;
sbit at 0xB1 TXD ;
sbit at 0xB0 RXD ;
/* P1 */
sbit at 0x90 P1_0 ;
sbit at 0x91 P1_1 ;
sbit at 0x92 P1_2 ;
sbit at 0x93 P1_3 ;
sbit at 0x94 P1_4 ;
sbit at 0x95 P1_5 ;
sbit at 0x96 P1_6 ;
sbit at 0x97 P1_7 ;
/* SCON */
sbit at 0x9F SM0 ;
sbit at 0x9E SM1 ;
sbit at 0x9D SM2 ;
sbit at 0x9C REN ;
sbit at 0x9B TB8 ;
sbit at 0x9A RB8 ;
sbit at 0x99 TI ;
sbit at 0x98 RI ;
/* TMOD bits */
#define GATE1 (1<<7)
#define C_T1 (1<<6)
#define M1_1 (1<<5)
#define M0_1 (1<<4)
#define GATE0 (1<<3)
#define C_T0 (1<<2)
#define M1_0 (1<<1)
#define M0_0 (1<<0)
/* T2CON */
sfr at 0xC8 T2CON ;
/* T2CON bits */
sbit at 0xC8 T2CON_0 ;
sbit at 0xC9 T2CON_1 ;
sbit at 0xCA T2CON_2 ;
sbit at 0xCB T2CON_3 ;
sbit at 0xCC T2CON_4 ;
sbit at 0xCD T2CON_5 ;
sbit at 0xCE T2CON_6 ;
sbit at 0xCF T2CON_7 ;
/* RCAP2 L & H */
sfr at 0xCB RCAP2H;
sfr at 0xCA RCAP2L;
#endif
here is the program file
#include<reg51.h>
#define msec 1
unsigned int num=0;
sbit dig_ctrl_4=P1^3; //DECLARE THE CONTROL OR ENABLE PINS OF SEVEN SEGMENTS
sbit dig_ctrl_3=P1^2;
sbit dig_ctrl_2=P1^1;
sbit dig_ctrl_1=P1^0;
unsigned int digi_val[10]={0x40,0xF9,0x24,0x30,0x19,0x12,0x02,0xF8,0x00,0x10};
unsigned int dig_1,dig_2,dig_3,dig_4,test=0;
unsigned char dig_disp=0;
sbit up=P3^5; //up pin to make counter count up
sbit down=P3^6; //down pin to make counter count down
void init() //to initialize the output pins and timer 0
{
up=down=1;
dig_ctrl_4=0;
dig_ctrl_3=0;
dig_ctrl_2=0;
dig_ctrl_1=0;
TMOD=0x01;
TL0=0xf6;
TH0=0xFf;
IE=0x82;
TR0=1;
}
void delay() //to provide delay
{
TMOD=0x01;
TL0=0x36;
TH0=0xF6;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}
void display() interrupt 1 //function to display the digits on 7 seg LED's
{
TL0=0x36;
TH0=0xf6;
P2=0xFF;
dig_ctrl_1=dig_ctrl_3=dig_ctrl_2=dig_ctrl_4=0;
dig_disp++;
dig_disp=dig_disp%4;
switch(dig_disp)
{
case 0:
P2=digi_val[dig_1];
dig_ctrl_1=1;
break;
case 1:
P2=digi_val[dig_2];
dig_ctrl_2=1;
break;
case 2:
P2=digi_val[dig_3];
dig_ctrl_3=1;
break;
case 3:
P2=digi_val[dig_4];
dig_ctrl_4=1;
break;
}
}
void main()
{
init();
while(1);
{
if(up==0&&down==1) //check if up pin is pressed
{
test++;
num=test;
dig_4=num%10;
num=num/10;
dig_3=num%10;
num=num/10;
dig_2=num%10;
dig_1=num/10;
if(test==9999)
test=0;
}
if(up==1&&down==0) //check down pin is pressed
{
test--;
num=test/30;
dig_4=num%10;
num=num/10;
dig_3=num%10;
num=num/10;
dig_2=num%10;
dig_1=num/10; if(test==0)
test=9999;
}
}
}
your help if greatly appreciated 🙂
07-28-2011 08:20 AM
Hi ssotek,
I will need to take a look at the actual project file that you are building in Multisim which includes your circuit because you are having a problem with compiling it there. The code looks good but the issue is with the compilation so the Multisim file is necessary for troubleshooting.
07-29-2011 04:06 PM
Here is the attached project
08-02-2011 09:12 AM
Hi ssotek,
The include statement should be #include "reg51.h" as this is a user defined header file.
08-05-2011 06:45 PM
Thank you for the help 🙂 now i have more errors that I do not know about. I think I am just gonna rewrite it from scratch
12-24-2014 11:43 PM
12-24-2014 11:49 PM