This morning I decided its about time I learnt how to use the UART hardware in most PIC microcontrollers. I started off with a USB-RS-232 converter that I got for US$3 from DealExtreme. There are a few reasons why I used a converter, firstly being because my main PC no longer has an RS-232 port since its old tech, but also because I thought it’d be alot neater for my projects to have a USB connection and it means I can interface with TTL signal levels (0-5v) instead of the RS-232 standards -12v – +12v which would have added complications, but we’ll get back to that just now…
The USB-Serial adapter from Dealextreme, the Bottom one has been modded to remove the DB9 connector and the MAX211 IC as well as adding connections to the TTL TX, RX and Gnd
(sorry about the pics again, using my phone, camera isn’t back yet ๐ )
I Started by removing the MAX211 IC which takes the PL-2303 (the usb-serial IC) TTL level signals and converts them to -12v – 12v and vice versa. Since we will be interfacing with a TTL level part, the 16F88, this is no longer needed. I also removed the DB9 connector because it was getting in the way and I’m not going to use it anyway ๐ Also added wires to the TXD, RXD and Gnd pads so I can connect it to my breadboard ๐
Next I connected TX and RX together for a loop-back test to make sure everything is still working:
Everything seems to be working well! So onto the microcontroller side of things..
I’m currently using MPLAB and the Hi-Tech C compiler after recently teaching myself C for microcontrollers (this is another complicated topic without many easy beginner tutorials, you just sorta have to jump and and google your way to success! perhaps one-day I’ll write a post about it… ๐ ) and an ICD2 to program. Luckily in the Hi-Tech samples folder there is a USART example! this made life alot easier… here it is:
A nice simple sample program to echo the users keypress’s
I quickly burnt it onto the 16F88, connected the usb-serial dongle and fired up the Termite, pressed some keys and couldn’t believe my luck! ๐
Bi-directional serial communication with my PIC 16F88!!! I thought this would be really difficult but it turned out to be easier than expected ๐
What are the next steps? We’ll I recently completed a simple automated irrigation system for my vegitable patch, which I’ll document soon in another post, and I would like to have it communicating with a small C# app on my server PC that will have a web interface such that I can set watering times and dates ๐ I have some other project ideas I’d like to try out aswell like servo controlled blinds and an automated coffee machine ๐ ๐
Hope you enjoyed my ramblings! until next time ๐
~Rob.
Leave a Reply