CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

A to D conversion with the 18f452

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 10, 2008 2:37 pm     Reply with quote

Example:
Code:
#include <18F452.h>
#device adc=10
#fuses HS,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=20000000) 
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

//=================================
void main()
{
int16 result;

setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_DIV_32);
set_adc_channel(0);
delay_us(15);

while(1)
  { 
   result = read_adc();
   printf("%LX ", result);
   delay_ms(500);
  }

}

This assumes your PIC has a 20 MHz crystal and that your analog input
signal is connected to the AN0 pin on the PIC. It also assumes that you
have your PIC board connected to the serial port on your PC, and that
you are running a terminal program such as HyperTerminal on your PC.
ongrongsan



Joined: 01 May 2013
Posts: 1
Location: Malaysia

View user's profile Send private message

Transfer the analog data to visual basic by through UART and
PostPosted: Wed May 01, 2013 6:40 am     Reply with quote

Thank for your coding, if I want transfer the analog data to visual basic by through UART and to control the I/O using visual basic. It's possible?
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Wed May 01, 2013 7:18 am     Reply with quote

Hi,

Yes, of course it's possible, why not? The PIC can send and receive data via
the UART, and Visual Basic can send and receive data using the PC COM port
and the MSCOMM control. Very simple to do this!

BTW, not that it's particularly relevant, but you are responding to a 5 year old thread!

John
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group