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

Board-Mount DC/DC Converters in Medical Applications

March 27, 2024
AC/DC or board-mount DC/DC converters provide power for medical devices. This article explains why isolation might be needed and which safety standards apply.

Use Rugged Multiband Antennas to Solve the Mobile Connectivity Challenge

March 27, 2024
Selecting and using antennas for mobile applications requires attention to electrical, mechanical, and environmental characteristics: TE modules can help.

Out-of-the-box Cellular and Wi-Fi connectivity with AWS IoT ExpressLink

March 27, 2024
This demo shows how to enroll LTE-M and Wi-Fi evaluation boards with AWS IoT Core, set up a Connected Health Solution as well as AWS AT commands and AWS IoT ExpressLink security...

How to Quickly Leverage Bluetooth AoA and AoD for Indoor Logistics Tracking

March 27, 2024
Real-time asset tracking is an important aspect of Industry 4.0. Various technologies are available for deploying Real-Time Location.

Comments

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