4

I am a programmer trying to build a circuit with limited EE knowledge. With so many options(at least being new to this), just want to make sure I am going down the right path.

What I am trying to build is a master device with a RaspberryPi and many plug and play slaves(relays and sensors with very small amounts of data transfer). Seems like using modbus/rs485/pic/75176(LTC485) would be the best solution.

  1. Consumer device, so component costs matter and an off the shelf product won't work.
  2. The more devices I can connect the better. (My understanding is Modbus can do 250 devices by default, but I can do a double register(16bit) to get 65k tho bandwidth will probably cut that in at least half which is fine)
  3. Slaves can be repeated many times. ie 10 of the same temperature sensors. I'm understanding that I don't necesarily have to define the slave id in modbus and can define it on the fly. Please correct me if I am wrong since I can't ask a consumer to set the ID manually if there is more than 1.
  4. I need the consumer (true end user no corporate) to just plug a device in and have the system recognize what it is and be able to uniquely identify it.
  5. True real time is not needed, a few second delay isn't a big deal.
  6. Everything will be a call from the master to get data from the slave. Nothing originating from the slaves.
  7. Plan on using a standard rj45 cable with a max distance of 100m since that's what they are rated for (cheap simple standard).
  8. Lastly, I do plan on having a wireless option in the future, so if any of it can mesh well, that's a bonus.

I found this example that seems like what I am looking for. Doing my code in c++, but should be easy to convert. https://docs.google.com/document/d/1YN4BeXw4zrb2dlk9HcTDxd-E5vxNjVN8wcSF4Q86yz0/

Again, I have much to learn, but tired of going down a bunch of wrong paths, so any advice would be great.

Thanks ahead of time.

