Multiple serial inputs?

Is it practical to use an Arduino to receive serial data from multiple devices and pass that data out the USB port?

Here's the blue-sky design. 4-8 RFID reader ICs (RFID Reader ID-20LA (125 kHz) - SEN-11828 - SparkFun Electronics) send their data at 9600bps to an Arduino. The board adds an identifier so it's clear which reader read which tag and sends the data out the USB to the computer. The Arduino never needs to send anything to the RFID readers.

From what I've seen so far (I'm a noob) I doubt an Arduino can do this without the chance of dropping data. But, because I know so little, it seems wise to ask the experts.

TIA
Mike

Try using the Mega, that has four serial ports. Alternatively the software serial library could help. As this is RFID then the data throughput is small. It might be 9600 baud but it is not sending that all the time, just about 10 bytes per card presentation so you should be able to get away with it. Remember that RFID readers should be kept about one foot apart to keep their range.
If that doesn't work then you will have to go with sevral I2C UART chips.

Thanks for the quick response. If I understand correctly, wouldn't the Mega have only 3 ports available for the readers since 1 would still be used for USB?

I looked at the serial libraries some and as near as I could understand they could drop data even at this low data rate because there's no way to buffer. That's why I questioned whether I'm understanding correctly.

Mike

Correct, but you can also use the SoftwareSerial library with the Mega.
And, when it's not connected to the computer, that serial port can be used for communications as well. (just like the Duemilanove)

But as far as the buffering and.. well, real communication goes, I can't help you there!

Best of luck!

According to the reference page: Serial.available() - Arduino Reference
the hardware serial buffer is 128 bytes.

Don't know about the software serial though.

Actually, do you even need the Arduino? Sparkfun has a USB base for the RFID readers: SparkFun RFID USB Reader - SEN-09963 - SparkFun Electronics
though you'd have to sort out all the virtual serial ports at the computer end.

I've got one of the SparkFun USB bases and it works great. The problem is I need multiple readers and they would be beyond the 3 meter limit of USB cables. Most would be beyond even the 5 hop limit of daisy chaining with hubs.

The thought was to 'concentrate' the readers with an Arduino and then use an XBee shield to transmit everything. If it comes down to using a Mega for every 3 readers then for about the same bucks I could just pair an XBee with every reader. The downside is providing power at every XBee/reader.

Mike

It sounds like you are doing a real access control system here. I used to design access control systems for one of the leading companies.
We had four serial inputs from the readers going into one serial port through a multiplexer. That is we switched the input to the read serial port when data was coming through. The fact that data was only sent on a door access meant the actual through put was small. The cases where two or more cards were presented at the same time was covered by the fact that the readers repeat the key code for as long as the card is held in the field, so if the controller didn't get it on the first pass it would get it on later passes. You get about 40 repeats a second so there is plenty of time to grab the data.

To improve things you can also use the start bit to trigger an interrupt to switch the appropriate multiplexer channel in when ever a reader starts sending stuff. However we found this wasn't necessary.

Actually, this is for model railroad use. A group of us are trying to pick off-the-shelf hardware that can be ordered and hooked up by most any modeler without the need for much (if any) soldering or use of discrete components. Since it's a hobby, we're trying to keep costs down.

The CTC computer for a model railroad is often in a different room and because of the twists and turns of a layout it could easily be 200' away as the cable runs. The data rate from each reader probably wouldn't be more than 1 tag per second as a train passes (1 tag on each car). The CoreID readers we've tested do NOT repeat a tag's info unless the tag goes out of range and returns. There's one chance to get the read and then it's gone.

The CoreID's output is serial but it's TTL so is there such a beast as a multiplexer for that? Please keep in mind the goal is to use off-the-shelf hardware. Even though model railroading requires some soldering skills, it seems that few modelers have any interest in electronics assembly.

Mike

but it's TTL so is there such a beast as a multiplexer for that?

There are very few types of multiplexer other than TTL ones.

You will defiantly struggle to get a TTL signal to go 200' The reader's output I used was open collector with a pull up to +12V and that would go that sort of distance.

