2
\$\begingroup\$

I've bought a Parallax ColorPal 28380 color sensor, http://www.parallax.com/Portals/0/Downloads/docs/prod/sens/28380ColorPAL.pdf

In the documentation above, they've used a Basic Stamp microcontroller, and I want to use this sensor with Microchip's 18F (18F2550 or 18F4550) microcontroller series.

The problem that I've been experiencing is, the sensor communicates in 2400-7200 bps range. I can't use PIC's own UART unit because the sensor has 1 pin only. First thing that came into my mind is using 1-wire protocol but it is operating at 15400 bps which is too fast.

Now I'm wondering, if I place a diode in front of TX line and merge it with RX line, is this setup works ? Or is there any way to control the transmission speed of the 1-Wire protocol ?

Thanks in advance,

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

First of all, you shouldn't use a UART because it's an Open-Collector interface - the pin used for the serial data should never be driven high. It should be set to tri-stated (high-impedance input) to transmit a "one" bit and set to an output driven low to transmit a "zero" bit, and this data should be sent at a prescribed baud rate. I'm pretty confident that any UART by itself will drive the signal both high and low. So if you want to use a UART to implement this interface, you need to introduce some external hardware. The following circuit is taken from an Atmel app-note:

enter image description here

I think the module you've linked to provides the (equivalent of) the 4.7kOhm pullup, but it's hard to say.

\$\endgroup\$
3
  • \$\begingroup\$ Thank you for your response, I'm gonna buy those BC547s first thing tomorrow (its 6pm now) and post results if I succeed. In the meantime, are you familiar with the 1-wire protocol and how to adjust its baud rate ? \$\endgroup\$
    – JuniorDev
    Commented Feb 29, 2012 at 15:56
  • \$\begingroup\$ @Ismail I'm not very knowledgable on the PIC18F's capabilities. But if it has one-wire hardware there should be a baud rate register... \$\endgroup\$
    – vicatcu
    Commented Feb 29, 2012 at 16:04
  • 1
    \$\begingroup\$ @Ismail Kuruca: Maybe you will find this Microchip App Note helpful. When you are using a simple I/O Pin instead of the usart, you dont need the BC547's ... ww1.microchip.com/downloads/en/appnotes/01199a.pdf \$\endgroup\$
    – PetPaulsen
    Commented Feb 29, 2012 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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