|
|
View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Apr 10, 2008 2:37 pm |
|
|
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
|
Transfer the analog data to visual basic by through UART and |
Posted: Wed May 01, 2013 6:40 am |
|
|
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
|
|
Posted: Wed May 01, 2013 7:18 am |
|
|
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 |
|
|
|
|
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
|