If you have a tag on each carriage you must make sure the tag from one leaves the reader's field before the next one enters. Also look at the specification of that sort of reader as readers that only output their code once often have a delay before they can read another tag. This is normally about one per second and it did cause trouble in an evacuation installation I dealt with.

Since it's a hobby, we're trying to keep costs down.

and

the goal is to use off-the-shelf hardware

don't often sit together very nicely.

There are very few types of multiplexer other than TTL ones.

Sorry. All I'm familiar with are serial port multiplexers -- like those used years ago to mux many serial terminals over one telco circuit. Aren't TTL and RS232 levels two different things?

If you have a tag on each carriage you must make sure the tag from one leaves the reader's field before the next one enters. Also look at the specification of that sort of reader as readers that only output their code once often have a delay before they can read another tag.

True. With the CoreID reader it will report only one tag when more are within range. There doesn't seem to be a time delay. Testing has shown that if tags are centered betweens ends of the railcars then a train can pass over the reader at up to 50% of max scale speed with 100% read accuracy. Tags start to be missed at higher speeds. Many tags are missed when they are placed at the mating ends of cars. They're just too close for the reader to handle.

You're right about costs at the hobbyist level. Just look at what Bluetooth costs for an Arduino!

Mike

Aren't TTL and RS232 levels two different things?

Indeed they are, but today you get a multiplexer as a single chip that handle TTL, where as the multiplexers you talk of had many components in their construction.

The one shot readers I designed required about 10 not valid data cycles before they would re read, any less and we found it to be unreliable.

Not too sure if you will find anything off the shelf apart from a bunch of USB to serial TTL bridges.

The biggest challenge in your application multiplexing serial ID data from multiple sensors isn't necessarily the distance or logic voltage used, but rather how do you ensure that any two or more devices don't try and send data at the same time?

Unless the multiplexer has internal memory buffering and some kind of addressing or protocol logic it's not a bullet proof design to just mux the serial links together to one controller. So the question to ask is how would you ensure that two trains don't both trigger a ID unit at the same time? If you can't, then what design features would deal with that situation?

Lefty

The biggest challenge in your application multiplexing serial ID data from multiple sensors isn't necessarily the distance or logic voltage used, but rather how do you ensure that any two or more devices don't try and send data at the same time?

That's what I was hoping an Arduino could do. It's looking more like a job for an XBee network. At least the base XBee would buffer data and the remotes would retransmit if they didn't get an ack. My limited knowledge ends there.

I'm wide open to any ideas.

Mike

It's looking more like a job for an XBee network

Well that does fit the off the shelf criteria but then each sensor node costs what a ID sensor and XBee unit costs, plus you still have to figured out how to power them.

Depending on how many total sensors one would want in their track layout this could become quite an expensive route to take. Using wireless data but running wire for power seems to not be a efficient use of funds to me :wink:

Lefty

I am building a homebrew system for model railroad control (3-rail O gauge) based on Arduino. An off-the-shelf solution seems like a really hard design constraint to meet.

I use RFID but at only one point; train identities are then deduced from occupancy patterns. Robust enough for computer control, but not muuch manual intervention.

As Mike notes, TTL signals are not going to cut it for the distances you are talking about. Converting the TTL signal to RS232 or RS485 for long-distance transmission would be pretty easy, but would need an IC and a few discrete components.

Well that does fit the off the shelf criteria but then each sensor node costs what a ID sensor and XBee unit costs, plus you still have to figured out how to power them.

Power is the one easy part. I'll have a power buss available with +-12VDC and +5VDC. Many model railroaders have comparable power busses under their layouts. Those that don't could pull power directly off the track with a bridge rectifier and a 5VDC regulator although that's getting away from off the shelf. A wall wart would do.

Depending on how many total sensors one would want in their track layout this could become quite an expensive route to take.

I figure an XBee base station at about US$51 and each remote reader at about US$74 using XBee.

There IS a reader "concentrator" kit available from a club in GB but because of GB's tax structure they won't sell to anyone who's not a member. There's an initiation fee, a membership fee, and the kit cost. Plus, their board has serial output so a serial/USB adapter is needed. That's a lot to go through and the kit still must be assembled. Not many modelers will go through that many hoops for RFID.

Like I said, getting power is the EASY part.

Mike