CURRENT ISSUE
Contests
FROM THE BENCH
|
|
Issue #213 April 2008
Digital Touch
A Potentiometer with No Moving Parts
by Jeff Bachiochi
Start | Touch Slider IC | Digital Potentiometers | Control and Feedback | Value to Digits | Linear Segmentation | Worth It | Sources & PDF
VALUE TO DIGITS
This application is based on a single timer-overflow interrupt. Every 4 ms, the Timer0 interrupt overflows. This interrupt routine is responsible for disabling the row driver for the present digit, selecting the next digit, figuring out what data should be displayed for the digit, and enabling the column driver before leaving.
A digit counter keeps track of the enabled digit 1 to 4, right to left (units, tens, hundreds, and sign). One column driver (digit) is enabled at a time (PORTC), while data for that digit is latched onto the row output port (PORTB). The data for that digit comes from a table holding the byte values that will display the digits 0 to 9 plus “blank” and “-.” The order of the table makes for an easy conversion from a number value to the offset in the table that holds the data representation of that value for the seven-segment display. Simple integer division determines the appropriate number to display based on the unit, ten, or hundredths position of the percent value (calculated in the main loop). For digit 4, a “blank” (table entry 10) is displayed unless the negative flag bit is set. Table entry 11 holds the data value for the minus sign.
|