From: ScadaEng on

"Paul Keinanen" <keinanen(a)sci.fi> wrote in message
news:82b616l1mbp6vfbodrvlm3jku629d6jbgm(a)4ax.com...
> On Fri, 11 Jun 2010 19:14:42 -0400, "ScadaEng"
> <scadaeng(a)optonline.net> wrote:
>
>>
>>"Bit Farmer" <bit.farmer(a)yahoo.com> wrote in message
>>news:V9-dnQM0RuB8Io_RnZ2dnUVZ_tGdnZ2d(a)giganews.com...
>>> ScadaEng wrote:
>>>> I have worked allot with RS232, and other serial protocols, but this is
>>>> my first RS485 project. It seemed straight forward to me, but now I
>>>> have
>>>> a big problem.
>>>>
>>>> I am using the max490 chip. I'm doing full duplex, 4 wire. Each of my
>>>> nodes have the max490 communicating with a 16F877A pic chip. The whole
>>>> project will have 25 nodes. I just built two pcb's (nodes) and
>>>> individually they work as expected. However when I put both of them on
>>>> the rs485 bus, I can't talk to either of them! Probably some kind of
>>>> collision, but as it turns out my scope just died and I'm on a tight
>>>> deadline. Any help is greatly appreciated.
>>>
>>> Check your output enables. You can't have both on at the same time.
>>> The
>>> system must be designed to allow only one transmitter to be on at a
>>> time.
>>> The easiest way to do this is to have the master poll each device in
>>> turn.
>>> When polled, each device can then send either a NoData packet or reply
>>> with the data that it needs to send. This approach was used for several
>>> generations of point of sale systems and works quite well. You will
>>> need
>>> to have unique addresses for each device and a means of setting them.
>>>
>>> b. Farmer
>>That's the thing, there are no output enables with the max490 chip.
>
> You can use that chip only on the master.
>
> In a "4 wire RS-485" network, the master will always have both the Tx
> as well as Rx active all the time.
>
> The slaves will always have the Rx enabled (listening for the master
> Tx pair), however, the slave Tx must only be activated, when that
> slave has been addressed and is ready to send the response to the
> master. Have you looked at e.g. MAX485, which has separate
> ReceiverEnable and DriverEnable pins, which you need for the slaves.
>
> I do not know about the PIC UART, but make sure that actually the last
> stop bit for the last byte has been transmitted out of the shift
> register, before turning off the transmitter.
>
> Some stupid UART designs such as the 14550 family generate an
> interrupt when the last byte has been loaded into the Tx shift
> register, however, you can not turn of the transmitter at time, but
> you have to wait for the last byte has actually been shifted out.
>
> For Modbus, you should actually keep the transmitter enabled for an
> additional 3.5 character times after the last data byte has actually
> been transmitted (thus sending constant Mark state), however, with a
> properly terminated line, this is not necessary as the last stop bit
> will put the line into the Mark state and the "fail-safe" termination
> will keep the line in Mark state, even if the transmitter is disabled.
>
You make a good point about the UART, I will be sure to look into the
timing. As for the new chip, I'm going to test with the max491, I am keeping
my 4 wire configuration, I don't want to change more by going two wire.
Thanks for your input.


From: Paul Keinanen on
On Fri, 11 Jun 2010 19:14:42 -0400, "ScadaEng"
<scadaeng(a)optonline.net> wrote:

>That's the thing, there are no output enables with the max490 chip. I do
>have unique addresses, and I can call each board by itself with it fully
>functioning. Its when I put more than one board on the network(485) that I
>can't commmunicate with any of them. Not that it should matter, but I am
>using a modified RTU Modbus protocol.

One dirty non-standard trick that has sometimes used in RS-232
environment _might_ work with constantly on RS-422 transmitters (such
as MAX490) on RS-485 buses.

Put a diode in series between the RS-422 output port and the RS-485
bus. Two diodes are required with opposite polarity for the Tx+ and
Tx- ports. The diode polarity must be set so that they conduct only
when Space ("0") is transmitted, but isolate the transmitter from the
bus, when Mark ("1") is transmitted.

