RS232 Master and Multiple Slaves

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

Post Reply
medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

RS232 Master and Multiple Slaves

Post by medelec35 »

I am creating a RS232 master and multiple RS232 slave arrangement.
Reason for this is so you can use microcontrollers which do not have RS232,SPI CAN etc. built in.
This project is on going, and I all be adding to it until it's finished.
one application I will be working on is to use several 8 pin microcontrollers, each will be a RS232 Slave, and control the port value via master.
As a starting point, here are two slaves. Ch1 and Ch2. It can be set up for software or UART control.
All commands and numbers are 3 digits long.
Slaves are enabled by #xx
xx=Salve number.
E.g
If you have three slaves, then to enable slave1 send #01 via RS232
Slave2 send #02
Slave3 send #03
Suppose I want port of:
slave1 = 31
slave2 = 24
slave3 = 5
I will have to send following chars:
#01031#02024#03005
When the above chars sent, then all three ports will stay at correct value.
To Clear port of slave1 just send #01000

If a slave is enabled, you do not need to resend #xx
so to make slave1 count up in ones send:
#01
001
002
003
004
etc
The port connected to other slaves will not be affected.

Reason for using # is so I can set the master up to transmit via Rs232 when receive commands form PC, String or keypad.
This has not been tested on real hardware, since It is only my theory.
If someone is interested in this application and wants to test the theory out, then letting be know the results is the only thing I ask for.
I have included two slaves, so you can see how each one requires configuring.

Master to follow, but you could use RS232 via hyperterminal with PC

Note: using 16F88 only porta 0 to 4 can be an output. So for that target device, max number is only 31
Attachments
RS232_Slave_Ch2.fcf
(11.5 KiB) Downloaded 431 times
RS232_Slave_Ch1.fcf
(11.5 KiB) Downloaded 410 times
Martin

Post Reply