Free Print Subscription Printer-friendly version Email to a Friend

Microcontroller functions as voltmeter

( 01 Aug 2007 )
By Noureddine Benabadji, University of Sciences and Technology, Oran, Algeria

The circuit in Figure 1 is an extension of a previous Design Idea on how to use an analog input in a microcontroller lacking a built-in ADC, and it takes into account tricks from another Design Idea on how to drive a seven-segment LED display without external switching transistors (reference 1 and reference 2). This circuit adds a serial link and needs only a twisted pair to send each measurement to a compatible PC. The serial link was tested using a Microsoft Hyper Terminal configured at 115,200 baud; at 8, N, and 1; and with no flow control.

Briefly, the software drives one seven-segment LED display at a time, through lines RA0 and RB7. Setting the RA0 output high and RB7 as the input activates common-anode display DS3. Setting the RA0 output low and RB7 as the input activates common-cathode display DS2. With RA0 as the input, setting the RB7 output high activates common-anode display DS1, and, with RA0 as the input, setting the RB7 output low activates common-cathode display DS0. While successively activating one display, only one line, RB0 to RB6, is configured as an output to drive one LED segment. This design no longer is limited to a VDDof 3V or lower, because LEDs inversely connect in parallel, so the forward voltage of one diode limits the reverse voltage of the other. Using a red-diode display requires 1.6V.

Figure 2 illustrates the new aspects of this Design Idea. Q1, R5, and R6 act as an equivalent variable resistor, RX, which charges capacitor C3. Instead of pulling RX to ground, just connect it to one I/O—RB0, for example—of the microcontroller. If RB0 is an output with a low state, then the first analog channel activates, and the measure subroutine counts pulses of charge as high as 66% of VDD; then, a look-up table converts this time delay to a three-digit millivolt value. To expand the number of analog inputs, you can connect as many as seven variable-resistor circuits in a parallel configuration—that is, each one connects between C3 and one I/O line, RB1 through RB7. Notice that I/O lines connect to the display and also activate or deactivate the analog channels. When one analog- input channel activates through one I/O line with the output in the low state, the other lines are high-impedance inputs, which deactivate all other channels. Meanwhile, the display is off.

The circuit in Figure 1 also adds a simple serial link with no added components. If you connect two I/O lines, RA1 and RA2, configured as outputs, to RXD (Pin 2) and GND (Pin 5) of an RS?232 connector, you can reproduce, by software, positive and negative voltages with respect to ground of the PC’s RS?232 port. When RA1 is high and RA2 is low, then RXD has a positive voltage of 5V with respect to ground of the PC’s RS?232 port. When RA1 is low and RA2 is high, then RXD has a negative voltage of –5V with respect to ground of the PC’s RS?232 port. Listing 1 gives a practical example with a PIC16F84A-20P. It is not optimized but is fully commented to make it easy to translate to another Microchip midrange device, such as a PIC16F628A, that supports a frequency of 20 MHz with more I/O lines.


References
· Benabadji, Noureddine, “Microcontroller, JFET form low-cost, two-digit millivoltmeter,” EDN, June 22, 2006, pg 71.
· Benabadji, Noureddine, “Ultralow-cost, two-digit counter features few components,” EDN, Aug 17, 2006, pg 69.

Click here for Illustrations:

Figure 1

Figure 2

 
Free Print Subscription Printer-friendly version Email to a Friend
 
Article Rating 
Average Rate:
 
Poor Quite Good Good Very Good Excellent
 
Related Content 
 
 
KNOWLEDGE CENTER
Panasonic Key Devices Guide 2008 :
 
Fairchild Semiconductor :
 
Texas Instruments: DaVinci™ Technology
 
Texas Instruments: Safe Bet Series
 
 
 
Highest Rated  
Feedback Loop  

ADS BY GOOGLE 
 
 
 
ADVERTISEMENT
Press Release 
 
TECHNOLOGY NEWS
 
RESOURCE CENTER

 
 
PRODUCT NEWS
 
FEATURED SPONSORS
 
 
DESIGN CENTERS
 
ADVERTISEMENT
     
Reference Designs 
   
     
 
 
 


 
 
RSS
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   

POLL
What type of environmental regulation do you think will be most beneficial for the tech industry?
Proper recycling and disposal
Push for power efficiency and energy conservation
Chemical/lead regulation
View results