When the transmitter is in the Idle Mark state, the bus is pulled to
the Mark state by the "fail-safe" termination resistors on the bus or
driven to Space by an other transmitter.

The diodes will reduce the noise margin by the diode voltage drop and
not be used, when making "RS-485" compliant slaves.

However, if you are in full control of both the master and slaves and
the slaves and the cables between them, you might consider this dirty
trick.

From: ScadaEng on

"Paul Keinanen" <keinanen(a)sci.fi> wrote in message
news:pun616los12l5tctnkgdhuj123dgtu6gjc(a)4ax.com...
> On Fri, 11 Jun 2010 19:14:42 -0400, "ScadaEng"
> <scadaeng(a)optonline.net> wrote:
>
>>That's the thing, there are no output enables with the max490 chip. I do
>>have unique addresses, and I can call each board by itself with it fully
>>functioning. Its when I put more than one board on the network(485) that I
>>can't commmunicate with any of them. Not that it should matter, but I am
>>using a modified RTU Modbus protocol.
>
> One dirty non-standard trick that has sometimes used in RS-232
> environment _might_ work with constantly on RS-422 transmitters (such
> as MAX490) on RS-485 buses.
>
> Put a diode in series between the RS-422 output port and the RS-485
> bus. Two diodes are required with opposite polarity for the Tx+ and
> Tx- ports. The diode polarity must be set so that they conduct only
> when Space ("0") is transmitted, but isolate the transmitter from the
> bus, when Mark ("1") is transmitted.
>
> When the transmitter is in the Idle Mark state, the bus is pulled to
> the Mark state by the "fail-safe" termination resistors on the bus or
> driven to Space by an other transmitter.
>
> The diodes will reduce the noise margin by the diode voltage drop and
> not be used, when making "RS-485" compliant slaves.
>
> However, if you are in full control of both the master and slaves and
> the slaves and the cables between them, you might consider this dirty
> trick.
>
Thanks Paul, its a neat trick. I have ordered the max489 it has the needed
enable pins and also is slew rate limited. With my low baud rate of 57.6K,
it will give me a little extra insurance of good comm. Thanks again.


From: Martin Riddle on


"ScadaEng" <scadaeng(a)optonline.net> wrote in message
news:4c135553$0$22519$607ed4bc(a)cv.net...
>
> "Paul Keinanen" <keinanen(a)sci.fi> wrote in message
> news:82b616l1mbp6vfbodrvlm3jku629d6jbgm(a)4ax.com...
>> On Fri, 11 Jun 2010 19:14:42 -0400, "ScadaEng"
>> <scadaeng(a)optonline.net> wrote:
>>
>>>
>>>"Bit Farmer" <bit.farmer(a)yahoo.com> wrote in message
>>>news:V9-dnQM0RuB8Io_RnZ2dnUVZ_tGdnZ2d(a)giganews.com...
>>>> ScadaEng wrote:
>>>>> I have worked allot with RS232, and other serial protocols, but
>>>>> this is
>>>>> my first RS485 project. It seemed straight forward to me, but now
>>>>> I have
>>>>> a big problem.
>>>>>
>>>>> I am using the max490 chip. I'm doing full duplex, 4 wire. Each of
>>>>> my
>>>>> nodes have the max490 communicating with a 16F877A pic chip. The
>>>>> whole
>>>>> project will have 25 nodes. I just built two pcb's (nodes) and
>>>>> individually they work as expected. However when I put both of
>>>>> them on
>>>>> the rs485 bus, I can't talk to either of them! Probably some kind
>>>>> of
>>>>> collision, but as it turns out my scope just died and I'm on a
>>>>> tight
>>>>> deadline. Any help is greatly appreciated.
>>>>
>>>> Check your output enables. You can't have both on at the same
>>>> time. The
>>>> system must be designed to allow only one transmitter to be on at a
>>>> time.
>>>> The easiest way to do this is to have the master poll each device
>>>> in turn.
>>>> When polled, each device can then send either a NoData packet or
>>>> reply
>>>> with the data that it needs to send. This approach was used for
>>>> several
>>>> generations of point of sale systems and works quite well. You
>>>> will need
>>>> to have unique addresses for each device and a means of setting
>>>> them.
>>>>
>>>> b. Farmer
>>>That's the thing, there are no output enables with the max490 chip.
>>
>> You can use that chip only on the master.
>>
>> In a "4 wire RS-485" network, the master will always have both the Tx
>> as well as Rx active all the time.
>>
>> The slaves will always have the Rx enabled (listening for the master
>> Tx pair), however, the slave Tx must only be activated, when that
>> slave has been addressed and is ready to send the response to the
>> master. Have you looked at e.g. MAX485, which has separate
>> ReceiverEnable and DriverEnable pins, which you need for the slaves.
>>
>> I do not know about the PIC UART, but make sure that actually the
>> last
>> stop bit for the last byte has been transmitted out of the shift
>> register, before turning off the transmitter.
>>
>> Some stupid UART designs such as the 14550 family generate an
>> interrupt when the last byte has been loaded into the Tx shift
>> register, however, you can not turn of the transmitter at time, but
>> you have to wait for the last byte has actually been shifted out.
>>
>> For Modbus, you should actually keep the transmitter enabled for an
>> additional 3.5 character times after the last data byte has actually
>> been transmitted (thus sending constant Mark state), however, with a
>> properly terminated line, this is not necessary as the last stop bit
>> will put the line into the Mark state and the "fail-safe" termination
>> will keep the line in Mark state, even if the transmitter is
>> disabled.
>>
> You make a good point about the UART, I will be sure to look into the
> timing. As for the new chip, I'm going to test with the max491, I am
> keeping my 4 wire configuration, I don't want to change more by going
> two wire. Thanks for your input.
>

