Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 30th May 2004, 11:03 AM   (permalink)
Default reg 16f877

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?
yagna is offline  
Old 30th May 2004, 12:22 PM   (permalink)
Default

Can't you send var1/2/3 then again var1/2/3 of the next set - so on and so forth?
__________________
"Ambition is the last refuge of failure..." --Oscar Wilde
"Success is not final, failure is not fatal: it is the courage to continue that counts." -- Winston Churchill
bsodmike is offline  
Old 30th May 2004, 02:00 PM   (permalink)
Default reg 16f877

i would be sending/controlling the variables randomly. Its not sequential.
its like controlling the pressure, volume and flow.
hope u understood.
yagna is offline  
Old 30th May 2004, 03:13 PM   (permalink)
Default Re: reg 16f877

Quote:
Originally Posted by yagna
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.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 04:54 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker