free 8051 Microcontroller Projects AVR PIC Microcontroller Projects Tutorials Ebooks Libraries, interfacing tutorials, lcd tutorial, stepper motor, dc motor 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems

 
8051 microcontroller 8051 microcontroller
Forums

8051 Microcontroller Projects AVR PIC Projects Tutorials Ebooks Libraries codes :: Forums :: Discuss and Learn :: PIC Microcontroller Discussion
 
<< Previous thread | Next thread >>
how to dispaly the a/d value from PIC16F877 using visual basic in digital value
Go to page  [1] 2 3 4
Moderators: Ajay, Junied , abbas1707, Arun Kumar V, pdi33, Shailesh NAYAK, ۞ TPS ۞, shyam, sashijoseph
Author Post
norms
Sat Feb 16 2008, 12:41AM
 User Offline
Registered Member #6079
Joined: Sat Feb 16 2008, 12:34AM

Posts: 28
Thanked 0 times in 0 posts
hi i'm a newbie in this one. can anyone help me with this? i'm using miKroC for programming the microcontroller. now i want to display the readings of the micocontroller in visual basic. for example i have a voltage output 4v read by the ucontroller and want to display the digital output in visual basic... thank you very much for sparing your time...

Back to top


Ajay
Sat Feb 16 2008, 01:01AM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 3753
Thanked 696 times in 655 posts
send the value to PC using UART and then display it in VB software after reading from COM port. All you need to do is COM port programming in Visual Basic (search forum for more information)

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top


norms
Sat Feb 16 2008, 01:21AM
 User Offline
Registered Member #6079
Joined: Sat Feb 16 2008, 12:34AM

Posts: 28
Thanked 0 times in 0 posts
this is my c program for microcontroller... any help or suggestion? it doestn have an error though

CODE:
unsigned int volts_out;
unsigned int get_adc;
unsigned int x;
unsigned int norms;
unsigned int value;
unsigned int temp1;
unsigned int temp2;

void main()
{
 int exit = 1;
 Usart_Init(9600);
 ADCON0 = 0x80;
 ADCON1 = 0x80;
 ADCON0.ADON = 1; // Enables A/D Conversion
 TRISB = 0;
 PORTB = 0;
 RCSTA = 0x90;
 TXSTA = 0x24;
 Delay_ms(100);
 
 for(;;)
  {
    if(Usart_Data_Ready())
    {
      exit=1;
      PORTB=0;
      volts_out=Usart_Read();
      Delay_ms(100);
      norms = (( 2.5 *1023)/5);
      if(volts_out==norms)  // Within the 240-220 voltage range
      {
       x = volts_out * (5/1023);
        do
        {
          PORTB.F2=1;
          PORTB.F3=1;
          PORTB.F4=1;
          PORTB.F5=1;
          Delay_ms(100);
          if(Usart_Data_Ready())
          {
            exit=0;
          }
        } while(exit);
      }
      else if(volts_out>norms) // Greater than 240 Volts
      {
        x = volts_out * (5/1023);
        do
        {
            PORTB.F2=1;
            PORTB.F3=0;
            PORTB.F4=0;
            PORTB.F5=1;
            Delay_ms(100);
            if(Usart_Data_Ready())
          {
            exit=0;
          }
        } while(exit);
      }
      else if(volts_out<norms)
      {
        x = volts_out * (5/1023);
        do
        {
          PORTB.F2=0;
          PORTB.F3=1;
          PORTB.F4=1;
          PORTB.F5=0;
          Delay_ms(100);
          if(Usart_Data_Ready())
          {
            exit=0;
          }
        }
        while(exit);
      }
      else if(volts_out==get_adc)
      {
        do
        {
          ADRESH=0;
          ADRESL=0;
          PORTB.F1=1;
          ADCON0.GO=1;
          Delay_ms(100);
          value=Adc_Read(0);
          Delay_ms(100);
          exit=0;
          temp1=ADRESH;
          temp2=ADRESL;
          Delay_ms(100);
          PORTB.F1=0;
          Delay_ms(100);
          Eeprom_Write(0,temp1);
          Delay_ms(20);
          Eeprom_Write(1,temp2);
          Delay_ms(20);
          Delay_ms(50);
          Usart_Write(Eeprom_Read(0));
          Delay_ms(20);
          Usart_Write(Eeprom_Read(1));
          Delay_ms(50);
          if(Usart_Data_Ready())
          {
            exit=0;
          }
        } while(exit);
      }
    }
    else
    {
      PORTB=0xff;
    }
  }
 
}
 


[ Edited Sat Feb 16 2008, 01:26AM ]
Back to top


norms
Sat Feb 16 2008, 01:23AM
 User Offline
Registered Member #6079
Joined: Sat Feb 16 2008, 12:34AM

Posts: 28
Thanked 0 times in 0 posts
how i am going to display the read value in visual basic in digital form?
Back to top


Ajay
Sat Feb 16 2008, 04:20AM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 3753
Thanked 696 times in 655 posts
how actually you are displaying your ADC output and where?

also what do you mean by digital form? can you explain with example?

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top


norms
Sat Feb 16 2008, 06:16AM
 User Offline
Registered Member #6079
Joined: Sat Feb 16 2008, 12:34AM

Posts: 28
Thanked 0 times in 0 posts
the x = .... is the one i will be calling in the visual basic...
i mean decimal value, sorry...
Back to top


abbas1707
Sat Feb 16 2008, 06:48AM

 User Offline
Registered Member #383
Joined: Thu Jan 25 2007, 08:07AM

Posts: 414
Thanked 67 times in 52 posts
consider you have value=56 in microcontroller...now convert decimal to a string. and send seriially to vb.
it that wat you want

A Thousand Miles Journey Starts With a Single Step.
Back to top


norms
Sat Feb 16 2008, 08:37AM
 User Offline
Registered Member #6079
Joined: Sat Feb 16 2008, 12:34AM

Posts: 28
Thanked 0 times in 0 posts
abbas1707 wrote ...

consider you have value=56 in microcontroller...now convert decimal to a string. and send seriially to vb.
it that wat you want



yup...

this is how i am going to convert

2.5v is the output read from a certain load then i'll convert it to decimal like this:

norms = (( 2.5 *1023)/5);

then ill have this declaration:

if (volts_out==norms)

//ill convert the decimal to a voltage value

x = (volts_out * (5))/1023 // this is the voltage that ill be calling to the visual basic program, am i right?

in vb

the value of x will be multiply to the ratio of the transformer like this

y = (x*220)/5

so y is the final value that i will like to be display in vb...

so is it ok?
Back to top


GioppY
Sat Feb 16 2008, 09:31AM
 User Offline
Registered Member #6071
Joined: Fri Feb 15 2008, 03:10PM

Posts: 22
Thanked 7 times in 4 posts
Do you mean something like this:
Back to top


norms
Sat Feb 16 2008, 10:10AM
 User Offline
Registered Member #6079
Joined: Sat Feb 16 2008, 12:34AM

Posts: 28
Thanked 0 times in 0 posts
yup but the voltage vill be converted to 220v from 8.7 for example. so insted of 8.7v in display it will now display 220V

[ Edited Sat Feb 16 2008, 10:13AM ]
Back to top


Go to page  [1] 2 3 4  

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System

8051 Microcontroller Projects 8051 AVR tutorials PIC microcontroller, 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems