RS232 to RS485

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
User avatar
jollybv
Flowcode v5 User
Posts: 360
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Contact:

RS232 to RS485

Post by jollybv »

Hi Guys

I need to use RS485 to communicate between to PIC's (PIC16f887 & PIC16f886) as I'm new to all this I was wondering has anyone got a diagram and some sample cod to help me get started as i really don't have a clue where to start

Brian :?

User avatar
Benj
Matrix Staff
Posts: 14851
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: RS232 to RS485

Post by Benj »

Hello Brian,

This article may help.

http://www.matrixmultimedia.com/article.php?a=419

User avatar
jollybv
Flowcode v5 User
Posts: 360
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Contact:

Re: RS232 to RS485

Post by jollybv »

Thanks Ben i will have a look

:D

User avatar
jollybv
Flowcode v5 User
Posts: 360
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Contact:

Re: RS232 to RS485

Post by jollybv »

Hi Guys

I'm really confused I am trying to send data Via RS485 but no luck I downloaded the examples and have written a small test program to see how it works but i cannot get it to work could you please have a look and tell me where I'm going wrong. I only need to send data from the master to the slave. what I really don't understand it the slave node (Node address 9th bit) and how you get it. You send 0x 101 from the master node and receive it in the slave node (RxVal AND 100) the result is 100 should this not be a 1 for the decision to be made :? :?
Master node test.fcf
(37.99 KiB) Downloaded 168 times
Slave node test.fcf
(12.5 KiB) Downloaded 170 times

User avatar
Benj
Matrix Staff
Posts: 14851
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: RS232 to RS485

Post by Benj »

Hello Jolly,

In both your programs you had the RS232 component set to 8bit data mode. I have changed this in both the programs so hopefully the origram should work correctly on your hardware now. Let me know how you get on.
Master node test.fcf
(37.99 KiB) Downloaded 216 times
Slave node test.fcf
(12.5 KiB) Downloaded 197 times

User avatar
jollybv
Flowcode v5 User
Posts: 360
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Contact:

Re: RS232 to RS485

Post by jollybv »

Hi Benj

Thanks for the reply I did notice that they were set to 8 bit mode and did change them to 9 bit but still doing the same in the simulation when I send a 0x101 (100000001) then data (123) from the master node, on the slave i get *123 but it just sits in a loop and dose nothing what am I doing wrong. I amuse that the * char is the 0x101(RxVal) and should be AND with 0x100 and the result must be a 1 so that the decision icon is yes but when i AND the 101 with 100 the answer is 100 not 1. Please help this is driving me mad :x

Brian

User avatar
Benj
Matrix Staff
Posts: 14851
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: RS232 to RS485

Post by Benj »

Hi Brian,

You can use this in a decision icon to see if the most significant bit is set.

rxval & 0x100

If you need the result to be 1 then you need to do this.

(rxval & 0x100) >> 8

User avatar
jollybv
Flowcode v5 User
Posts: 360
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Contact:

Re: RS232 to RS485

Post by jollybv »

Hi Benj

Thanks I will try it..!! I just want to ask if I upgrade to V5 will the RS484 sort my problem out of not understanding how to send data..??

Brian

User avatar
jollybv
Flowcode v5 User
Posts: 360
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Contact:

Re: RS232 to RS485

Post by jollybv »

Hey Guys
I need help I am so lost with this RS232/485 My boards are working with the RS232 but when I connect the Max485 chip onto it it dose not work i have connected pins 2 & 3 together and to RB7 then pins 1 & 4 go to the Rx & TX of the chip i then pull RB7 high in the software and send the same string that i was sending when it was connected as RS232. On the receiving side I connect RC5 to Pins 2 & 3 and this is pulled low. I have set up some LED's to flash when it goes into the various macros I am getting some sort of data sent but it is not always right. What I don't understand is that it is working right in the simulation but not on the boards.

I can honestly say i have no idea how this RS485 is supposed to work :evil:

Please can someone help me as I have potential orders for my product but now this software problem is holding me back :?: :?:

I have noticed one thing I can send the the first and second string then i get a Char 255 a Y with 2 dots on top and then nothing works. I might need to clear something but i do not know what.

Post Reply