# Interfacing a PIC microcontroller to different logic levels

I'm planning on interfacing a PIC microcontroller to two devices which operate on two different logic levels and I'm wondering what the best way of approaching this is. I'm rather inexperienced in this area and was hoping to get some ideas on the matter and clarify a few points.

The problem is that the logic level for the PIC is TTL logic; 0 = 0v, 1 = 5v and the logic levels for the other two devices are 0 = -6v, 1 = - 6v and 0 = 0v and 1 = 10v.

I was planning on using a max232 to provide a conversion to -10v/10v logic and using a voltage divider on the output to provide the -6v/6v logic. Could this approach cause any potential problems with the signal conditioning?

For interfacing to the 10v logic level I was planning on using the 10v rail created by the max232 and somehow switching this to ground using the PIC. Is this a reasonable solution or is there a more elegant approach? Any pointers or factors I should consider would also be much appreciated!

## 1 Answer

You seem to have a typo, as you don't have a -10V off in your problem.

In any case, if you look at the max232 datasheet, you'll notice that it's inverting- i.e., a 1 in will give you a 0 out. Check your devices to make sure they aren't expecting the inverted logic. If they both are, or both aren't, you can deal with this. If one is and one isn't, you have an issue.

In general, I don't like using voltage division to do level conversions, because if the device starts sucking or sourcing current the voltage you've so carefully calculated changes. In most cases you won't have a problem, but you do need to keep track of things. For example, if you were trying to light an LED with your voltage divider, your voltage would fall with the LED on, and how much it fell would depend on the values of your resistors. If you see troubles like this coming, simple transistor circuits can easily handle your level conversions. That's assuming, of course, that all your signals are one-way. Whole different ball of wax for bidirectional lines.