Skip navigation
Power Electronics

Isolated Serial Link Delivers Digitized Power Supply Data

Isolated link provides safe communication of power supply status.

Safety agencies require user-accessible signals for power supplies to be isolated from power supply referenced signals. This infers that these power supplies must provide a means for information, such as power supply status or enable/disable commands, to pass safely across the isolation barrier. Common methods for this are to use opto-couplers or isolation transformers. These methods work well and are easy solutions when there are few communication lines. But, these solutions become cumbersome for a large number of lines. In applications where there are many communication signals, a more elegant solution is to digitize these signals and transmit and receive the information via an isolated serial link.

Some of our company's off-line power supplies have up to 10 output voltages. All the products provide the user with various controls for the power supply, such as individual output enable/disable lines. By digitizing these control lines and communicating the information across the isolation barrier via two microcontrollers, you can reduce the number of isolation lines to two. This simplifies the hardware — especially as the number of isolated signals goes up. This is exactly what we are doing on the PFC Micro, an 800W, six output, power factor corrected off-line switching power supply. The PFC Micro has 10 individual user-interface lines — six of them are bidirectional. This method reduces the number of isolation elements from sixteen to two. The serial communication link approach allows the addition of increased functionality to the power supply at little or no cost in hardware.

This solution is advantageous in applications where there are a large number of isolation lines required and/or where a lot of features are required. Under these conditions, the design can have a lower parts count and cost, and it takes less space on the p. c. board. Another advantage is adaptability. Because the execution of the features is in firmware, alteration to meet future user needs is possible. These include controlling power on/off sequencing or adding additional features.

The method developed for the PFC Micro utilizes a four-word frame to communicate information between the two microcontrollers. The microcontrollers read any change in the digital inputs for the transmission of the correct frame of information. Communication between the microcontrollers is asynchronous. Each microcontroller can receive and transmit data simultaneously. The frame approach provides error detection and correction. The protocol also uses handshaking. This helps in assuring the proper completion of tasks and proper reception of data. Designers chose Microchip's PIC16C63A microcontroller for this application, which was written in C, because it contains a built-in USART (Universal Synchronous Asynchronous Receiver Transmitter). This feature simplifies the code considerably.


The transmission/reception frame consists of four words: Start word; Code word; Data word; and CheckSum word

The Start word was arbitrarily set to 55 Hex. The receiving microcontroller uses it to determine where the incoming information frame begins. The second word of the frame is the Code word. It contains the instruction information of the frame. Theoretically there could be up to 28 instructions. Third is the Data word. Here, you can find any data necessary to execute the instruction. Last is the CheckSum word. This is the summation of the previous three words. It's primary function is error checking. If the CheckSum is not correct, the frame is corrupt.

Upon completion of a transmission (transmitting a whole frame of data), the transmitting microcontroller waits until the receiving microcontroller sends back a data valid acknowledge frame (ACK). This interrupts control reception after receiving a word. Each received word is stored in a temporary storage location allocated for each word in the frame. After receiving the whole frame, the first three words of the frame combine, to compare the sum to the received CheckSum. If the CheckSum is incorrect, the receiving microcontroller will send back a data invalid frame (NAK). After receiving this frame, the original data retransmits. The transmitting microcontroller also retransmits the data after a certain amount of time, if the receiving unit has not responded with an ACK frame (data valid acknowledge).


The USART of the PIC microcontroller is configured in the asynchronous mode. In this mode, nonreturn-to-zero format (one start bit, eight data bits, and one stop bit) transmits the data. The USART transmits and receives the LSB first. The same baud rate and data format are used for the transmitter and receiver — even though they're independent. Once the USART is configured, (setting USART to asynchronous mode, selecting the baud rate, etc.) transmission is easy. Just load the TXREG (transmit register) with the data you want to transmit, and transmission automatically commences. When TXREG is empty, the empty flag bit (TXIF) sets. You can now load the next Data word for transmission into the TXREG.

When the program wants to transmit a frame of information, data is loaded into the XCodeReg (transmit code register), XDataReg (transmit data register), and the ACKF (acknowledge data sent) flag and Xmit (transmit flag) are set. The Xmit flag calls the transmit function. The Code and Data words pass to the transmit function. The transmit function then calculates the CheckSum word and transmits the four-word frame. An ACKF flag signifies that the transmitting microcontroller is waiting for an ACK (data valid acknowledge) command from the other microcontroller. If this command is not received in a specified amount of time (255 ms) or if a NAK (data invalid) command is received, the data frame retransmits.

