Looking at the signal ranges I'm not sure if I can use a CAN transceiver (not controller!) to send data to a single RS485 device.
CAN – Using CAN Transceiver to Send RS485 Data
canrs485
Related Solutions
As noted, typical baud rates will flash the LED at rates which are invisible to the eye.
The visual effect that you want can be obtained by adding either some form of triggered oscillator or some form of "monostable" or (most elegantly) by using a microcontroller to control the flashing and decision making.
A single Schmitt trigger gate in a tiny package would do the job. Probably a SOT23-6 package.
While using a microcontroller may seem like bizarre overkill (and probably is :-) ) it also allows a minimum parts count solution, small size, great flexibility, addition of other features if desired AND immense Cool! value.
A device such as a PIC10F200 in stock at digikey for 56 cents in 1's would do your job with NO extra parts apart from the LED, or perhaps one resistor if you wanted to be "proper". I chose that for it's lowest cost in 1's in a small package - but you can get cheaper.
If this is a one off job there will be people willing to write a program for you for free AND program you a chip, just for the sheer joy of the stupidity of such overkill.
Packages include DFN (2mmj x 3mm leadless smd), SOT23-6 (2.3 x 3.1mm worst case outside leads) and DIP.
Schmitt trigger inverter based flasher:
The diagram below is from fig 14 in 74HC14 data sheet here
This will drive an LED or a second gate can be used as a buffer.
To gate this on and off a diode is connected to the gate input.
Gate package 74HC14 or equivalent.
Resistor R gate_in to gate_out (eg pin 2 to pin3) say 100k
Capacitor gate in to ground - say 1 uF ceramic
Diode RS485 line to gate in (polarity tbd - see below)
LED with series resistor from gate out either to Vcc or ground with appropriate polarity OT
gate_out to gate2_in. gate2_out to drive LED via series R as before. Gate 2 here acts as a buffer.
This will oscillate at ABOUT 10 Hz with values given (12.5 Hz according to their formula) when the diode is reverse biased. It will stop oscillating when the diode conducts. Connect diode to RS485 line with connection and polarity to suit.
The state that the gate is "stalled" in controls whether the LED is on or off when not flashing.
Note to compulsive editors: anyone who wants to add an enabling diode and LED with series R is welcome.
RS485 is a multidrop bus, which means that a number of nodes are connected to the same bus and, in this case, they all have the potential to "talk" at the same time. For a device to take control of the bus and be able to talk, the RS485 transceiver (in your case the MAX3160) has to have its transmit enable pin be enabled. All the other devices on the bus need to have them disabled. If more than one device is enabled to transmit, data can become garbled because one device might be trying to drive the bus in one state and another device trying to drive the bus in a different state.
You enable the device to take control of the bus by setting the DE pin high. Once it is high, anything on the DI pin is transmitted on to the bus. It is important to note that all other devices on the bus should have their DE pins low.
The other enable pin on the transceiver is usually called the ~RE pin. Note that this is low for anything on the bus to be reflected on the RO pin. That looks like it's the R1OUT on your Max device.
A lot of the time, you see the ~RE and DE pins connected together and to a GPIO on the micro. This GPIO determines whether you are listening to what other nodes on the bus are saying or talking on the bus yourself.
All this is not to be confused with flow control which is often used on devices such as modems that are relatively dumb and have relatively small data buffers. This is a method of each device saying it is ready to send more data out or ready to receive data in. This can be done in hardware with RTS/CTS pins and can also be done in software with XON/OFF messages. There are lots of good resources on line that explain this very well and I still dip in and out of these every now and again because it can get confusing!
It's probably worth noting that there are various methods of deciding who is allowed to talk on the bus at any one time. There always needs to be a method of knowing who is the one master at any one moment in time.
So, to listen on the bus, ensure ~RE (R1OUT) and DE are low. To transmit on to the bus, DE should be high. If ~RE is high at the same time, you will not get what is being transmitted, send back to the Rx pin of the UART on your micro.
Related Topic
- Electronic – How does “RS485 Pi” 2-wire transceiver connection work
- Electronic – Where to use CAN v RS485
- Electronic – Put RS485 microcontroller and transceiver to sleep and wake it up on incoming data
- CAN Transceiver – Understanding Current Draw in Embedded Systems
- Electronic – Glitching on UART RX line with RS485 transceiver
- RS485 – Is It OK to Use Separate Wires for Each Device?
Best Answer
In the CAN recessive state, the differential voltage can be zero. This is not a valid RS-485 signal level.
However, many RS-485 receivers have built-in fail-safe logic that interprets an undriven bus as logic one, and a bus without such logic is supposed to have fail-safe biasing resistors with the same effect. So if you wire the bus so that the CAN dominant state (CANH > CANL) corresponds to RS-485 logical zero (A < B), then it might actually work.