Shop OBEX P1 Docs P2 Docs Learn Events
DC motor and basic stamp 2 — Parallax Forums

DC motor and basic stamp 2

NtelosNtelos Posts: 21
edited 2009-08-27 03:04 in Learn with BlocklyProp
Hello there.

I use basic stamp 2 (5 Volt ) and i have a dc motor (6 volts). I would like to connect the motor to the controller.

I was told that the simplest way is to use a 6V relay (with two inputs) and connect the motor and the controller and it should work fine.

Another solution is to use H-bridge but i don't know which solution is the safest for the controller.

Does anyone know if the relay - solution will work?
If not, where i could find a circuit with h-bridge, so i can use one for the project?

Thanks in advance

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-05-19 13:16
    Both solutions (relays / H-bridge) are used. You actually need two relays, one to turn the motor on and off and the other to reverse the direction of the motor. The H-bridge is actually a transistorized version of the same thing. It has the advantage of being fast enough so you can have very rapid pulses of power to the motor with the width of the pulses determining the speed of the motor since the motor averages the power it's given to determine its speed.

    Do a web search for "wiki h-bridge". You'll find a nice article explaining how an H-bridge works and links to examples including circuits. The StampWorks Manual also has some examples since the PDB (Professional Development Board) has an L293D H-bridge IC. See under "Downloads & Resources" here:
    www.parallax.com/StoreSearchResults/tabid/768/txtSearch/stampworks/List/0/SortField/4/ProductID/144/Default.aspx
  • EverQuriousEverQurious Posts: 48
    edited 2009-06-01 04:20
    On the other side, I am attaching a PAINT file I made showing the RELAY motor controller I have used on several of my bots. No speed control, but it is impervious to any BAD data commands and can be built cheaply and to carry decent loads. SIMPLE, EASY YES! FANCY, FULL FEATURED NO!
    Just wanted you to look over both options.
    Best of luck on your endeavors.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    EverQurious
  • NtelosNtelos Posts: 21
    edited 2009-06-01 12:59
    I bought a relay (Matsu(expletive)a JW2SN) which works at 6Volt and i am going to buy a transistor 2N222 type and i will try this circuit.

    If it works, i will post the solution. Otherwise i will try the circuit you posted!

    Thank you a lot anyway!
  • EverQuriousEverQurious Posts: 48
    edited 2009-06-01 19:52
    Sounds like you are working on the same circuit. Remember you will need two relay circuits for each motor and be sure NOT to omit the reverse diode on the relay coils. If you do you will quickly fry the 2N2222s.
    Let me know how it goes.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    EverQurious
  • EverQuriousEverQurious Posts: 48
    edited 2009-06-01 22:40
    Here is another diagram I created along time ago. It is the same circuit but simplified to one motor and gives desciption of how to use it.
    Guess I should leave ya be now...
    GOOD LUCK tongue.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    EverQurious

    Post Edited (EverQurious) : 6/2/2009 12:40:13 AM GMT
  • $WMc%$WMc% Posts: 1,884
    edited 2009-06-02 17:51
    Heres another application,Its soild state.

    It also works with steppers



    ________$WMc%______

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············································ BoogerWoods, FL. USA
  • NtelosNtelos Posts: 21
    edited 2009-06-08 10:38
    I created the circuit on the picture attached, on a breadboard. The motor works without the function of the basic stamp controller.

    That means that if i disconnect the wire going from the controller to the 390 Ω resistor, then the motor still works. Is there any mistake in the wiring or what?

    Thank you in advance!
    1755 x 1612 - 110K
  • Mike GreenMike Green Posts: 23,101
    edited 2009-06-08 13:59
    1) The only error I can see in the diagram is that the diode is connected backwards. The cathode (banded end) of the diode should be towards the +5V supply. That doesn't explain the behavior you mention, so you must have a wiring error of some kind. Check your wiring.

    2) Unless you have a very small motor, it's best to power the motor directly from a 6V supply instead of the regulated +5V supply.
  • NtelosNtelos Posts: 21
    edited 2009-06-08 18:28
    Ok.

    I change the diode as you said.
    The program is something like that:

    OUTPUT 10
    OUT10=1
    PAUSE 3000
    OUT10=0
    PAUSE 2000

    so i can test the function of the motor.
    When i changed the direction of the diode:
    1)At first, the motor tries to start and then i listen a 'tick' sound from the relay. This happens 3-4 times.
    2)Then, the relay starts working for 3 seconds and then it stops for w seconds and this function repeats 2-3 times.
    3)Then, the step 1) happens again but the motor does not start. It tries to start and i hear the 'tick' from the relay, without starting working.

    When i closed the main switch and opened it again, the motor started to work continuously like before. Is there any possibility to be relay's fault? What 'tick' sound from relay is for?

    In the project i am working to, i cannot connect the motor directly to power supply, because i want to connect the motor function with something else. (i.e.: if the photoresistor works, the motor works - something like that. So i need to guide the motor through the controller).


    And something else...

    If i want to reduce the speed that the motor turns, am i going to use just a trimmer?

    Thank you in advance

    Post Edited (Ntelos) : 6/8/2009 9:10:13 PM GMT
  • $WMc%$WMc% Posts: 1,884
    edited 2009-06-09 01:03
    Ntelos

    I think Your using a normally closed contact were you wanted a normally open set on the relay. This would explain why the motor runs continuously when you disconect the base lead from the stamp.Heres A little code short cut.You can use HIGH and LOW instead of OUTPUT and OUT

    HIGH 10
    PAUSE 3000
    LOW 10
    PAUSE 2000

    is the same as

    OUTPUT10
    OUT10 = 1
    PAUSE 3000
    OUTPUT10
    OUT10 = 0
    PAUSE 2000

    ______________$WMc%_________

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············································ BoogerWoods, FL. USA
  • NtelosNtelos Posts: 21
    edited 2009-06-09 05:30
    i tried the code but i had the same results

    If i disconnect the lead from the controller, the motor works continuously.If i connect the lead then i hear the 'tick' from the relay.
    I changed the duration from 3 seconds to 6 seconds and i noticed that, when i turn on the main switch then i hear the 'tick' from the relay the motor starts but it stops.
    Its like it takes an amount of current for a millisecond and then it stops. (like you give it a turn nothing more). Then it stops for 6 seconds and the same again.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-06-09 05:55
    The motor and the relay may be drawing too much current from the power supply. This would cause the voltage to drop below the point where the Stamp can operate and the Stamp would reset causing the program to start all over again.
  • NtelosNtelos Posts: 21
    edited 2009-06-09 13:09
    I removed the relay and i connected the motor directly to the transistor and it works just fine.
    I just wanted to make a demonstration of how a relay can work (university project).

    Thanks for you time all of you!
  • $WMc%$WMc% Posts: 1,884
    edited 2009-06-10 00:58
    Ntelos

    I would read up a little more on relays before I posted anything on a University Project!!!


    ___________$WMc%_______

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············································ BoogerWoods, FL. USA
  • NtelosNtelos Posts: 21
    edited 2009-06-10 05:05
    You are right about reading. I read how it works but there is so much to do for lots of projects (not really projects - more like assignments), so many times you cannot handle all of it.
    For this project - assignment i have done quire a lot, so if the relay doesn't work because i have to find one that draws less current, it doesn't matter that much!

    Thanks anyway!
  • EverQuriousEverQurious Posts: 48
    edited 2009-06-10 18:17
    I am having trouble re loading your JPEG but as Mike said above make sure the diode is correctly installed, otherwise it is just a dead short across the relay.
    Also It would be nice to see the internal wiring of the relay you are using to see what it is actually switching.
    I don't know how you tend to employ this circuit but remember if you want bi-directional control you will need to duplicate the circuit.
    This can be done two ways. the first involves 2 lines one controlling direction and the other controls the motors run / no run status.
    The second method that I used in my controller above also uses 2 lines but the controls motor activity and direction together.
    I personally like this method better because if you send it no signal, nothing happens, a high on line one runs forward and a high on line two runs bacwards.
    The other advantage is if you accidentally send a high to BOTH lines the motor will also not run. ( FOOL PROOF )
    I used the 5 volt mini 10 amp relays available at your local Radio Shack. ( which has the full internal connection drawing on the package. )
    At any rate see if you are using a NC or NO relay and try to provide an internal wiring / pinout on your relay.
    let me me know if this helped at all. And if you got her going.

    Good luck. and feel free to message me if I can help anymore.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    EverQurious
  • $WMc%$WMc% Posts: 1,884
    edited 2009-06-11 02:26
    "Ntelos
    You are right about reading. I read how it works but there is so much to do for lots of projects (not really projects - more like assignments), so many times you cannot handle all of it.
    For this project - assignment i have done quire a lot, so if the relay doesn't work because i have to find one that draws less current, it doesn't matter that much!

    Thanks anyway!"


    Have You checked the current draw with a meter? I think Mr Green may be on to something. The best way to tell is with a current meter.

    One last thing. If it doesn't matter that much!...Don't PM Me!!!


    ___________$WMc%__________

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············································ BoogerWoods, FL. USA

    Post Edited ($WMc%) : 6/12/2009 1:36:04 AM GMT
  • NtelosNtelos Posts: 21
    edited 2009-06-11 07:03
    I used a 5V relay instead of the 6V i used and it works fine.

    Now, i am going to try the EvenQurious's solution with the two relays for the bi-polarized function of the motor. All i need is a second 5V power supply.
  • NtelosNtelos Posts: 21
    edited 2009-06-11 12:19
    I designed the circuit in the image attached, for bi-polar function of the motor, but i doesn't work.


    Any suggestions?

    Do i need two power supplies or i can do it with one 5V DC?
    1850 x 967 - 86K
  • EverQuriousEverQurious Posts: 48
    edited 2009-06-11 18:13
    I am not sure I understand your circuit drawing. I don't see a ground connection for the relay coil or your motor connection. One thing I do notice is the motor should be connected to the relays common terminal not the NC or NO connections. The relays should be wired so that when neither is keyed both motor lines are negative. If relay one only is keyed that side goes positive to make the motor run forward. When only relay two is keyed IT goes positive to make the motor run backwards. As I said before if BOTH relays are keyed then both motor lines are positive and the motor will also not run. Review the diagram I sent and study it a bit more.
    Let me know how it goes

    PS. One power supply is all you need just DO NOT try to drive the relays ( or motors ) directly from the BS2 lines or supply. It will fry the I/O s.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    EverQurious

    Post Edited (EverQurious) : 6/11/2009 6:52:39 PM GMT
  • NtelosNtelos Posts: 21
    edited 2009-06-11 21:25
    The previous circuit was wrong. The new one is here.

    The two coils of the relays are connected each other and then to the ground.
    The other side of the coils is connected to each emitter of the 2N2222A npn transistor.
    The bases of the transistor are connected through the resistors to the two outputs of the controller and the two collectors are connected to 5V DC.

    The two n.o. are connected to each other and then to 5V DC.
    The two n.c. are connected to each other and then to ground.

    The two wires of the motor are connected to the two common pins of the two relays. The circuit you sent me doesn't show any connection of the motor to the ground.

    This is how i understood the circuit you sent me. If is anything wrong with it, i understood something wrong.
    Otherwise, perhaps i didn't understand where the common, n.o. and n.c. pins are on the relay.
    From the schematic of the relay (it is shown at the picture attached at the left - bottom), i understood that common are pins 8 and 9 (the first column). 11 and 6 are n.c. pins and 4 and 13 are n.o. pins. Is this correct or i understood the wrong way?
    1850 x 967 - 86K
  • EverQuriousEverQurious Posts: 48
    edited 2009-06-12 01:08
    Your text description sounds right. But the diagram still doesn't jive. The motor is tied to the two COMMON terminals of the relays and requires no ground as that is what the two relays are doing. ( simply reversing the polarity to the motor. As noted both relay NC connections go to ground and both NO connections go to +/- 5-6 volts. Your coil circuit looks ok and the 300 ohm verses my 100 ohm base resistor is not that critical. just don't go lower than 100 ohms.
    Try these changes and include where your motor (load) is in the circuit if you post it again.

    Note that my design uses 2 power sources ( one for the relay control circuit and one to power the motor/s ). For my application this proved beneficial, however both circuits will work just fine with only one battery/power supply. just tie both positive power lines together and both negative power lines together and omit one battery.
    also insure the circuit and the BS2 share a common ground.

    Hope this helps. Let me know.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    EverQurious

    Post Edited (EverQurious) : 6/13/2009 2:38:11 AM GMT
  • NtelosNtelos Posts: 21
    edited 2009-06-22 17:40
    I think that's wrong. I have the bs2 on a breadboard, but the circuit of the motor is on another breadboard and i pull two cables to connect the two breadboards.
    When i do this, when i try to load the program to bs2, the program does not recognize any basic stamps.
    If i disconnect the cables that connect the two breadboards, then the program recognizes the bs2.

    So, i will try to transfer the motor circuit to one breadboard
  • EverQuriousEverQurious Posts: 48
    edited 2009-06-24 03:26
    The motor/relay control circuits may share the same supply but the BS2 needs it's own and only the grounds of both boards should be connected.
    Hope this helps and keep me posted. jumpin.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    EverQurious
  • EverQuriousEverQurious Posts: 48
    edited 2009-06-29 04:31
    Here's the last word on the relay motor controller. I simplified it further by using just one battery for both relay coil circuit and motor supply. Simply connect the two inputs (forward / reverse ) to your desired BS2 ports and connect a ground wire from this circuit to the BS2 supply ground. Set one line high and the motor runs forward. Setting the line low stops the motor. Set the other line high and the motor runs backwards. For testing the board without the BS2, simply connect both inputs one at a time to the positive side of the battery to insure the circuit is working before you connect the 3 BS2 lines (fwd signal, rev signal, and ground. ) Look at the new drawing and see if it makes more sense
    I have found the RadioShack mini 10 amp contact relays rated at 5 volts and this circuit as a whole will run on anything from 5 to 9 VDC.

    Best of luck

    OH. Please excuse the typo on my drawings. The transistors are 2N2222 NOT 2N222. I'm sure everyone caught that boo boo.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    EverQurious
  • NtelosNtelos Posts: 21
    edited 2009-07-02 21:05
    I tried the last circuit and it really worked!!

    Thank you for your time!
    It really helpped!

    Thanks again!
  • AMPEDAMPED Posts: 3
    edited 2009-08-26 16:13
    freaked.gif·Anyone is there a cource code for this controller. I like the way it works . I am new at this but have some experience in electronics need help with source code . Thanks AMPED leathercrafter@charter.net

    Post Edited (AMPED) : 8/26/2009 6:41:21 PM GMT
  • EverQuriousEverQurious Posts: 48
    edited 2009-08-27 00:07
    If you have the Basic Stamp Editor I recommend reading the "Whats a Microcontroller" text. Both the editor and the WAM files are available as free downloads on the Parallax site. The only real commands you will need for this controller are the HIGH, LOW and PAUSE commands. All are explained fully in the text. If you need specific help with this circuit let me know and I can provide a simple example program. Hope this helps, let me know. Good luck and much fun.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    EverQurious
  • AMPEDAMPED Posts: 3
    edited 2009-08-27 03:04
    Thanks EverQurious looks like i have to do some research. I really like the way this relay system works thanks again AMPED.
Sign In or Register to comment.