Tiny microcontroller provides 4-channel A/D conversion for a PC serial port

Oct. 22, 1998
Microchip’s PIC12C671 is a lowcost 8-pin microcontroller that has everything needed to perform a four-channel 8-bit analog-todigital conversion without external components. To create a plug-in four-channel analog-to-digital converter for a PC, the...

Microchip’s PIC12C671 is a lowcost 8-pin microcontroller that has everything needed to perform a four-channel 8-bit analog-todigital conversion without external components. To create a plug-in four-channel analog-to-digital converter for a PC, the circuit in Figure 1 uses a PC’s serial port to power and communicate with the PIC12C671.

Pin 4 of the PC’s serial port supplies power to the microcontroller through a 5-V reference device. The PIC12C671’s VDD also serves as an A/D conversion reference voltage. The PC sends commands to the microcontroller through pin 7, and the device sends information back to the PC through pin 2. Figure 2 shows the details of the communication protocol.

Once the 12C671 powers up, it will count how many pulses are generated on the serial port’s pin 7 within 16 ms. If there’s one pulse, then channel 0 is selected for the A/D conversion. If the pulse count is 2, 3, or 4, channel 1, 2, or 3 will be selected. After the channel information is received, the microcontroller will start to perform the A/D conversion for the selected channel. Then the 8-bit A/D conversion data will be sent back to PC through the microcontroller's pin 2.

Since the PC may have a different serial port baud rate, it’s necessary to send a training pulse to the PC before starting transmission of A/D conversion data. The PC program contains a loop to accept the training pulse. The number of loop iterations that execute before the training pulse reception is completed determines the baud rate used for reception of the A/D conversion data from the microcontroller.

Listing 1 is the assembly program for PIC12C671 microcontroller and Listing 2 is the C program for the PC. The C program will read four inputs every second and will display the results on the PC screen.

Sponsored Recommendations

TTI Transportation Resource Center

April 8, 2024
From sensors to vehicle electrification, from design to production, on-board and off-board a TTI Transportation Specialist will help you keep moving into the future. TTI has been...

Cornell Dubilier: Push EV Charging to Higher Productivity and Lower Recharge Times

April 8, 2024
Optimized for high efficiency power inverter/converter level 3 EV charging systems, CDE capacitors offer high capacitance values, low inductance (< 5 nH), high ripple current ...

TTI Hybrid & Electric Vehicles Line Card

April 8, 2024
Components for Infrastructure, Connectivity and On-board Systems TTI stocks the premier electrical components that hybrid and electric vehicle manufacturers and suppliers need...

Bourns: Automotive-Grade Components for the Rough Road Ahead

April 8, 2024
The electronics needed for transportation today is getting increasingly more demanding and sophisticated, requiring not only high quality components but those that interface well...

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!