VirtualLife
  • 141
  • 2
  • Since it seems you're going to use Ethernet cables, why not use actual Ethernet? Each node comes with its own unique MAC id from the factory; all you need to do is define some type for each node either via your own protocol or one of the [too] many fieldbus protocols over Ethernet. There is no such facility like unique, factory assigned MAC addr in Modbus over RS485; you'd need to implement something custom. Also Modbus over RS485 only supports 32 nodes without repeaters IIRC. – Fizz Dec 18 '15 at 19:32
  • May have understood wrong, but with regular ethernet, I wouldn't be able to run a 12v power across and would need an expensive router every time I more ports are needed. Hadn't read about the repeater need. The ones I am seeing are very expensive. Guess that means RS485 is shot. Are there any other options? – VirtualLife Dec 18 '15 at 19:43
  • There's Power over Ethernet. – Fizz Dec 18 '15 at 19:44
  • Just to give a simple idea of what I am trying to accomplish. Picture a consumer outdoor weather station (not really but easiest example). The end user would buy the Master Unit (Raspberry Pi) and then whatever sensors they want to go with it. Trying to make the end user experience as easy as possible. So when they plug in a slave sensor, the master knows what it is and can communicate with it directly. – VirtualLife Dec 18 '15 at 19:46
  • What distance to envisage this to work at: per segment and total. Is your typical use case a daisy chain of sensors or a star topology? – Fizz Dec 18 '15 at 19:55
  • Distance would preferably be 100m, just because that makes it so the end user can't buy too long of an ethernet cable. I can deal with any topography. I know I'm a bit over my head here, just found that link in my original post which looked exactly like what's needed, cheap circuit and repeatable. Maybe a better choice would be to make everything wireless, just thought this would be cheaper and easier. – VirtualLife Dec 18 '15 at 20:13
  • If you intend your stuff for EU, [KNX](https://en.wikipedia.org/wiki/KNX_(standard)) fits the bill (especially since you want to mix wired and wireless) but its market penetration in the US is negligible and most most compatible products are made in the EU; see [temperature sensors](http://www.knx.org/knx-en/knx/knx-products/knx-certified-devices/index.php?pf=Phys.+sensors&pt=Temperature#letteredListSearchFilterProductFamily) for example. Yeah, field bus protocols are regional. Different stuff is popular in the US, Japan, or Europe. – Fizz Dec 18 '15 at 20:14
  • The wiki on KNX sounds very promising. Quick search didn't bring up much on how to implement something custom, but will definitely look into it more. – VirtualLife Dec 18 '15 at 20:30
  • Also, from what I've read of the wireless *mesh* networks, only WirelessHART has any real implementations insofar. A mesh network (unlike say 802.11) allows nodes to dynamically connect to each other. See https://www.youtube.com/watch?v=WFASdYPzjvQ – Fizz Dec 18 '15 at 21:38
  • Admittedly, I've read that from EU sources. Over the pond ISA100.11a is apparently more popular in that area https://www.youtube.com/watch?v=S2prv9Bmoq4 I suspect either of these might be prohibitive for consumer applications insofar owing to too little adoption resulting in fairly high unit prices. At least for this stuff you don't have choose between 20+ standards like for wired field buses. – Fizz Dec 18 '15 at 21:46
  • For a more concrete example of WirelessHART see https://www.youtube.com/watch?v=ogzg6rAxHbE – Fizz Dec 18 '15 at 22:00
  • Do you have an actual question or are you just making an ad? – Andy aka Dec 18 '15 at 22:25
  • Also there's an IEEE 1451 standard for self-describing (a sort of plug-and-play) sensors, but it doesn't seem to have much industry traction. – Fizz Dec 18 '15 at 23:26

3 Answers3

3
  1. Consumer device, so component costs matter and an off the shelf product won't work.

When doesn't it matter in industry ;)

  1. The more devices I can connect the better. (My understanding is Modbus can do 250 devices by default, but I can do a double register(16bit) to get 65k tho bandwidth will probably cut that in at least half which is fine)

Technically you can only give slaves address 1-247 as 248-250 are reserved. You could double the register address but then you wouldn't be compatible with any other Modbus device as you are no longer using Modbus Protocol.

  1. Slaves can be repeated many times. ie 10 of the same temperature sensors. I'm understanding that I don't necesarily have to define the slave id in modbus and can define it on the fly. Please correct me if I am wrong since I can't ask a consumer to set the ID manually if there is more than 1.

What do you mean by "design on the fly"? If you are not going to allow your end user to define their own Slave IDs then I reccomend you initiate your own slave IDs to a higher number, like 150+. If your device is connected to a pre-existing Modbus network then you might run into the issue of pre-exsisting slaves already using addresses that you assigned. YIKES! Keep in mind that most end users will begin assigning devices at address 1 but that's not always the case!

  1. I need the consumer (true end user no corporate) to just plug a device in and have the system recognize what it is and be able to uniquely identify it.

Very easy to do but as stated in bullet 3, if your hardcoded Slave ID already exists on their system you will have multiple devices communicating to the same master.

Everything else you stated looks like standard Modbus RTU specifications so you should be fine there. I would reccomend looking up Modbus TCP protocols for when you use wireless transmission. Here is a helpful link to a website that goes over all of the Modbus Protocols as well as indepth analysis on what Modbus Erros and Responses need to look like.

Simply Modbus

R. Johnson
  • 182
  • 9
  • Appreciate it. This is all proprietary, so not worried about other networks. I picture someone going to the store and buying 5 temperature sensors for example. Those temperature sensors would have the same ID from the factory (vs a light sensor would have a diff ID). When it get's plugged in, I don't want any collisions between those 5 with the same ID. Maybe I am just misunderstanding how the ID system works? – VirtualLife Dec 18 '15 at 18:59
  • 1
    I have not personally heard of any manufacturer pre-programming Modbus IDs into thier product as that is typically set up by the end user or some 3rd party before it goes out to consumer. Modbus IDs are NOT manufacture IDs they are seperate. You could code your system to periodically "ping" modbus addresses and see if you get a response from the slave in order to determine a new slave was added but you would need to set up the slave ID prior to this. – R. Johnson Dec 18 '15 at 19:26
  • That was essentially what I started trying to do with just USART communication. Every x amount of time, send a message to all slaves and they report back their ID and the internal list gets updated. Was running into data collisions which I didn't know how to handle, so I thought a standard like modbus would be better. Sounding like maybe not from Respawned comment. – VirtualLife Dec 18 '15 at 19:54
  • I'll look around and see if there is a communications protocol that might be more what you are looking for but comming from a controls standpoint, lonworks and modbus are typically used the most. – R. Johnson Dec 18 '15 at 20:11
  • Thanks. I was honestly hoping what was designed in that link was exactly what I needed. Looks like I may have to fake it for now for a POC until I can pay someone that has industry experience and time to build it. – VirtualLife Dec 18 '15 at 20:18
0

You could setup a pc as the modbus master and buy cheap micro plcs for your clients. There are many cheap reliable brands that can be programmed using function blocks. 1- 6 IO unit costs about USD90.00, but it will do what you want out of the box, no c++ programming or fancy electronics required. Just connect your sensors. Look for a PLC that supports both TCP and RTU. Xlogic has a wifi model that would suit what you're trying to do.

Modbus function 40 is used to identify devices, but you will have to manually assign each device ID.

0

Have a look at 1-Wire. There are a range of sensors and digital I/O chips which are uniquely IDed. Plenty of software to go with them including some very clever polling techniques to figure out what's on the network.

The system can work with 2-wires (1-Wire refers to one data wire, I suspect) but a three-wire system separating +5 V, data and GND is more reliable.

[Edit]

Have a look at Guidelines for Reliable Long Line 1-Wire Networks. It also addresses problems with star topology, etc. I used 1-wire temperature sensors with a RPi and invested in a 1-Wire-Pi board based on the DS2482S-100 driver chip. This looked after all the driving and timing accuracy and made the task straightforward and reliable.

Transistor
  • 168,990
  • 12
  • 186
  • 385
  • What's the maximum length of wire in a 1-Wire system? – pjc50 Jan 05 '16 at 14:36
  • I am using somewhat of a 1-wire setup right now. Rx/Tx are tired together with a diode. Technically it works, but I have a collision issue when all devices are talking at once (when booting the system needs to send a hello who is on the network and get a name back from all the slaves). Hence the reason I looking into modbus so I didn't have to write my own. @pjc50, the max length is about 100m, but I think it depends on the # of devices attached also. – VirtualLife Jan 05 '16 at 15:22
  • Updating answer. – Transistor Jan 05 '16 at 17:09