RS232 Master Slave Setup

Forum for problems or queries regarding Flowcode Comms Components. Eg LIN, I2C, SPI, RS232, CAN, IrDA etc

Moderators: Benj, Mods

Post Reply
Cris
Posts: 16
Joined: Sun Nov 02, 2008 7:25 pm
Contact:

RS232 Master Slave Setup

Post by Cris »

Hello,
I’m not good at programming yet but working on it, that’s why I bought FlowCode v3 hoping it could do it all. But as I found out after using it for a while and checking the posts it turns out that it has limited RS232 capabilities. I learned it was mainly setup to program a master chip to communicate with Eblocks. I am trying to set up a simple program where I can remotely dim four lamps using PWM on two slave chips controlled from one master via RS232. I’m using three 16F877A IP chips each with their own 20MHZ crystals, setup – HS. WD timer off. I have checked the data sheets regarding addressable RS232 TX and RX bits but I am not clear on how to put it in my flow chart. I’ve tried various ways using the component macros and calculation boxes keeping in mind some of the examples found on the web site and in the forums but never saw anything that was exactly the same set up I’m trying to do, just bitts and pieces of other good things. I tried some string manipulation stuff as well but no luck. I’m doing the tests using three breadboards with direct connections and no Max CPE chip at this point. I think I’m having framing or data shifting issues. Some times it seems to work for a vary short time then the data gets crossed up or become intermittent. I’m using the same variable names in all the chips? I have uploaded the fcd. files In hopes that someone can shed some light on my problem. Any help would be appreciated, Thanks guys

Cris
Attachments
LAMP DIM SLAVE 2.fcf
(5.5 KiB) Downloaded 337 times
LAMP DIM SLAVE 1.fcf
(5.5 KiB) Downloaded 339 times
LAMP DIM MASTER.fcf
(7.5 KiB) Downloaded 351 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: RS232 Master Slave Setup

Post by Benj »

Hello

I have had problems with this in the past. Are you commoning the grounds between each of your devices. This was the step that I missed when getting UART devices talking in a Master / Slave setup.

User avatar
Dan81
Valued Contributor
Valued Contributor
Posts: 268
Joined: Sun Jan 15, 2006 4:07 pm
Location: Albi France
Been thanked: 60 times
Contact:

Re: RS232 Master Slave Setup

Post by Dan81 »

Hello

I think the problem is that your 3 boards are not synchronised and your "slave" delays are too long.

I've modifed the value of LAMP_x in order to differentiate the first from the other three.

The "Slave" flowchart can be almost the same for the two slave boards.

Don't send 255, it's a special value to indicate that there is no reception (see RS232 help within Flowcode).


The Flowcharts are not fully tested but I think they're quite good


Daniel
DIM SLAVE-mod.fcf
(5.5 KiB) Downloaded 392 times
DIM MASTER_mod.fcf
(7 KiB) Downloaded 386 times

Cris
Posts: 16
Joined: Sun Nov 02, 2008 7:25 pm
Contact:

Re: RS232 Master Slave Setup

Post by Cris »

Thanks for your input guys!, Daniel I appreciate the time you spent making changes to the fcd files. I’m using one of my 3 breadboards for another project at the moment but I did test the master and one slave as uploaded, and It seems to work like a charm, great!. I’m going to look at the additions and changes more closely to see how and why they work and try to adapt it for the slave 2 chip. But one thing I can see and I never thought of, was letting all the data filter through the programs on each chip and filtering out the variables in the programs themselves and not worrying about trying to address and send data to each individual chip. I’m going to try and get some time this weekend to give it a go. Also Ben makes a good point on bonding the grounds together, I can see that would be important, and I did have a common ground as the whole setup was fed from one supply daisy chained together. Again thanks for all your help guys and hopefully I’ll be ok from here.

Cris :P

Post Reply