Sunday, March 18, 2012

Micro controller Networking - UART to SPI bridge

There are many parts used in embedded systems.In most cases,we have to transfer data between these components.In this tutorial we're going to look how to receive data from UART module in a PIC micro and transfer those data to another component using SPI module.Using this method we can transfer single input to multiple receivers because we can use more than one component in SPI.

In here,PIC16F887 micro controller is used as the UART receiver and it'll send the received data via it's SPI module.MikroC PRO is used for the writing the firmware.You can download the FREE(with some limitations) version from,

MikroC PRO Download Page

This is the code used.First we initialize UART module to work at 9600bps.
Then we initialize SPI module.Then the code is to check whether there is data coming to UART module and if so,just relay them to SPI module.The last line will send received data again to another UART receiver via UART Tx pin.

You can find more info on these modules form MikroC knowledge base.

SPI Library

UART Library

void main() {
char receive;
if (UART1_Data_Ready() == 1) {
receive = UART1_Read();

Circuit with PIC16F887 Slave with this PIC16F887 Master:(Click on image to get high resolution schematic)

In the next post,we'll build a simple motor controller slave with this :D

Wednesday, March 7, 2012

Homemade USB LC Meter

I wanted to have a LC meter for a long time.Specially when working with oscillators and stuff,they are really useful.After some research on internet I found this great site by YUS.He had designed a USB LC meter using PIC18F2550.As I had a PIC18F2550 development board with me,I decided to test it on a piece of vero board.

YUS's post including Schematic diagram and Software

But after i downloaded HEX file and tried to program it with my Pickit2,I found that there are no config words included on this HEX file.So,I guessed them by my knowledge on PIC18F2550 and they worked well in the first try.I disabled MCLR too in this and you can build the circuit without R7(4.7k).I've also replace 2N7002(SMD) with a 2N7000(Through hole) because I only had that.
Here are the config words:

Here are some photos of measuring 150pF capacitor and a 100uH inductor shown below.

Finally this is my LC meter circuit on a piece of vero board.
It did only cost me less than US$ 0.50 for this part :)

This is my PIC18F2550 development board on a veroboard.
It did only cost me around US$ 1.00 for this part without PIC18F2550 :)

Finally I must say "Thank you YUS for your great design on this" :D