RS485 half-duplex ideas?
annuello
Posts: 294
Hello all,
The context is with a lighting system (RS485 half-duplex) that seems to send out a "heartbeat" on the bus every 0.7 seconds, as well as additional data at irregular intervals. Up until now I have just send my strings to the bus regardless of whether another device is currently using the bus. I believe (though I can not confim) that some of my commands are creating collisions and as a result, are not being performed. All data from the lighting system is currently ignored.
I'm looking for ideas & suggestions on how to safely code for half-duplex RS485 busses. My initial guess is to set up a receive buffer that, when data is received, a "bus in use" flag is set, then cleared 0.1sec later. My code would then wait until the flag is cleared before sending data. Is this a good approach, or is there a more effecient way to handle the situation? Both Axcess & Netlinx ideas are welcome. I'm currently using an Axcent3, though it will be upgraded to an NI-700+Axcent3_slave in 12 months time.
Annuello.
The context is with a lighting system (RS485 half-duplex) that seems to send out a "heartbeat" on the bus every 0.7 seconds, as well as additional data at irregular intervals. Up until now I have just send my strings to the bus regardless of whether another device is currently using the bus. I believe (though I can not confim) that some of my commands are creating collisions and as a result, are not being performed. All data from the lighting system is currently ignored.
I'm looking for ideas & suggestions on how to safely code for half-duplex RS485 busses. My initial guess is to set up a receive buffer that, when data is received, a "bus in use" flag is set, then cleared 0.1sec later. My code would then wait until the flag is cleared before sending data. Is this a good approach, or is there a more effecient way to handle the situation? Both Axcess & Netlinx ideas are welcome. I'm currently using an Axcent3, though it will be upgraded to an NI-700+Axcent3_slave in 12 months time.
Annuello.
0
Comments
I would guess your lighting system is one of the latter two. I don't see any downside in waiting for the buss to settle, even if the rest of the devices do not - unless the buss is so chatty it never actually settles. But that is the route I would take. You could do it in Axcess by setting a flag in a named wait when you see activity on the buss. Any further activity would have to reset the wait (cancel it and restart) and the flag. When your wait times out without being reset, your flag drops and you can send. If your "master" on the lighting system doesn't acknowledge your data, you may want to send everything a few times to make sure it gets through.
It occurs to me that I have seen yet another way of managing 485 - where all the devices monitor the line and send their data sequentially. In other words, device 3 holds it's data until it sees device 2 report, unless a timeout occurs, whereupon it sends anyway. I believe this is how the Viewstat thermostats operate.
It's nice to know that I was on the right track.
Annuello.