USB Controller RC Car

Discussion in 'The Projects Forum' started by khayman218, Jan 9, 2008.

  1. khayman218

    Thread Starter New Member

    Jan 9, 2008
    9
    0
    Hey all,

    I am trying to control an RC car from my computer via a USB device. The USB interface I am using is this one.

    I have already written all the code for it (host and device). I am setting four different output pins to high based on user input at the PC.

    I have also taken apart the RC Car's remote and found the switches that control forward/backward/left/right. I have been able to short-circuit the switches using relays on a breadboard, and I can control the remote by turning the relays on/off.

    However, since my background is entirely in software, I am not very confident about hooking up my breadboard circuit to the PIC on the USB device. The breadboard circuit has a wire attached to the RC switch for a direction and that wire is grounded when the relay is powered. It works, but I'm not sure if I am slowly frying all the circuits involved.

    The current relays are 56 ohm coils with a nominal voltage of 5. From what I remember from Physics E/M that's 89 mA of current. The PIC output pins can only drive 25 mA (I believe). So I don't think my existing breadboard circuit is safe for the PIC. No other relays were available at RadioShack, but I found this one online. It seems like it would only pull 12.5 mA of current.

    I am looking for some confirmation or words of experience concerning having a PIC's output pins drive relays and how to prevent everything from burning. Also, I'm pretty new to the hardware side of things, so any details are appreciated.

    Thanks!

    -Andrew
     
  2. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    Your PIC outputs can turn on logic level FET's. I use VN10LP's for that function. The FET is a current switch. With 5 volts on the gate, it will turn on and pass current - each can handle more than the 89 ma for the relays. Use a 100 ohm resistor between the PIC output pin and the gate, tie the source of the FET to ground and the relay to the drain.

    You might want to get the spec sheet on the FET's and read up on the devices in out Ebook to have a bit more confidence in using them.
     
  3. khayman218

    Thread Starter New Member

    Jan 9, 2008
    9
    0
    Thanks for the quick reply!

    Would the attached image show what you are referring to?

    I have added the FET and attached the PIC output pin to the gate on the FET. Other than that, this drawing shows how the breadboard circuit is currently.

    You will have to excuse the MSPaint job on the schematic. OpenOffice doesn't have a circuit designer product yet ;)

    -Andrew
     
  4. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    If you don't want to fiddle with FETs, you can use a standard ULN2003 or ULN2803 IC. These contain seven or eight Darlington pairs, respectively. They cannot SOURCE (supply) current, but can sink (ground) up to 500mA per output. They're made for inductive loads like your relays, and thus have bypass diodes in the output stages to take care of the reverse EMF.

    ULN2x03's are for TTL. If your outputs are CMOS, use ULN2x04's. They're basically the same IC's, except the x04's have about 7k more resistance for the input lines.

    If you go the FET route, don't forget to use diodes across the relays' coils to absorb the reverse EMF, as the voltage spike can be high enough to "zap" your FETs.
     
  5. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Andrew,
    Your attachment didn't "take"

    Actually, I personally prefer to see folks upload .jpg, .png or .gif images rather than other types, because you don't need additional software to view them, and they load very quickly.
     
  6. khayman218

    Thread Starter New Member

    Jan 9, 2008
    9
    0
    Sorry about that. I tried to upload a jpg. It appears for me, but maybe I didn't do it correctly for others to see.

    Here is a link to imageshack hosting it: [​IMG]

    -Andrew
     
  7. khayman218

    Thread Starter New Member

    Jan 9, 2008
    9
    0
    After doing some more reading, I have revised the circuit. Here is the latest version:

    [​IMG]

    Does anyone see any issues with this? Let's hope I don't get the windows "USB POWER SURGE!" warning again ;)

    -Andrew
     
Loading...