Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

help with ac voltmeter code

Status
Not open for further replies.

max_1974

Newbie level 5
Newbie level 5
Joined
Feb 20, 2009
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,411
hello to all

can anyone please help me with this code it's ac voltmeter using 16F676.
how can i convert it to Hex
Code:
void main()
{

#define data1 PORTC.F1

#define clk PORTC.F0

#define seg1 PORTC.F3

#define seg2 PORTC.F4

#define seg3 PORTC.F5



unsigned char aray1[10]={0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfc,0x87,0xff,0xe7};

void shift(unsigned char value)

{

unsigned char temp1,i;

 temp1=value;



for(i=0;i<8;i++)

{

clk=0;

data1=temp1/128;

 clk=1;

 temp1=temp1<<1;

 }



    }

void display(unsigned int value)

{   unsigned char j,k,l,m;

 k=value%10;

value=value/10;

l=value%10;

value=value/10;

m=value%10;



for(j=0;j<50;j++)

   {



  shift(aray1[m]);



  seg1=1;

  seg2=0;

  seg3=0;

   Delay_ms(1);

   seg1=0;

  seg2=0;

  seg3=0;

  shift(aray1[l]);

   seg1=0;

  seg2=1;

  seg3=0;

     Delay_ms(1);

   seg1=0;

  seg2=0;

  seg3=0;

 shift(aray1[k]);

 seg1=0;

  seg2=0;

  seg3=1;

   Delay_ms(1);

   seg1=0;

  seg2=0;

  seg3=0;



   }

   }

void main()

{ unsigned int temp=0,count=0;

unsigned char r;





TRISA=0x03;

CMCON=0x00;

    OPTION_REG|=0x80;

   WPUA=0xff;





   TRISC=0x00;









      while(1)

   { ADCON0=0x80;



   ADCON1=0x70;



    ANSEL=0x03;

    Delay_ms(1);

    for(r=0;r<10;r++)

    {

   ADCON0.ADON=1;

    Delay_ms(1);

   ADCON0|=(1<<GO);

   while(!(ADCON0&(1<<GO)));

      Delay_ms(1);

   temp=((ADRESL)|(ADRESH<<8));



    count=count+temp;

    }



     display(count/10);

     count=0;

    }







   }
 

when you compile your code you get a Hex file along with other files in your projects
 

I'm getting this error

Error 128 A #DEVICE required before this line
 

You must give us some clues. Like - what program is telling you this?

Which compiler are you using and is this error from the compiler or the device programmer?

Is your problem that you want the result in hexadecimal or you want the programming information to be in a hex file?


BRian.
 

if you are having any problem to display the digits on 7 segment then u can take a help from the given below thread

how to make a seven segment based count down timer for traffic signal using atmega 16
 

Good day
as your code start with main() , have you included the required header ? like #include <16F676> in your header ? and any other device initializing required ?

Regards
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top