2
\$\begingroup\$

I have a PIC24F based device that normally connects to a PC via USB. The device can be controlled through PC software this way. I want to add an optional hand control box that can also be plugged into a separate connector on the main device and can be used to control the device and read/display data from the main device. This hand control box will also be PIC based. I am trying to decide which communication technique to use between the main device and the optional hand control box. I like the idea of SPI but I know that is not intended to be used over long distances. Do you think my best option would just be to use the UART modules with RS-232 line tranceievers to boost the signal to +/-12 volts? Are there really any other options?

\$\endgroup\$
3
  • \$\begingroup\$ There is RS485, but 30ft is easy in quiet env. Is it quiet? \$\endgroup\$
    – tyblu
    Jan 5 '11 at 13:49
  • \$\begingroup\$ Do you have a strong preference with respect to wired/wireless protocols? \$\endgroup\$ Jan 5 '11 at 17:02
  • \$\begingroup\$ Lots of options below, based on USB RS232 devices are cheap and easy, I would use RS232. 30 feet will have a maximum speed. lammertbies.nl/comm/info/RS-485.html \$\endgroup\$
    – kenny
    Feb 14 '12 at 13:43
3
\$\begingroup\$

One option (assuming your desired device supports it... many Microchip PIC's do) is a CAN messaging system. It's extensively used in automobiles, e.g. so a tire rotation speed sensor and an accellerometer can communicate with the airbag computer. The protocol is designed such that you can have an unlimited number of devices communicating on one bus without collisions.

I use it at my company to communicate up to about 200 feet between a product and a controller. Highest standard baud rate is 1Mbit/s. It's fairly easy to implement in C. You'll need a CAN transceiver if you choose to do this; something like Microchip's MCP2551.

Here's the specification, here's pertinent app notes AN713 and AN754

\$\endgroup\$
3
  • \$\begingroup\$ +1 CAN is robust. However, I don't think it specifies hardware/physical layer. What voltage and cable scheme do you use? \$\endgroup\$
    – tyblu
    Jan 6 '11 at 13:23
  • \$\begingroup\$ We usually 5VDC along shielded twisted pair. This is uncommon, most automotive applications use 12 volts. For a 30 foot run in anything less noisy than a microwave I'd first try using CAT5 driven at 5VDC, because it's cheap and will probably work just fine. edit: I work in industrial lighting, not automotive \$\endgroup\$
    – Isaac
    Jan 6 '11 at 13:51
  • \$\begingroup\$ +1 for CAN. Hardware layer is defined esp. if you go for a protocol such as CANopen \$\endgroup\$ Jan 6 '11 at 21:24
2
\$\begingroup\$

RS-485 will work well, but you will need to add a RS-485 transceiver between your UART and the RS-485 bus. There are many software protocols that use this physical layer. Modbus is one of them that I've used in the past. It's very simple to implement and there are lots of industrial controllers out there that support it.

\$\endgroup\$
2
\$\begingroup\$

I've implemented the DMX protocol used for theatrical lighting systems which is a flavour of RS-485, and this worked in a noisy environment at least as far as 100ft. This was using a PIC16F877A and a RS-485 line driver to transmit, and several other receiver units with the same microcontrollers, daisy chained together along the 100ft line with a terminating resistor at the end.... it worked well.

Microchip actually has a very good datasheet on the subject with some circuit diagrams and example assembler code.

\$\endgroup\$
2
\$\begingroup\$

Yes, RS232 will work. Keep the baudrate nice and low, and 30 feet is no problem. But long cable runs are a hassle, so wireless seems attractive. Especially since a quality 30' RS-232 cable costs some money.

Other ideas to consider:

  • if one way communication is acceptable, put an IR receiver on the box and program it to listen to a consumer IR control. Use a popular remote's codes so that an $8 universal remote will work.

  • if you control the host software on the PC, have it open an ethernet port and serve web pages with the desired functions and controls on them. Any wifi-enabled iPad or smartphone becomes a remote control, and remote monitoring is easy. You could even replace the USB with an ethernet port, but that will add some complexity to the box.

  • Look at the ISM-band wireless modules like the 24L01 stuff from Nordic and the CCxxxx parts from TI. Sparkfun sells some on modules. If this is for a real product, using FCC precertified modules can save some money because FCC cert is expensive. I would say modules make sense in product volumes up to 5000 pieces.

Edit: You should use this remote.

\$\endgroup\$
1
  • \$\begingroup\$ To add to the RS232 answer: ensure you implement improved error checking on top of parity (CRC or whatever). You may be able to use CAT5e or CAT6 cable, depending on your environment, which is cheap. \$\endgroup\$
    – tyblu
    Jan 6 '11 at 6:55
1
\$\begingroup\$

I have used these,RF Link 4800bps Receiver - 315MHz and RF Link Transmitter - 315MHz

i have 2 different frequencies one for send and one for receive. I have successfully used them up to 30 feet using 5v to power them. Sparkfun has other wireless communication devices as well.

\$\endgroup\$
4
  • \$\begingroup\$ I have just been looking at the xbee and bluetooth products \$\endgroup\$ Jan 5 '11 at 14:48
  • 1
    \$\begingroup\$ xbee, from what i have heard work great, I probably will be picking a few up soon. \$\endgroup\$
    – jsolarski
    Jan 5 '11 at 15:17
  • \$\begingroup\$ It's worth mentioning that I believe the linked RF modules have no error-checking or correction. It's entirely up to the user to check the transmitted data is valid. Any noise during the data transfer can cause errors, which will not be detectable unless you do parity or CRC checking. \$\endgroup\$ Jan 6 '11 at 10:04
  • \$\begingroup\$ @Fake Name Yes you are correct there is no error checking in the linked RF modules, they are very simple devices, so no bells and whistles. \$\endgroup\$
    – jsolarski
    Jan 6 '11 at 13:21
1
\$\begingroup\$

There are various ZigBee devices that can be used just like a UART and should be simple to control from a PIC device. For example, the XBee is quite easy to use and is very affordable. In my experience I've been able to transmit and receive data in a crowded office at distances greater than 100 ft, and in a wide open space we could do much better, especially with good antennae. In my opinion wireless is much preferred to a 30-ft. long cable!

\$\endgroup\$
1
  • \$\begingroup\$ I agree. Digi xbee modules can be cheaper than a cable! They will go 10-20m with no antenna and 100m through walls with even a 1/4 wave length piece of wire as antenna. They also provide full error checking and even encryption. \$\endgroup\$
    – Myforwik
    Sep 14 '12 at 9:57
0
\$\begingroup\$

The MIDI interface was designed to reliably communicate over 50 feet. The hardware required (an optoisolator and a diode and a few resistors and an IC or transistor inverter) costs less and has better performance over long lines than the hardware required for +/- 12 V RS232 communication.

\$\endgroup\$

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.