This is an application of USB connectivity in this particular case, using the emulation RS232 serial port using a PIC18F2550 microcontroller (You can use any of this family) to acquire analog data using analog-digital converter of the same, and sending this data to the PC and processed by LabView.
With LabView can do a lot of awesome things, and most impressive is the implementation time is very short, in minutes you can get a pretty powerful application.
used for this application components labview VISA for serial connection quickly but effective CHART GRAPH is used to plot the acquired data, and function to WRITE TO SPREAD SHEET save this data to a spreadsheet exel.
With LabView can do a lot of awesome things, and most impressive is the implementation time is very short, in minutes you can get a pretty powerful application.
used for this application components labview VISA for serial connection quickly but effective CHART GRAPH is used to plot the acquired data, and function to WRITE TO SPREAD SHEET save this data to a spreadsheet exel.
CLICK HERE FOR CODE [-/+]
//-------------------------- -------------------------------------------------- -------
/ /
/ / More projects in: http://perfectalgorithm.blogspot.com
/ /
//------------------ --------------------------------------------------
-------------- / / This work is licensed under a
/ / Attribution-Noncommercial-Share Alike 2.5 Mexico Creative Commons.
/ / To view a copy of this license, visit:
/ / http://creativecommons.org/licenses/by-nc-sa/2.5/mx/
/ / or envie a card to Creative Commons, 171 Second Street, Suite 300,
/ / San Francisco, California 94105, USA.
//----------------------------------------------- ------------------------------------
# include \u0026lt;18F2550.h> # device ADC
= 10 # fuses
XTPLL, NOWDT, NOPROTECT, NOLVP, NODEBUG, USBDIV, PLL1, CPUDIV1, VREGEN, NOPBADEN
# use delay (clock = 48000000)
\u0026lt;usb_cdc.h>
# include # include \u0026lt;LCD1 . c> / / Change LCD adecuado por library.
\u0026lt;string.h>
# include # BYTE TRISA = 0x0F92
BYTE TRISB = # # BYTE PORTA =
0x0F93 0x0F80 0x0F81
# BYTE PORTB =
ADCON0 BYTE # = BYTE # 0x0FC2
ADCON1 0x0FC1
= BYTE # = cmwith 0x0FB4
char command [10];
adc_string char [ 10], int16
adc_dato;
int len \u200b\u200b= 0;
char c;
void command ();
void main (void) {
LCD_init ();
usb_init ();
TRISA = 0x0FF ;
TRISB = 0x00;
ADCON1 = 0x0F;
cmwith = 0x07;
setup_comparator (NC_NC_NC_NC);
setup_adc_ports (an0);
setup_adc (vss_vdd);
set_adc_channel (0);
setup_adc (adc_clock_internal);
printf (lcd_putc, "\\ fPerfectAlgorithm");
len = 0;
while (TRUE) {
if (usb_enumerated ()) {
if (usb_cdc_kbhit ()) {
c = usb_cdc_getc ();
command [len] = c;
len + +;
}
if (len> 2) {
commando ();
len = 0;}
}}}
envia_dato void () {
int i;
read_adc(ADC_START_ONLY);
while (bit_test(ADCON0,1));
adc_dato = read_adc(ADC_READ_ONLY);
sprintf(adc_string,"%Lu",adc_dato);
for(i=0;i<strlen(adc_string)+1;i++) {
usb_cdc_putc(adc_string[i]);
while(!usb_cdc_putready());
}
}
void commando() {
if (Comando[0]=='G') { //----------- GDT
if (comando[1]=='D') {
if (comando[2]=='T') {
envia_dato();
}
}
}
}
CLICK HERE TO VIEW DOWNLOAD SOURCE LABVIEW / PIC [-/+]
The file contains the firmware for the PIC (. C Compiled CCS PCW) and SOURCE for LabView v8.6
http://rapidshare.com/files/395453831/Conexion_CDC_con_Labview.rar.html
0 comments:
Post a Comment