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

hareeshchamiyar
Thu Mar 29 2018, 10:47 AM
please help me for the configuration bits for dspic30f2010
hareeshchamiyar
Thu Mar 29 2018, 10:45 AM
can any one using dspic30f2010.
Thu Mar 29 2018, 06:03 AM
Neena
can anybody give solar tracking in 8051 using proteus and keil to mail [email protected]
ExperimenterUK
Mon Mar 19 2018, 07:33 PM
sorry bedo.. maybe next time
Sun Mar 18 2018, 07:48 AM
Mourya Manojkumar
Please send me circuit diagram and PCB diagram
Thu Mar 01 2018, 05:49 AM
Felixc
May you please help me with a code for programmable load shedding controlling 4 loads
Sun Feb 25 2018, 08:29 PM
ezeoke.charles
i need of it
Sat Feb 24 2018, 03:35 AM
Aaquib
I want help for digital ic tester
ExperimenterUK
Tue Feb 20 2018, 04:01 PM
Join up.. and post your problem
Mon Feb 19 2018, 11:17 AM
ashishkumar
i needs help for my project

Downloads

Comments

jamiel
Sat Apr 14 2018, 12:47 AM
akrepkral76
Wed Apr 04 2018, 07:51 PM
samanthaeaves
Mon Apr 02 2018, 06:27 AM
rana2056
Sat Mar 31 2018, 02:11 PM
Darshanparabbnb
Mon Mar 26 2018, 07:17 AM
marttinsmarcio
Sat Mar 24 2018, 12:31 PM
LAMBO
Tue Mar 20 2018, 09:51 AM
bedo123
Mon Mar 19 2018, 07:48 AM

Online

Guests: 41, Members: 0 ...

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

Members: 37993
Newest member: jamiel
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Apr 16 2018, 08:49 PM
On the diagram, a diode feeds a rectified sine wav...
LAMBO Avatar
Posted By LAMBO
Mon Apr 16 2018, 06:39 AM
Hi sir i haven't connected any serial connec...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Apr 13 2018, 02:09 AM
I assume you are doing this project.http://www.805...
LAMBO Avatar
Posted By LAMBO
Thu Apr 12 2018, 06:51 PM
hii sir,I am working on ac motor controller .I hav...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Apr 10 2018, 06:12 PM
The lpc214x has a 32-bit prescaler , so I would ...
Praneeth1299 Avatar
Posted By Praneeth1299
Tue Apr 10 2018, 09:16 AM
Hi,I'm generating constant frequency of 1hz and va...
akrepkral76 Avatar
Posted By akrepkral76
Sat Apr 07 2018, 01:57 PM
I have used diptrace.I think ı have recevied from ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sat Apr 07 2018, 01:45 AM
You will need to say which software you are using,...
akrepkral76 Avatar
Posted By akrepkral76
Fri Apr 06 2018, 12:22 PM
I have drawed many PCB board. But it is still not ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed Apr 04 2018, 10:49 PM
Do you have a working HM2007 board as shown in the...