Hi, I’ve just got a huge job that will involve a massive PCB, The G120 will be excellent for the front end display/networking etc. but there are time critical elements to the project as well. So I’m thinking of a PCB that will require a single G120 and up to 8 G30’s. It’s totally insane right! I’ve not got the slightest clue yet how I would do it. There are no size constraints so I might even use the G30 through hole modules. At least I can remove them if I need to update the software then. I had a crazy idea that I might be able to deploy to the G30’s over UART through the G120, since all the G30’s would use the same software, would that even be possible. Then I could use IFU for the whole board.
What would be the best for all of the chips to communicate, CAN? If I were to use CAN, I would need to use both interfaces on the G120, because there will be 10 of these large boards on another CAN network as well. So I would kind of need an internal and external CAN interface. Maybe something other than CAN, although I really need 2-way communication. Has anyone done anything like this before, suggestions?
There are a lot of questions here, huge thanks in advance.
UART would be nice for Point to Point communication, but G120 only has 5 UART’S I think.
CAN would be good, but you need CAN transceiver on both sides, since you can not connect them on TTL Level, and I’m not sure if G30 supports CAN.
And why do you need 8 G30’s what do you want to do with them?
Also when you write time critical:
You might consider using Native micros, like some XMega or whatever, … In NETMF you always have to fear that GC will Interrupt you.
How complex is the thing, the G30s have to do? Maybe a small ATtiny/ATMega or something is enough, they could comunicate via I2C or SPI plus an interrupt to tell the G120 they have data for him. Is the whole thing time-critical or just single functions? Maybe RLP is enough?
Just some thoughts, as I can’t imagine what you exactly want to do :)…
The g30’s need to monitor analogs, do complex math, monitor interrupts drive half a dozen outputs each. The communication doesn’t have to be quick either and could be instigated by the g120. Could I use a single UART from the g120 to every g30, and use some gpios to act as a type of chip select.
I’m assuming that I can switch the g30’s com port pins that aren’t selected, to high z so that they don’t effect communication on the lines.
Don’t think you can put the driver into a high impedance state whilst the UART is active. Why not just add a low cost RS485 driver IC and then you have multi-drop that just works. The MAX13487 does the auto transmission so no need for any GPIO pin to control the tx. Only downside is that it is only available in 5V versions only.
I’ve got no exp with RS485, from what I can tell it is similar to CAN, but everywhere says that it doesn’t have collision detection, but that this can be done in software. Is this correct? and if so, is it hard to write software to detect collisions. I guess I could just use the g120’s as a type of master on the bus, and set the g30’s to only spit out data on request. right?
Correct. The RS485 bus with a UART is a master-slave type so you need a master to request the data from the slaves. A ready made protocol for this that just works is Modbus. The Modbus driver in Codeshare almost works with UART but has an issue when more than 1 device is present due to the fact it can’t handle devices that respond too quickly. If all your devices on the bus are NETMF based this should not be an issue. I posted a fix to improve the code. It will make your design so much quicker to develop if you have the code space to use it.
If you have a Auto select Driver like the MAX Dave mentioned, then RS485 works nearly exact as RS232.
The only difference ist: Only one device must send at any time. All devices will see the sent data.
So you need to use a protocoll that includes the device address.
Modbus provides this, and MODBUS RTU is specifically designed for RS485.
If you use a Driver without Auto select, you Need one GPIO to Switch between read and write.
My MODBUS Library on Code share can handle all of this and is used in an industrial application by me. https://www.ghielectronics.com/community/codeshare/entry/880
Pleas don’t expect it to be perfect, but it’s working verry well for me.
Just a quick note when it comes to using 485. I’ve used the GHI 485 module now several times in the past, and the one thing I’ve noticed, is that if you loose power to the Processer & 485 board, it will pull down the entire network of 485 devices. Basically was eavesdropping on the network for logging purposes, and ended up switching to RS232 via a RS485 radio link, simply for isolation to avoid this problem as everything I do has to fail safe to a known state.
I don’t believe that you can just connect the TXs of multiple serial ports together. They are each sourcing current. They might be a way to do this with diodes? You also have to be sure the master’s TX port is able to drive all the slave RX ports. There are limitations.