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

Sun May 20 2018, 01:16 PM
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, 09:51 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, 04:09 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, 11:24 PM
@kaiserslautern Post in forum
Wed Apr 25 2018, 10:24 AM
kaiserslautern
Hello everyone, using software uart is a very good idea for a second serial port. Thank you so much. I would kindly like to know how to connect this port to the PC?
ExperimenterUK
Sat Apr 21 2018, 11:05 PM
This is a community site. Feel free to help anyone needing advice
hareeshchamiyar
Thu Mar 29 2018, 02:02 PM
please help me for the configuration bits for dspic30f2010
hareeshchamiyar
Thu Mar 29 2018, 02:00 PM
can any one using dspic30f2010.
Thu Mar 29 2018, 09:18 AM
Neena
can anybody give solar tracking in 8051 using proteus and keil to mail [email protected]
ExperimenterUK
Mon Mar 19 2018, 10:48 PM
sorry bedo.. maybe next time

Downloads

Comments

bdmehta
Tue May 22 2018, 02:30 AM
kmag1953
Sun Apr 29 2018, 07:09 PM
udiwonder
Sat Apr 28 2018, 12:41 PM
pirpiri
Sat Apr 21 2018, 03:35 PM
Pater
Fri Apr 20 2018, 02:38 PM
jamiel
Sat Apr 14 2018, 12:47 AM
akrepkral76
Wed Apr 04 2018, 07:51 PM
samanthaeaves
Mon Apr 02 2018, 06:27 AM

Online

Guests: 58, Members: 0 ...

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

Members: 37998
Newest member: bdmehta
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Jul 12 2018, 08:27 PM
I'm glad we got there in the end :)>whats differen...
LAMBO Avatar
Posted By LAMBO
Thu Jul 12 2018, 06:51 AM
hi sir as u mentioned above to change crystal and ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Jul 10 2018, 07:20 PM
I assume you meant a AT89S52.It seems to me that...
LAMBO Avatar
Posted By LAMBO
Tue Jul 10 2018, 06:06 AM
hi sir i have checked now much of the distortion ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Jul 09 2018, 06:55 PM
Okay that is very interesting.I have attached two ...
LAMBO Avatar
Posted By LAMBO
Mon Jul 09 2018, 08:14 AM
hi sir as u mentioned above program i have tried ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Jul 06 2018, 11:58 PM
Okay..That motor creates a lot of sparks which mig...
LAMBO Avatar
Posted By LAMBO
Fri Jul 06 2018, 01:33 PM
hi sir as u told >Try the original code againi hav...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Jul 02 2018, 06:20 PM
>is it ok to work on 12.10 v Yes, that is ok.>now...
LAMBO Avatar
Posted By LAMBO
Mon Jul 02 2018, 08:22 AM
hi sir as u mentioned in the program i have checke...