El presente sitio presenta diseños y proyectos realizados con Solidworks y otros programas 3d , además de laminas y modelos 3d para practicar en casa, con el único objetivo de poder aprender y explorar la capacidad de Solidworks, no existiendo en ningún caso fines de lucro.
Friday, March 1, 2013
Simple Coversor Analógico Digital CCS
Posted by Juan Francisco | Friday, March 1, 2013 | Category:
CODIGO CCS
|
/////////////////////////////////////////////////////////////////////////
//// ////
//// This program displays the min and max of 30 A/D samples over ////
//// the RS-232 interface. The process is repeated forever. ////
//// ////
//// Configure the CCS prototype card as follows: ////
//// Insert jumpers from: 11 to 17, 12 to 18 and 9 to 16 ////
//// Use the #9 POT to vary the voltage. ////
/////////////////////////////////////////////////////////////////////////
#fuses HS,NOLVP,NOWDT,PUT
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
void main() {
int i, value, min, max;
printf("Sampling:");
setup_adc_ports( RA0_ANALOG );
setup_adc( ADC_CLOCK_INTERNAL );
set_adc_channel( 0 );
do { //Takes 30 samples from pin A0
min = 255; //and displays the min and max
max = 0; //values for that 100ms period
for(i = 0; i <= 30; ++i) {
delay_ms(100);
value = read_adc();
if(value < min)
min = value;
if(value > max)
max = value;
}
printf("nrMin:%x MAX: %x", min, max);
} while (TRUE);
}
Subscribe to:
Post Comments (Atom)
Currently have 0 comentarios: