Remember last post I said I was going to play with the accelerometer on my TI board? Well, I didn’t lie too much…
I decided to wire a LCD screen up to the board so I could see the data from the accelerometer in real time. That was hard enough…As this post is detailing.
That is how long it took me to realise 3.3V logic and 5V logic doesn’t play well together. Two of them.
Let’s take a few steps back and I’ll start from the start.
I wanted to play with the accelerometer on my TI board, but I like seeing what’s happening. The data in/out. What everything is doing. The awesome JFET debugger on the TI board helps a lot with that, but nothing beats a good old LCD screen showing what’s happening. So I thought, “I’ll just grab an LCD screen, hook it up and then play with the accelerometer”.
Good idea idiot.
Armed with my new 5V power supply (Which, turns out, did need the heat sink. That 7805 gets frikken hot) I set out to quickly hook up my LCD screen to my TI board.
For starters, it was a different LCD screen to the first one I had. So all the commands are different, the initialisation is different, the pins are different. After making a massive spaghetti mess of cables to connect the screen up I set out to write some code.
Enter first problem.
I don’t know how to code on TI microcontrollers. I don’t know the routines, the registers, the tips and tricks. Oh I know C syntax. I can code. But not on TI controllers. Just starting off and getting a simple code to compile and run was interesting enough. But I digress. After poking around in the example code that came with the board, I worked out how to set up the Data Direction Registers, well, the TI equivalent anyway.
I cracked out the code I used for the other LCD screen I used previously in my Bluetooth remote. The logic was useable. Had to play around with the pulsing of the enable logic for it to work on the TI compiler. Along with writing my own “delay_ms” and “delay_us” functions.
So. Technically, I have functions that should work. The wires are all connected together properly. Trust me. I had checked those wires about one hundred times.
Still nothing is working.
I couldn’t even get the LCD to initialise.
End day one.
I’ll hook the screen up to my ATmega8515 on my STK500 and see if I can get it working. Low and behold. It works. The screen initialises and prints text. (After much fiddling around and making an LCD header and source file, just for future use, I might post it up here once I have commented and cleaned it up a little.)
So what am I doing wrong on the TI board?
Move it back and try the new logic from the AVR program.
Still nothing. It’s not the contrast adjust. I play with that every time I try to get it work, tuning it to try and get some text to appear. So what the hell can it be?
Late at night after watching some Starwars, possibly episode 3, maybe 2, it dawns on me.
TI uses 3.3V logic.
End day 2.
This is damn “simple” project is now testing every part of my engineering mind, and it turns out to be a simple little thing like that? I am going to make this thing work if it kills me.
Right. Now I have established I need 5V logic for the LCD and my TI board outputs 3.3V logic, what can I use to bump it up?
A series of 7805′s? Pfft. No. That’s expensive and just silly. Also, The response time would be far too slow. Probably. I didn’t have any spare 7805′s to test it with anyway.
What I need is a way to use 3.3V to switch on 5V.
Isn’t that what transistors are for? Digital switches?(actually, they are current amplifying devices, but can be used as switches, and commonly are) Humm…. I remember playing around with this for a night. Where was that video I watched?
Right. There’s the kinda thing I need to do. How can I adapt that to work with logic? Think Phill! That’s all your mind ever does! Think!
Remember this post? It’s a switch! For logic! I’ll just replace the mechanical switch with the transistor! Genius!
A transistor array!
The actual transistors I am using are c1815. A small signal audio amplifier. Not really the most optimal for a transistor switch, but what I had with me anyway. Still works.
But hang on. This will invert the logic. This design makes the output active low with active high input. This had to be reflected in code, obviously. But if you do this hack method, remember to invert your output.
Right. Let’s get this baby working.
Look at that!
My pretty TI board and my transistor array are being nice together. After I realised I had to ground the R/W line on the LCD screen. Silly mistakes for everyone! I have enough spare!
So there you go.
After 3 and a bit days of fiddling around. I have a working 5V logic LCD screen interfacing with a 3.3V logic TI microcontroller.
Hope you enjoyed this epic post of silly mistakes. Proving, you can interface 3.3V logic with 5V logic.
EDIT: I had better point out, this is a one way logic converter. For output from the microcontroller only. You can’t read anything in from the screen using this method.
I still haven’t found my spring from my solder sucker. Curses!