Figs. 1 and 2, on pages 50 and 52, describe how the transmit function operates. First, the interrupt that can cause a change in the data frame is disabled. The transmit counter (Fcount) initializes and the data and code words are stored in global variables. Then, the CheckSum word is calculated. Transmission can begin at this point. The Start word (55 Hex) is then loaded into the TXREG. Now the frame transmission loop is entered. When the TXIF (TXREG register empty) flag is set, the next word to be transmitted is loaded into the TXREG. The Fcount counter value determines which word is loaded. As each word is loaded into the TXREG, the Fcount counter decreases. When Fcount equals zero, the transmit function proceeds to two routines used for error detection and correction. If there's a problem in the communication between the microcontrollers, these routines help to re-establish successful communication. Each routine basically does the same thing. They allow only a certain number of retransmissions of the NAK (data invalid) command. The primary function of this bit of code, in conjunction with some code in the receive function, is to correct a frame sequence error. For example, if the receiver thinks that the code word in the frame is the Start word, the frame received will always be invalid. Thus, the NAK command will continually be transmitted. To prevent this from infinitely happening and to re-establish the communication link, this code was added. The first routine is used if the transmitting microcontroller received a NAK command in response to a frame it sent. And the second is used if an error is detected in the received frame (i.e. CheckSum incorrect). The last process before leaving the transmit function is to re-enable the interrupt that was disabled when the function was entered.


Once the USART is configured for the asynchronous mode, setting the CREN bit enables the reception. It's bit four of the RCSTA register (receive status register). A high-speed shift register reads incoming data into the microcontroller. Upon reception of the stop bit, the incoming data transfers to the RCREG (receive register). Data is received in the nonreturn-to-zero NRZ format (one start bit, eight data bits and one stop bit) — that is, if the RCREG is empty. An interrupt generates when this transfer is complete. The interrupt sets the RCIF bit in the PIR1 register. Setting the enable bit RCIE in the PIE1 register enables the interrupt. The receive interrupt RCIF bit clears when the RCREG register is read and is empty. The RCREG register is a two deep FIFO (first in first out). Therefore, it's possible to receive two bytes of data before the RCREG is read. If a third word is received while RECEG is still full, an overrun error bit (OERR) will be set.

When a word is received and an interrupt generated, the program will call the receive function. Fig. 3, below, and Fig. 4, on page 57, provide details of the receive function. First the BadCom flag is checked to see if it's set. If it's set, the communication with the other microcontroller is not functioning properly. At this point, the receive function will not do anything else in the function until the Start word is received. Once it's received, frame reception is initiated. This section of code solves the problem of frame misalignment. The receive function assumes the frame is received in a specific order (Start, Code, Data, and CheckSum) and uses a counter to store the received word in the proper storage locations. If communication is functioning properly, each received word will be stored in its proper temporary storage locations (STemp, CTemp, DTemp, and CHKTemp).

Once the CheckSum is received, it's compared to the CheckSum calculated by the receive function (STemp+ CTemp+DTemp). The receive function can store two frames of data. If the received CheckSum is correct and no other frame is in the reception registers (decode queue) the received frame is loaded in the reception registers (RCodeReg, RDataReg, RChkSum). However, if data is in the decode queue (reception registers), the frame will remain in the temporary registers and will be moved to the reception registers when the frame ahead of it in the queue is decoded. Note: If a third frame is received before the second frame received is transferred to the reception registers, it (the second frame received) will be lost. If the calculated CheckSum is not the same as the received CheckSum, then the NAK code (Data is not valid) is loaded into the decode queue. It's loaded into the correct registers, depending on the condition of the queue. When the frame is loaded into the queue, the decode flag (Flag 4.7) is set. This flag will be used to call the decode function, decode the data, and take the proper action. The proper action in the case of the NAK code is to retransmit the frame. The last thing that happens before exiting the receive function is to check to see if an overrun has occurred. An overrun is defined as the reception of a third word by the USART before the first word received is read. Reading the RCREG register clears it. If an overrun occurs, the overrun bit (OERR) clears to keep the communication link up and running. An overrun causes the second word received to be lost and overwritten by the third word. If this occurs, it could cause a frame misalignment error. As mentioned above, the code can correct for this error.

This approach is a good alternative for situations where the number of isolation lines are large, or significant functionality is needed. The frame approach to serial communication is simple and a reliable method for receiving and transmitting data across an isolation barrier. Microchip's PIC16C63A, with its built in USART, does the lion's share of the formatting and control of the data flow. This means besides configuring the USART, you can concentrate management of the incoming and outgoing data. The four-word frame provides enough headroom for applications with moderate instruction needs and provides a degree of error detection. Handshaking and frame error detection also increase the reliability of the communication between the two processors. The two C-code functions are not excessively complex, and you can use them in many applications to provide reliable information transfer.


  1. Microchip Technology Inc., PIC16C6X Data Sheet, Microchip Technology Inc., 1998.
  2. Peatman John B, Design with PIC Microcontrollers, Prentice Hall Inc., 1998.
  3. Microchip Technology Inc., MPLAB C Compiler User's Guide, Microchip Technology Inc., 1997.
  4. Horton Ivor, Instant C Programming, Wrox Press Ltd., 1995.
Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.