1
\$\begingroup\$

I just want to start by saying that I'm relatively new to electrical engineering in general, so if I sound absolutely retarded please bear with me.

As part of a learning project I'm working with a few color sensors, specifically Parallax's ColorPAL 28380s, and I have both an Arduino Uno and Arduino Mega 2560 lying around to grab data off them. I've been fiddling around with the specifics for this project over at the Arduino SE but I suppose this question could be for any microcontroller in general. These sensors use a communication method known as 1-Wire/MicroLAN wherein they use only one pin for transmission and reception depending on the state of the pin they're attached to, among a few other specifics. Now, I have three of these, and my final objective is to be able to grab data off all of them in the same point in time repeatedly so that I can send the data over to some other program I'm writing to run an algorithm. The problem is that the example used is based on an emulated serial port on the Arduino that doesn't like working with multiple instances.

Now, the Mega 2560 has three sets for Serial communications embedded into it which would be perfect... only if I could separate the RX and TX from the 1-Wire. A user over at Arduino SE suggested I use a transistor to separate it. Call me silly, but I don't have any spare around so I'll be out to test it soon once I can go out to a nearby electronics store. Yet, searching around the internet I've read that 1-Wires should never be connected to native serial ports because of how they work with states.

In summary, can 1-Wire sensors communicate with native serial ports in microcontrollers if I make a circuit to split the signals? And, if this is possible, what are the specifics behind such a circuit?

\$\endgroup\$
3
\$\begingroup\$
  • With some software effort you can read all three sensors over the same wire: 1-wire peripherals have a unique ID.

  • Dallas 1-wire is a specific communication protocol, and using UART hardware to communicate with a 1-wire device is, well, like using a chainsaw to turn a screw? Better look for a 1-wire library that simply bit-bangs the protocol. There are bound to be many such libs, either for the Arduino or for a bare Mega 2560.

  • If you really really want to 'split' the one (UART) line you could use an analog multiplexer.

\$\endgroup\$
  • \$\begingroup\$ Alright, so it is kind of silly to drive them with the native UART. I've been able to drive a single sensor using a library, so that part I can understand. Regarding your first point then, what you're telling me is that I can simply do the resetting of the sensors all at once through the same wire, switch the pin state to input, and cycle through IDs with interrupts/using a state machine to be able to read the inputs individually? \$\endgroup\$ – Eriol Nov 21 '14 at 15:04
  • \$\begingroup\$ Read up on the 1-wire protocol, it should be explained in the datasheet of your sensors. There are commands that target a specific peripheral (identified by its ID). \$\endgroup\$ – Wouter van Ooijen Nov 21 '14 at 15:43
  • \$\begingroup\$ After analyzing the datasheet a bit longer, I'll try using some of the commands directly there and toy around with them using your suggestion. I'll expand if I find anything else, but I think the +nn command may be of use in the case of the 28380 even though it says otherwise in the datasheet. I'll expand on the specifics back at the Arduino SE if I get it to work. \$\endgroup\$ – Eriol Nov 21 '14 at 20:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.