Current Issue|
|
Under pressure (or not) 29/8/2008
MORE BLOG POSTS
PCIM Europe This Design Idea is for low-end, eight-pin, flash-memory, 8-bit microcontrollers, such as the MC68HC908QT4A from Freescale (www.freescale.com), but it would also apply to any 8-bit microcontroller that uses the ADC feature. In a nutshell, the ADC converts an inputanalog- voltage level to a digital-signal format. The digital-signal format has an 8-bit hex-code value, such as $00. The microcontroller “sees” the inputanalog- voltage level from its ADC ports in a range from $00 at VSS to $FF at VDD. Based on those hex-code values, there is a total of 256 ticks. The input voltages between VSS and VDD represent a straight-line linear conversion. In other words, the higher the input voltage, the higher thehex-code value.
The difficulty is that a programmer who needs to write assembly code for a programming algorithm must know what the hex-code value is for a different input-analog-voltage level—1.6V, for example. Referring to the microcontroller’s specs and even contacting its manufacturer do not yield satisfactoryanswers.
However, this Design Idea presents a solution to the problem. Given the microcontroller’s power operatingvoltage source, VDD, use the following simple formula to obtain the hexcode value that corresponds to an identified input-analog-voltage level: VINVIN/(VDD/255)=result value= hex code. Note that you must round off the result value to a whole number before converting to a hex-code value for better accuracy. The following sample calculation finds the hexcode value for a measured input-analog- voltage level of 1.6V when using a known microcontroller’s VDD of 5V:1.6V/(5V/255)=81.6=82, or $52.