On the PIC there is a bit that flips when the TX Register is Empty.
I forget if a interrupt is generated or not.

Cheers




From: Paul Keinanen on
On Sat, 12 Jun 2010 09:09:18 -0400, "Martin Riddle"
<martin_rid(a)verizon.net> wrote:

>
>
>"ScadaEng" <scadaeng(a)optonline.net> wrote in message
>news:4c135553$0$22519$607ed4bc(a)cv.net...
>>
>> "Paul Keinanen" <keinanen(a)sci.fi> wrote in message
>> news:82b616l1mbp6vfbodrvlm3jku629d6jbgm(a)4ax.com...

>>> I do not know about the PIC UART, but make sure that actually the
>>> last
>>> stop bit for the last byte has been transmitted out of the shift
>>> register, before turning off the transmitter.
>>>
>>> Some stupid UART designs such as the 14550 family generate an
>>> interrupt when the last byte has been loaded into the Tx shift
>>> register, however, you can not turn of the transmitter at time, but
>>> you have to wait for the last byte has actually been shifted out.
>>>
>>> For Modbus, you should actually keep the transmitter enabled for an
>>> additional 3.5 character times after the last data byte has actually
>>> been transmitted (thus sending constant Mark state), however, with a
>>> properly terminated line, this is not necessary as the last stop bit
>>> will put the line into the Mark state and the "fail-safe" termination
>>> will keep the line in Mark state, even if the transmitter is
>>> disabled.
>>>
>> You make a good point about the UART, I will be sure to look into the
>> timing. As for the new chip, I'm going to test with the max491, I am
>> keeping my 4 wire configuration, I don't want to change more by going
>> two wire. Thanks for your input.
>>
>
>On the PIC there is a bit that flips when the TX Register is Empty.
>I forget if a interrupt is generated or not.


The 1x550 family also has status bits for Tx Register Empty and Tx
holding Register empty, but unfortunately only the latter can be
configured to generate an interrupt, for the first, you have to poll
for the last stop bit to be sent.

Unfortunately, it is completely unacceptable in any multitasking
kernel to do a busy loop to poll a status register for 0.1 to 10 ms
(115k2 .. 1k2) to find the end of a character, if proper interrupts
are not available.

One way to avoid this on a _2-wire_ RS-485 system is to enable the
receiver during your own transmit and when processing the TRx
interrupt from the last character echoed, turn off the Tx Enable pin.

This method is not generally available for 4 wire RS-485 networks, so
you have to poll the Tx status register in a busy loop, unless a
proper interrupt is available.