Page 1 of 1

The best way of sending Serial Data?

Posted: Sun Jul 21, 2013 1:42 am
by Jordy101091
Hi all,

I'm finally graduated from school 8), and back from vacation :? .
So I have plenty of time to work on all kinds of electronic projects :wink:.

I want to know how you guys are transmitting you data over a serial bus like RS232 / RS485.
What I'm planning to do is build a system where you would have a base unit and from there on you can hook up all kinds of accessories.
I want to make this plug - and - play where the base unit (master) will automatically detect the new connect device.

for instance:

You have the base unit (Master) and there are 2 (or more) slaves connected

Slave one.= Temperature sensor
Slave two.= Hydro Sensor

What is the best and most robust way of sending and retrieving data from these slaves.
I want to hear what you think of this and how would solve this.

Regards Jordy

Re: The best way of sending Serial Data?

Posted: Sun Jul 21, 2013 8:29 am
by JohnCrow
Hi Jordy

Congratulaions on passing the exams.

Re: The best way of sending Serial Data?

Posted: Sun Jul 21, 2013 9:25 am
by Jordy101091
JohnCrow wrote:Hi Jordy

Congratulaions on passing the exams.
Thanks,

I can call myself now a electrical engineer :wink:

Regards jordy

Re: The best way of sending Serial Data?

Posted: Sun Jul 21, 2013 5:25 pm
by brandonb
i didn't have anything on computer so i wrote this up for you as an example :wink:
when using rs232 uart the slave tx lines will short is more than one is hooked to same chip pin, what i do is use a multiplexer chip, like this, it takes two uart tx lines and outputs one signal
pro_dash_mux.fcf
(12.7 KiB) Downloaded 319 times
, if you rig this up to a 16f1829 you have 10 port interrupts so can mux 10 tx lines into one, the timing from the master to get the signals is critical to keep everything in synch
here is the one's i drew up this morning, this is the master
mini28 uart pwm send.fcf
(19.89 KiB) Downloaded 348 times
this is the slave
mini44 uart pwm receive.fcf
(25.73 KiB) Downloaded 330 times
the way this works is, its a simple draw up, the master chip is just a rc5 remote control acting like a keypad, when i input a number i can press a button to send it, when i do send it the keypad number returns back to zero, there is another key that also returns the value to zero incase when inputting data a digit gets missed, when you select to send the data thats on the screen it sends the number 0-511 out on the 9 bit uart tx
the slave chip is programmed only to respond to the address of 501!!!
what this does is it controls 5 pwms on the slave chip
the addresses are 501 to 511 so can have 10 chips on uart line,
its programmed to where it wont do anything unless a number 501-511 is received
when it is received it is locked on that slave chip and you won't have to enter the address again unless you want to talk to another slave, you can send a pwm address 300-304 which controls pwm#s 0-4
after that is sent you just send number 0-100 to control the dutycyle on the selected pwm module
you can also get the value from any of the pwms 0-4 by sending 400-404, it will return the dutycyle for that pwm on the screen
notice when in the pwm mode you don't have to keep sending the command for that pwm or for the chip address because its designed to be locked in until you changed it
you can see that its really easy to create a touch screen program that can control many chips with all kinds of functionallity with this approch
can make it when you ask for a certain pwm% you can increment it from there but i didn't put that functionallity into it yet on this one
did this help you out?

Re: The best way of sending Serial Data?

Posted: Sun Jul 21, 2013 6:28 pm
by kersing
Basically RS232 is for communication between two devices. There are work-arounds with multiplexers etc. RS485 is a multi device bus, so probably the better option.

When attaching new devices to the bus they must somehow signal the master there is a new device, so you will need to design a protocol to handle that. Also RS485 is a half duplex bus allowing multiple masters but without collision detection, so you'll need to keep that in mind while designing the protocol as well :-)

You might want to take a look the elektor bus.

Re: The best way of sending Serial Data?

Posted: Sun Jul 21, 2013 7:05 pm
by brandonb
kersing, can you explain how to convert to rs485 without buying boards?

Re: The best way of sending Serial Data?

Posted: Sun Jul 21, 2013 9:07 pm
by kersing
brandonb wrote:kersing, can you explain how to convert to rs485 without buying boards?
Have you checked the elektor site? The item numbered 6 has a freely down-loadable diagram (registration required) using the LT1785. The data sheet for it has some typical application examples as well.

Re: The best way of sending Serial Data?

Posted: Sun Jul 21, 2013 9:09 pm
by kersing
Also you could take a look at the data sheet for EB062 and build the circuit yourself...

Re: The best way of sending Serial Data?

Posted: Mon Jul 22, 2013 6:25 pm
by Jordy101091
Oke I have search the internet for a possible solution, and I think I found it,so I thought.
I came across the following bus CAN.

Everywhere I look on the internet people are saying that CAN bus is the most easiest bus of all to work with.
When I investigate the macros provided with Flowcode a little more it doesn't seem so easy anymore.

I hope somebody can explain how it works because I do not understand what all the buffers, IDs ect mean.

Regards Jordy

Re: The best way of sending Serial Data?

Posted: Mon Jul 22, 2013 9:21 pm
by dazz
Hi Jordy
have a look at the attached doc, it should help

Regards
Dazz