View Full Version : Serial Communication with the 8051

10-21-2005, 12:57 PM

I'm planning on making a rover using the 8051. I want to control it using RF . I have the RF modules - transmitter and receiver. I need to know how to couple these the 8051 so that I may be able to go fwd , reverse , rt. tune and left turn.

Another thing - before using the microcontroller I was planning to use the Holtek 12E and 12d encoder decoder chipe - but they have only 4 outputs. I need more - and PWM control of the motors - hence the uC. What I also need to know is how can I use the uC to ensure that the Rf data received is not erroneous.

Please guide. Thanks

10-21-2005, 01:28 PM
Why do you need the 8051 at all?? :?:

10-21-2005, 05:40 PM
Hi Docel!

If you are asking why use a microcontroller at all than my answer is:

For more O/P pins - i plan to add a camera, promixity sensors etc at a later stage. I figure that it would be a lot easier for me to upgrade my rover if I'm using a uC. Secondly for PWM speed control of the driving motor/s.

If you are asking why the 8051 in particular, in that case the reason is :

That is the onley uC then I have some knowlwdge about, since I have been studying a few books on the 8051 which i picked up some months ago - so want to use the theoretical knowledge that I have picked up.


10-21-2005, 07:51 PM

It seems that you have done good background study and search.

You need to connect the RF receiver-data-out to serial-RX pin of the MCU.
and the transmitter to the serial out of your PC.
and eventually your PC will send commands (either by hyperterminal, or by VB code) to the MCU.

**However, before attaching RF modules simply control the robot using direct wire serial link.**(else you wont be able to figure if its a problem due to RF or your control code)

keep baud-rate low (about 300-600 ) in begining when using the RF.

Now make your own command protocol to notify the MCU what kind of command you wish to send - an example of 2byte command protocol -

0xCA 0xYY -- Forward, with PWM speed YY (both motors run FWD)
0xC2 0xYY --- Left motor with speed YY
0xC8 0xYY -- right
0xC5 0xYY -- reverse with speed YY
...and so on

for Error correction you can add a third-byte which could contain the turncated checks-sum of the first 2 bytes. The MCU reads the 3 bytes, and then cross-checks the sum. if its not valid, it rejects the command.

This is just a pointer. You may wish to form complex data-packets of fixed number of bytes, more checksum/CRC error detection etc.
However, keep the data small, as RF speeds are low unless you at using GHz range RF

Moreover, before "starting" the stream your RF data, always send a few 0xAAAFFF1 or similar type data which helps the PLL of RF modules to sync.
the MCU should igonore this data and will wait for a particular start headrer byte/s decided by you.

I did not ask what kind of RF modules you have, because I am assuming you have bought the right ones after enough internet search.


10-23-2005, 05:46 PM
Thanks a ton Vivek!

But does this mean that I will not be anle to use the Holtek encoders since I need to make my own error detection code? I would have liked to emulate the deocding of the 12D using the 8051. Is that possible?