Electronic – Isolating digital I/O on an Atmega328

isolationmicrocontrollerstepper-driver

I have an Atmega328P MCU that is driving a stepper motor driver using its digital I/O. However, I'd like to use the same pins to drive the motor externally as well possibly using a different MCU or hardware. When the external driver is driving the motor using these same pins, the Atmega328P MCU maybe powered down and its state would be unknown. I know that its not safe to drive the Atmega328P MCU's pins with logic levels when its powered down and it will in fact destroy the chip.

To overcome this, I thought of adding low power Schottky diodes between the Atmega328P MCU's pins and the motor driver inputs (as shown in the image). Would this be ok or can any one recommend a better solution? I know I could use an optocoupler but I do not space on the board for placing so many of them.

enter image description here

UPDATE: This is what I'm finally thinking of doing (see image). The buffer chosen here can sustain upto +6.5V on its output terminals when powered down. I also realized that even when an external logic control is used, the board still has to be powered on for the motor drivers to work. This means that the onboard Atmega would also be powered on. However there is the possibility of the user inadvertently forgetting to power on the board before plugging in an external control source. In this case the onboard Atmega would experience 5V on its I/O pins when its powered down which obviously is not good. These buffers take care of that.

enter image description here

Best Answer

I would use a dual supply level translator such as 74LVC8T245.

As stated in the datasheet, when either VCCA or VCCB are at the GND level, both ports are at high impedance (i.e. disconnected). Therefore you can connect, say, VCCA to your ATMEGA328's VDD, so when it's powered down, no problem will occur.

You can also tristate the outputs by pulling OE high. In this way you can have your circuit automatically pulling OE high when you are connecting an external driver, to avoid contentions.

All inputs can accept 5.5V regardless the VCC voltage, and, as a bonus fact, you can also use a VCCA value different from the VCCB.