Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

reg 16f877

Status
Not open for further replies.

yagna

New Member
hi, i am designing a circuit using pic16f877. i am controlling an instrument by a computer and using pic as the controller. Now i need to control 3 variables from the computer. And the resolution is 8 bit. i am sending the data from the computer through rs232 to the pic. i cant understand how to send 3 variables , but i know how to send 2 variables. since the pic can take a data of max 9 bit. i hope u all understood the problem.
kindly give me some tips or ideas?
 
Can't you send var1/2/3 then again var1/2/3 of the next set - so on and so forth?
 
i would be sending/controlling the variables randomly. Its not sequential.
its like controlling the pressure, volume and flow.
hope u understood.
 
yagna said:
i would be sending/controlling the variables randomly. Its not sequential.
its like controlling the pressure, volume and flow.
hope u understood.

You simply need to send more bytes, presumably this isn't speed critical at all - or you wouldn't be allowing random intervals. The main problem with sending 8 bit binary data, is that the value can be anything from 0-255, obviously!. This means you can't send a start of data and end of data byte, before and after the data, because the data itself may have the same value as the control bytes.

There are a great many different ways you could do it, one simple one would be two split each data byte into two 4 bit nibbles, shifting the upper nibble down into the lower half of the second data byte. Then in the upper half of the nibbles add a code to signify which half of which data input it is.

For example:

Pressure 1000LLLL - low half of pressure
Pressure 1001HHH - high half of pressure

Volume 1010LLLL - low half of volume
Volume 1011HHH - high half of volume

And so on.

This allows 8 different data bytes to be sent as double bytes of data, with each one being individually identified. Simply reassemble the bytes in the receiver software.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top