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
sashijoseph
Tue Mar 04 2008, 12:00AM

 User Offline
Registered Member #5870
Joined: Mon Feb 04 2008, 06:26PM

Posts: 554
Thanked 124 times in 117 posts
The previous USART_Write(volts_out) would send out the value volts_out which had been declared as char hence only rounded off values(ie1,2,3,4,5) would be sent instead of say 1.87 or 2.54 etc.It was only for checking proper working.
The actual value received by the adc,which is an integer (2bytes) is split into two bytes and sent to the PC as Low_byte and Hi_byte.In the PC you can then 'join' the 2 bytes to the original int and then convert it to the appropriate voltage reading to be displayed. Hope it's clear.
I would suggest doing things step by step.First program the PIC and see if the LED's are working correctly.Then use Hyperterminal and check if the serial code is OK.Finally make the VB program.



Let there be music........
Back to top


norms
Tue Mar 04 2008, 01:37AM
 User Offline
Registered Member #6079
Joined: Sat Feb 16 2008, 12:34AM

Posts: 28
Thanked 0 times in 0 posts
thanks.. ill try it tonight...
Back to top


norms
Tue Mar 04 2008, 07:24AM
 User Offline
Registered Member #6079
Joined: Sat Feb 16 2008, 12:34AM

Posts: 28
Thanked 0 times in 0 posts
hmm im trying it right now, and it can't light the leds on... does something in my circuit is wrong? the schematic diagram of my pic was posted before here. kindly check it sashjoseph, ive changed the ADCON1 to ADCON0, so the input will be put in AN0 in pin number 2, am i right?
Back to top


norms
Tue Mar 04 2008, 09:18AM
 User Offline
Registered Member #6079
Joined: Sat Feb 16 2008, 12:34AM

Posts: 28
Thanked 0 times in 0 posts
heres my code and its working, i can light the leds now..... hope you can add the necessary codes for transmitting the signal to the serial port... pls help...


void main()
{
int limit=512;
int value;
TRISA=0xff; // Configure PORTA as analog input
TRISB=0; // Configure PORTB as output
PORTA=0;
PORTB=0;
ADCON0=0b10000000;
ADCON1=0b10001110;
ADCON0.ADON=1; // Enable ADC
for(;;)
{
ADCON0.GO=1;
Delay_us(10);
value=Adc_Read(0);
if(value>=512) // value is greater or equal to 2.5V
{
PORTB.F0=1;
PORTB.F2=1;
PORTB.F4=1;
PORTB.F6=1;
Delay_ms(100);
PORTB.F0=0;
PORTB.F2=0;
PORTB.F4=0;
PORTB.F6=0;
Delay_ms(100);
}
else if(value<512)
{
PORTB.F1=1;
PORTB.F3=1;
PORTB.F5=1;
PORTB.F7=1;
Delay_ms(100);
PORTB.F1=0;
PORTB.F3=0;
PORTB.F5=0;
PORTB.F7=0;
Delay_ms(100);
}
Delay_ms(3000);
}
}



and pls help me in my vb program... here is my first vb program...

Private Sub CmdExit_Click()
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
End If
End
End Sub
Private Sub Form_Load()
MSComm1.InputLen = 0
MSComm1.CommPort = 1
MSComm1.Settings = "9600,N,8,1"
End Sub
Private Sub Timer1_Timer()
Dim BytesToRead As Integer
Dim value As Variant
MSComm1.PortOpen = True
BytesToRead = 1
Do
DoEvents
Loop Until MSComm1.InBufferCount = BytesToRead
value = MSComm1.Input
Text1.Text = (((Asc(value) * 0.01) * 230) / 2.5) & " Volts AC"
MSComm1.PortOpen = False
End Sub

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