Discussion in "Project Help" started by    kira113    Aug 19, 2017.
Sat Aug 19 2017, 08:52 AM
#1
hello everyone
i write a simple program using c language for read analog value from adc0804 then convert that value to three decimal number and then display them on 3 seven_seg but when i compile the program using keil ide i got some error ( like 'multiple public definition ')
can anyone help me with it .
#include <REGX51.H>
sbit cs   = P3^7 ;
sbit WRIT	= P3^5 ;
sbit READ	= P3^6 ;
sbit inter= P3^4 ;
#define adc_port  P1 
#define seg_port  P0 

char ones,tens,hunds,digital_value,rfd;
int table[16]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10,0x08,0x03,0x46,0x21,0x06,0x0e};
void conv();
void read_adc();
void delay_us(int);
void delay_ms(int);
void delay_sec( char);
void div23dig(char);
void disp ( char , char, char );
void main(){
							
							adc_port = 0xff	;		//init adc_Port as input
									P0 = 0X0			;//init p0 as output
									P3= 0x10		;	//init p3.4 as input
								while(1){
									
									
										conv();
										read_adc();
										div23dig(digital_value);
									  disp(ones,tens,hunds);
										delay_sec(1);
									 
										
												}
            }

void conv()
	{
		cs=0;
		WRIT=0;
		WRIT=1;
		cs=1;
		while(inter);
	}

void read_adc()
	{
			cs=0;
			READ=0;
			digital_value=adc_port;
			READ=1;
			cs=1;
  }

void delay_us( int us_count)
 {
    while(us_count!=0)
      {
         us_count--;
       }
   }
void delay_ms( int ms_count)
 {
        while(ms_count!=0)
         {
            delay_us(112);   /*delay_us is called to generate 1ms delay*/
             ms_count--;
            }
   }
void delay_sec( char sec_count)
 {

     while(sec_count!=0)
      {
         delay_ms(1000);    /*delay_ms is called to generate 1sec delay*/
         sec_count--;
        }
 }
void div23dig(char x )
 { 
		hunds= digital_value/100 ;
		rfd = digital_value%100 ;
	  tens = rfd/10;
		ones = rfd%10;
	
 }
void disp ( char x , char y ,char z )
 {  char i; 
		i = table[ones] ;
	  seg_port = i ;
	  P2=P2|1;
	  delay_ms(16);
		P2=P2&254;
	  i=table[tens];
	 seg_port=i;
	  P2=P2|2;
		delay_ms(16);
	   P2=P2&253;
		i= table[hunds];
	  seg_port=i;
	  P2=P2|4;
		delay_ms(16);
	  P2=P2&251;
 
 }



[ Edited Wed Aug 23 2017, 01:26 PM ]
Sun Aug 20 2017, 08:31 PM
#2

"when i compile the program using keil ide i got some error
( like 'multiple public definition ')"

When asking for help, giving the exact error message is important.
It is better to zip and post your full code,
as copying off the web page is not 100% successful.

I tried your code and got unused variables warnings for call
"void disp ( char x , char y ,char z )"
x,y and z are not used in the procedure.

I notice you declared it as
"void disp ( char , char, char );" without naming the variables.
That may be legal, but makes it harder to spot errors, as in the case above.


[ Edited Sun Aug 20 2017, 08:35 PM ]
Wed Aug 23 2017, 01:30 PM
#3
It will be easier to help if you can post the complete error message with line number. So we know which line is generating the error.
By the way, it's better to define "table" as const since you're not going to change it but just use it as a reference for digits.
 kira113 like this.
Sun Oct 08 2017, 08:33 PM
#4
actually i solve this problem , and it was just test for my project which is"power meter"
so i could measure the ac voltage and display it on 3 7-seg , and then moved to measure current using CT 1000:1 and it worked very good with some error , but when i tried to merge current and voltage together i used tow adc0804( i could to use adc0808 but the time was very short to do that ) and connect it with same PORT on micro , i will attach the schematic and the code to understand what i'm trying to say so maybe you can help me .
Sun Oct 08 2017, 08:40 PM
#5
these are my schematic and c source file , and i hope to help me because i tried to solve it for two weeks and there is no progress at all
Sun Oct 08 2017, 08:42 PM
#6
https://drive.google.com/open?id=0B_IGcFftMx3fYV9VTmw5dkp2Q2s


[ Edited Sun Oct 08 2017, 08:45 PM ]
Thu Oct 12 2017, 01:04 AM
#7
I don't think the 0804 works as it should in Proteus.
I ended up greatly simplifying your design to get it working.
The good news is that you have a working start point.
Use the virtual serial port in Proteus to print messages to help
with debugging.

Attachment

Get Social

Information

Powered by e107 Forum System

Conversation

ExperimenterUK
Sat Sep 29 2018, 06:28 PM
Please post questions in the forum.
Sat Sep 29 2018, 11:26 AM
Ashfaq Ch
hi i have some AT89C51RC microcontrollers already programed. some one help us to how to download from AT89C51RC and after study and edit all corractions reload to AT89C51RC controller
shshistiem
Wed Sep 12 2018, 10:58 PM
hii!! some1 please let me know how i ll get rfid code to 8051 by WEIGAND mode
DrNossberg
Tue Sep 11 2018, 08:09 PM
is there anyone here?
Mon Aug 27 2018, 07:30 AM
bun
Hello everyone´╝ü
Sat Jul 21 2018, 06:21 AM
Dibakar Bhanja Chowdhury
By using a 555 timer how can I expand the range of the mobile phone jammer? Please reply me asap
Sun May 20 2018, 10:01 AM
justinb
how to write and execute a program that read the keypad button and display the number on 7 segment on intel8051 at89s52 in assembly language?
Thu May 17 2018, 06:36 AM
HAMZA TAJ
sir iwant to ask about controller of three phase supply by using back to back thyristor instead of triac....will u give me some guideline?
Sat Apr 28 2018, 12:54 PM
ashutosh jain
IR Remote Switch using TV remote (RC5 Protocol) is not working properly. opp1 & opp2 is in problem.plz help
ExperimenterUK
Fri Apr 27 2018, 08:09 PM
@kaiserslautern Post in forum

Downloads

Comments

PCBindex
Fri Sep 14 2018, 02:45 AM
sirkit
Thu Sep 13 2018, 04:46 AM
shshistiem
Wed Sep 12 2018, 10:36 PM
DrNossberg
Tue Sep 11 2018, 03:25 PM
ranjanvh
Thu Sep 06 2018, 02:28 PM
rbbhamre
Tue Sep 04 2018, 06:15 PM
Tressie
Sun Sep 02 2018, 02:20 PM
Sudhansudeep
Fri Aug 31 2018, 08:26 AM

Online

Guests: 44, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38006
Newest member: PCBindex
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Sep 13 2018, 08:39 PM
First of all, by reading your reply, I abandoned m...
DrNossberg Avatar
Posted By DrNossberg
Thu Sep 13 2018, 03:49 PM
Hi, thanks you for your reply ^^ First of all, by ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed Sep 12 2018, 12:12 AM
HiThere are several issues here.The original 8051 ...
DrNossberg Avatar
Posted By DrNossberg
Tue Sep 11 2018, 08:08 PM
Hello everybody!First of all let me explain some s...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Sep 07 2018, 05:08 AM
The compiler thinks the micro doesn't have enough...
Sudhansudeep Avatar
Posted By Sudhansudeep
Fri Sep 07 2018, 02:59 AM
this is the build output message
Sudhansudeep Avatar
Posted By Sudhansudeep
Fri Sep 07 2018, 01:38 AM
Change the mobile number as [number removed] in t...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Sep 06 2018, 08:56 PM
I don't know what the problem is, I get no errors....
Sudhansudeep Avatar
Posted By Sudhansudeep
Thu Sep 06 2018, 01:12 PM
the code is Attachment ...
Sudhansudeep Avatar
Posted By Sudhansudeep
Thu Sep 06 2018, 12:48 PM
the code is same as u sent me for 16 chars