Shop OBEX P1 Docs P2 Docs Learn Events
Relays and the Propeller — Parallax Forums

Relays and the Propeller

malcolm3000malcolm3000 Posts: 12
edited 2008-12-31 23:47 in Propeller 1
Hello,

I'm new to microcontrollers and have been playing with my new Propeller and eventually will begin interfacing it with my meccano set.

I've had some luck running a small electric motor using a transistor but want to use a relay to be able to use higher voltages than 3.3v (the motor sometimes needs to be turned to allow it to run at 3v). However, the relays I find at radio shack need 5v to pull the coils in.

My questions are these;

1. Should I use 5v to run the propeller or is this a poor practice and put too much strain on the chip?

2. Are there any relays that will pull in using the smaller voltages?

Thanks,

Malcolm.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-28 01:23
    There are some reed relays that work fine at 3V with about 12mA coil current. I know DigiKey carries them:
    search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=Z622-ND

    You could also use a transistor just like with the motor, but controlling a 5V or higher coil voltage relay.
    You could also use a transistor with a higher voltage motor.
  • johnfl68johnfl68 Posts: 72
    edited 2008-12-28 01:24
    The Propeller needs to be run at 3.3v to operate.

    There are some Solid State relays that will trigger from 3.3 volts, but you might be better off using a opto isolator chip, so that the prop triggers the led in the opto, and the opto triggers a relay, as this will help protect the prop from the relay better.

    John

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Whistler: I want peace on earth and goodwill toward men.
    Bernard Abbott: We are the United States Government! We don't do that sort of thing.
    Sneakers (1992)
  • JonathanJonathan Posts: 1,023
    edited 2008-12-28 01:32
    Use an NPN transistor and the 5V relay. Reed relays work, but make sure they can carry the current of your motor or they can fail. If you use a mechanical relay, make sure to include a diode across the coil to prevent back EMF from damaging the transistor and Prop pin. Never use 5V to power the Prop, you'll blow it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
  • sosaraujososaraujo Posts: 24
    edited 2008-12-28 01:54
    Two examples:
    Here www.electronicsteacher.com/circuits-and-diagrams/motor-and-general-control-schematics/r106.gif
    and here home.att.net/~Tom.Horsley/phonetale/relay.jpg

    and here (operation of transistors in circuits) www.kpsec.freeuk.com/trancirc.htm

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Adrian Sosa Araujo.- San Luis, ARG - Time Zone (GMT -3)
    El planteo de un problema es mas importante que su soluci
  • malcolm3000malcolm3000 Posts: 12
    edited 2008-12-28 03:19
    Thanks all,

    I've gotten the transistor to energize the 5v relay and I can hear the relay work. I even used a separate voltage supply to actuate the motor and the motor turns every time.

    However, the end result that I was looking for was to have a single power supply. I have a 9v DC adapter plugged into my home ac outlet and thought that I could get all the power I needed from it (rather than just the 9v battery). This was to run the chip and motor(s). However when I initially tried the one power supply and tried to turn the motor on, the power fluctuated in the system, chip and all, preventing the motor or chip from running properly. I have the chip board set up by following Parallax's PE platform (40-Pin).

    I suspect that I have to understand my circuit and capacitors better or use two different power supplies. One to be dedicated to the chip alone and the other to run all other items through relays. Could I be discharging the capacitors too quickly?

    I appreciate your help before and if you have any suggestions to help me stick to one power supply, I would be thankful.

    Thanks,

    Malcolm.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-28 03:52
    Your problem is that you may need a different power supply. If it doesn't have enough capacity for everything, it's output voltage will sag under load. A 9V AC "wall wart" may have a voltage of 12-14V under light load and drop to 5-8V under heavy load (like from a motor and a relay).

    If your motor is designed for use with a 6V battery or 4.5V battery, it can be damaged by running it at higher voltages. It would be nice if you had some idea of the current drain of the motor. Under heavy load, a small motor can draw as much as 1A or more, perhaps way more than your wall wart can provide.

    Until you understand the needs of your circuit and parts, in the absence of information from datasheets or spec sheets, you'd be better off having one supply for the Propeller and another one for the motor(s), with a common ground terminal for all the supplies.
  • JavalinJavalin Posts: 892
    edited 2008-12-28 10:37
    >The Propeller needs to be run at 3.3v to operate.
    nope. Works very happily at 3V too. Check the datasheet.
  • malcolm3000malcolm3000 Posts: 12
    edited 2008-12-28 11:42
    Mike,

    Thanks for your input.

    I do have the specs.

    1. Relay draws 89.3 mA with a pick up voltage of 3.5V

    2. Motor draws .18A~.25A at no load (which is what it is seeing at the moment) at 1.5V to 3V.

    3. The adapter puts out 9v with a maximum of 1.0A. (With the motor running at no load the total amperage drawn is 274ma measured at the adapter).

    I've noted that when the motor is not running (it needs a push which is what I'm trying to avoid) the total current drawn (measured at the adapter) is 312ma.

    When the stores open today I'll be buying the second power supply but eventually there has to be a solution. There are many toys out there that run the motors and chips fine under one power supply.

    Thanks,

    Malcolm.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-28 15:01
    Your adapter ought to work. At this point, we need more information.
    1) We need a schematic of what actually is wired, not what you think is supposed to be there.
    2) We need a more detailed description of what happens after you reset your Propeller
    3) We need a listing of your program
    The schematic and listing should be as attachments to your reply using the forum's Attachment Manager.
  • johnfl68johnfl68 Posts: 72
    edited 2008-12-28 16:39
    >>The Propeller needs to be run at 3.3v to operate.
    >nope. Works very happily at 3V too. Check the datasheet.

    Javalin, I know what the datasheet says (3.3 volt power (2.7 – 3.6 VDC)), the point is - he asked about running the prop with 5v.

    John

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Whistler: I want peace on earth and goodwill toward men.
    Bernard Abbott: We are the United States Government! We don't do that sort of thing.
    Sneakers (1992)
  • kwinnkwinn Posts: 8,697
    edited 2008-12-28 17:24
    Malcolm, it sounds like your power supply is up to running the motor and the prop, but the high startup current is causing the voltage to dip low enough to cause problems. What you need is a diode to isolate the power supply capacitors from the motor and possibly larger value capacitors.
  • malcolm3000malcolm3000 Posts: 12
    edited 2008-12-30 01:10
    Mike, kwinn,

    I have attached the schematics Propeller 1 and Propeller 2 as well as the in PDF format (I've haven't done any serious programing since I took C many years ago and I know there is a better way but at the moment I'm learning as I go). The schematic that has the chip has two circuits. One shows the power distribution but that has been modified. See my attachment which shows the motor and relay.

    I will check to see once I post if I can read the attachments. If I cannot, I will re-submit.
    Thanks,

    Malcolm.
    2338 x 1700 - 1M
    2338 x 1700 - 536K
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-30 01:44
    1) You don't want the diode in series with the resistor and the transistor base. The diode adds 0.7V or more of a voltage requirement to the transistor control without adding any advantage and the Propeller's I/O output voltage is at most 3.0V.

    2) You do need a diode in series with the LED on the next pin to limit the LED current. Usually 150 Ohm or something like that (from 100 Ohm to maybe 330 Ohm roughly).
  • soshimososhimo Posts: 215
    edited 2008-12-30 02:47
    Check out this PS I've been using with servos. They don't draw as much current as your motor (singly, but I'm running multiple servos) but I was having some serious brownout problems. Basically the diodes and the capacitors smooth out sudden drops in voltage from the 7805. This drop in voltage causes the 3.3v regulator to drop below the brownout voltage level. While not specifically you problem it will definitely protect you against sudden current surges such as when a motor is first started or stalled.

    newps_v2.gif

    HTH
    683 x 341 - 4K
  • PaulPaul Posts: 263
    edited 2008-12-30 02:51
    I've always found the ULN2003 to be great for high amp situations like relays and LEDS. I'm guessing they should work with motors as well. The Darlington pairs can be paralleled for even more amps if needed and they come complete with built in diodes.

    Once you get one motor running, why not another..and another?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki Rocks! - propeller.wikispaces.com
  • kwinnkwinn Posts: 8,697
    edited 2008-12-30 04:00
    Malcolm, Soshimo's power supply is very good for your application. Even adding only D1 and C4 to your current setup should fix the problem you are having.
  • malcolm3000malcolm3000 Posts: 12
    edited 2008-12-30 04:59
    I've done some troubleshooting and decided to try a separate power supply and came up with something interesting (I will try some of you solutions later when I buy more capacitors for a permanent solution).

    I found out that my relay (running about 180mA) kicks out using a separate power source. I'm guessing the relay overheats carrying the current to the motor and somehow that resets my chip. On P16 I have an LED that should stay on when the P17 is also on (P17 is the output for the coil on the relay) but it goes out. I believe the relay overheats because when I reduce the current on the motor it seems to run indefinitely. Before, the motor ran for about 5~10 seconds before resetting the chip and that's even with the motor running on a completely separate power source (I bought another 9VDC power supply). This is frustrating. The motor needs high current to start but once started the current needs to be reduced.

    The relay is a Radio Shack part number 275-240 5VDC and on the front of the package it's rated for 1A (120VAC/24VDC) but on the back the Nominal Current is listed as 89.3mA. Which is correct? Can the relay handle 1A or only about 90mA? I'll visit Radio Shack this week and try to find out.

    Malcolm.
  • malcolm3000malcolm3000 Posts: 12
    edited 2008-12-30 05:03
    Shoshimo,

    By the way...I've noticed some very nice diagrams. I have multisim 2001 student edition but could not find a voltage regulator in the components so I had to draw my sketches out by hand. Is anyone here familiar with Multisim and how I can model a voltage regulator.

    Thanks.
  • kwinnkwinn Posts: 8,697
    edited 2008-12-30 15:03
    Malcolm, the 89.3ma is most likely the coil current rating at 5V. You have it connected to 9V which means you will be cooking that coil. Connect the coil to the 5V regulator. The relay contacts are rated for 1A, and that rating is for a resistive load. A motor is an inductive load with a high peak current when starting and generates a counter EMF when stopping which can overheat the contacts on the relay. Also you measured the motor no load current earlier as being ~.25A at 3V. At 9V the current will be much higher. A second power supply with an output voltage to match the motor would be the simplest way to proceed and has the added benefit of isolating the motor from the micro.
  • rjo_rjo_ Posts: 1,825
    edited 2008-12-31 03:09
    I haven't read the whole thread... but for simplicity of design... relays work fine... my preference is a 5 bolt reed relay from Radioshack... it works fine just hook it up to your prop ... no problems... and you can go from there to transistor logic seemlessly.
  • Paul RowntreePaul Rowntree Posts: 49
    edited 2008-12-31 19:50
    Greetings All;
    I am not an EE by any means, but why not just run the base of a TIP120 Darlington driver from a prop pin through a 100 Ohm resistor, and directly run the motor with low-side switching? I am running a 200 mA, 12 Vdc motor this way and it works well, with no heating of the chip at all even without a heat sink. On a Protoboard, I just use the raw wall wart power in to run the motor. Plus, a simple PWM gives excellent speed control. Starting the motor up too quickly can cause the prop to reset (it has a large rotor mass), but ramping the PWM gives smooth starts and stops. Still working on PID speed control ....

    Just make sure you have a diode across the motor leads.

    Cheers!
  • kwinnkwinn Posts: 8,697
    edited 2008-12-31 20:27
    This is a simple and effective way to control a small motor, but what happens if the transistor shorts? I know that's not very likely, but it does happen on occasion, and I don't think the prop pin would survive 120mA current input. Personally I prefer to use some form of isolation such as an opto isolator, or at least a resistor large enough to limit the current to something the pin can handle.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2008-12-31 23:47
    Malcolm, if you need a transistor to drive a relay to drive a small motor then why bother with the relay then? It seems to me that you are getting correct answers to your questions it's just that it's your question that's wrong (happens).

    Take Paul R's post for instance, it seems it would address your requirement rather than your question. As to the transistor shorting and taking out the prop I would put that in the same category as lightning damage. Keep it simple, one transistor and one resistor plus a diode for the motor. There is that issue with power supply droop and you can overcome it with the suggestions that have been offered. However none of them can help you if the motor stalls as your power supply does not have enough current in this instance to maintain it's output voltage within acceptable limits. The worst that can happen is that the prop resets and the motor is turned off and unless it's a safety critical system this is quite acceptable behavior don't you think?

    *Peter*
Sign In or Register to comment.