Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/18/07 16:57
Read: times


 
#135204 - start by making your A/D convertor work
Responding to: ???'s previous message
You will likely need to measure some resistance and/or voltage for this so make the A/D convertor work and display the readings from a simple potentiometer as a starting point.

Pseudo code for access A/D devices is normally as follows:
(How to apply to your specific controller/device is up to you)

* activate A/D convertor
* setup the channel you want to measure (normally A/D convertors on mcu are multichannel)
* setup mode of conversion
* start conversion
* ... wait for conversion to finish (as a beginner use POLLING and NO interrupt - esp. for a test case like the one I propose)
* put the value together


For a T89C51CC02 that looks like follows in C (SDCC used):
/* initialize A/D hardware */
void ADC_init()
{
	ADCF=1;		/* set P1.0 as analog input */
	ADCON &= 0xF8;	/* clear A/D channel select */
	ADCON |= MSK_ADCON_ADEN; /* enable ADC */
}

/* execute A/D conversion
    IN: channel 0-7   the A/D channel we want to measure
   OUT: conversion result - 16bit value
 */
int ADC(unsigned char channel)
{
	int result=0;	

	ADCON |= channel; /* set channel to measure */
	ADCON |= MSK_ADCON_ADSST; /* start A/D input */

	/* wait until conversion has finished  - inline assembler is faster */
	_asm
adcloop:
	mov A,_ADCON
	jb ACC.3,adcloop
	_endasm;

	ADCON &= 0xef;

	/* read A/D value */
	result=((ADDH<<2)+ADDL);
	
	return(result);
}




And your task is to transfer and adapt this new knowledge to your project and specific circuit! This WILL NOT work for whatever you have at hand, it is only to show principles and ideas.

HTH,
Matthias

List of 34 messages in thread
TopicAuthorDate
thermometer with a 89c52            01/01/70 00:00      
   e-mail            01/01/70 00:00      
   You\\\'ve got lots of options including...            01/01/70 00:00      
      Options            01/01/70 00:00      
   start by making your A/D convertor work            01/01/70 00:00      
      What the hell are you posting??            01/01/70 00:00      
      Not for a direct-to-digital sensor!            01/01/70 00:00      
   Link            01/01/70 00:00      
   Background?            01/01/70 00:00      
      thanx            01/01/70 00:00      
         Project?            01/01/70 00:00      
            hobby            01/01/70 00:00      
               Plenty of time to think, then!            01/01/70 00:00      
   Thermistor, 12-bit ADC, 89S52 and LED display            01/01/70 00:00      
      lm35            01/01/70 00:00      
         Thermistor Thermometer: LCD version            01/01/70 00:00      
            Think!            01/01/70 00:00      
         Interesting links that have to do with the LM35            01/01/70 00:00      
            Interesting links on how to make a simple ADC...            01/01/70 00:00      
            You forgot the most important one            01/01/70 00:00      
               I was assuming that he was already there!            01/01/70 00:00      
   the easy way            01/01/70 00:00      
      Easy?            01/01/70 00:00      
         Re Easy            01/01/70 00:00      
            There's the problem!            01/01/70 00:00      
            My friend's opinion            01/01/70 00:00      
               I hope analog            01/01/70 00:00      
                  In that case            01/01/70 00:00      
               understanding basics            01/01/70 00:00      
                  slight warning about 1-wire thermo sensors            01/01/70 00:00      
                     Parasite power?            01/01/70 00:00      
                        yep parasite power            01/01/70 00:00      
               not believeable !            01/01/70 00:00      
                  timing diagrams can look daunting.            01/01/70 00:00      

Back to Subject List