I'm totally new to Arduino though I've done a fair bit of embedded work before on PIC platforms. In my current project, I am using the Bare-bones Arduino to control 12 mosfet drivers and read from 3 analog sensors. There will be 40 of these guys daisychained on a full-duplex RS485 bus (using MAX3466 1/4UL drivers).
I have a couple of things I'd like to confirm about my hardware design, and possibly a couple of neat little tricks to share if these will work.
The bus is full-duplex, meaning one master receiver is connected to all other transmitters, and the master transmitter talks to all other receivers. Messages go through the master and have to contain an address in the packet header.
- batch programming along the 485 bus
I am hoping to do batch programming of the 40 devices by connecting the PC USB to the serial programming port on the master BB Arduino board. Since the TX/RX pins are connected to the RS485 drivers, anything that comes across to program that board, should be sent along the bus as well. I will need a DPDT switch to connect Master RX<->Slave RX and same with TX. Once programming is done I will switch back to Master TX<->Slave RX and Master RX<->Slave TX for normal bus operation. Questions:
a) Does the board talk back to the PC during programming? if not, then I will boot the boards with the 485 TX drivers disabled to avoid bus conflicts; if so, then I will connect only the Master TX to the programming cable and hope that bus delays don't cause a problem.
b) Can anyone see any reason why this won't work, or has anyone done this before?
- multitasking I/O pins
This hack came about because initially I forgot in my design about 2 things: address configuration and the RS485 TX driver enable signal, required in order to prevent conflicts on the bus. The solution I came up with is to use the digital pins as inputs during setup, with internal pull-ups on, and then switch them to outputs once addressing/config data has been read. By putting a switch to ground in series with a 4.7k resistor then into the pin, the pin will read 1 when the switch is open because of the pullup and have at worst 4.7/24.7*Vcc=0.2Vcc when the switch is closed. This is below the 0.3Vcc required to register as low on the 168 input. Once the pin switches to output, it drives the gate of a mosfet. If the config switch on that pin is closed, there will be a 4.7k resistor between gate and ground, so the only real side-effect is to draw an extra about 4.2/4.7 mA of current if the associated config switch is closed.
Does anyone see any problems with this? If people like, I can post code and schematics which show how this works (it has been successfully tested on my breadboarded version).
Thanks for the collective input/wisdom!
Rob.