Shop OBEX P1 Docs P2 Docs Learn Events
Relay with the hiccups — Parallax Forums

Relay with the hiccups

Joe-BotJoe-Bot Posts: 24
edited 2013-04-18 20:58 in General Discussion
I’m having trouble with my relay. I added a LED to the circuit, to make the issue more visual.
When I set the I/O pin on my basic stamp to HIGH 7 and follow it with a PAUSE for the duration I need, it works fine, with no hiccup. But I can’t program any maneuvers for the Boe-Bot until that duration is over. I tryed putting it on HIGH 7 without a PAUSE duration and I see the LED flicker like a slow pulse, in conjunction with the hiccup on the music module. So can I get a constant HIGH 7 without adding a PAUSE duration? Or is there something I could add to the relay circuit to absorb the momentary power drops.

I was reading the blog; Looking for simple power relay, by JBWolf, and he said he was directly driving the relay with a capacitor to buffer any fluctuations.
I’m wondering if I could use a capacitor, where to put it, and what size should I use?
Joseph.
1024 x 861 - 46K

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-16 21:06
    How are you powering your circuit? If it's a battery, it may be weak. A capacitor won't help if there's not enough power to begin with.
  • Joe-BotJoe-Bot Posts: 24
    edited 2013-04-16 21:24
    The batteries in the music module I believe are 3 - 1.5 button batteries, and the basic stamp are 4 - 1.5 double A
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-04-16 23:19
    Well, the wiring appears right, but it seems you are expecting the double AA cells to power the Boe-bot's servo motors as well. I doubt if they have enough power.

    The relay coil itself is usually about 60ma of load, but your reed relay is even less.

    You could run a few tests.

    A. Check your battery pack for voltage without load.
    B. Check your battery pack for voltage with relay coil load
    C. Check your battery pack for voltage without relay coil load and with the BOE-bot servos rotating. (This last test is most important)

    The whole problem may just be that your batteries are either not fresh or not powerful enough. Fresh alkaline batteries work best. Rechagible batteries may have lower intial voltages and not last as long.

    What to do? If you really want to continue with AA cells, buy one of Parallax's 5 cell holders for the BOE-bot. Or switch to a 7.2 volt Lithium ion pack.

    Why the hiccups? The battery drops below the reset voltage for the BasicStamp, everything is reset and it tries again, and again. This is a very common 'brown out' failure mode.
  • Joe-BotJoe-Bot Posts: 24
    edited 2013-04-17 17:03
    So I charged the AA batteries and tried again with the same results. By the way the music module plays fine on it’s own.
    Also I’m testing the relay with the switch in the #1 position so the servo’s don’t come into play. And if the stamp was resetting, it should sound the alarm, and it’s not.
    I can play the music module over and over again as long as I use a duration which is 27000 ms. long, but as soon as I take the PAUSE 27000 duration and LOW 7 away that’s when I see the hiccups.
    By the way thanks for your patients while I try to explain.

    So this is what I’ve programed;

    'Robotics with the Boe-Bot - TestMusic2.bs2
    'Test music modole Pin 7 on/off.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    DEBUG "Test Music Module"
    FREQOUT 4, 500, 3500 ' Signal program start/reset
    PAUSE 1000
    HIGH 7
    PAUSE 27000
    LOW 7
  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-17 17:59
    Since the relay powers the music module and the power has to stay on until it's done, you do need to leave pin 7 high that long. You can do anything else during that time period since pin 7 will stay HIGH until you change it (with a LOW). A PAUSE will also leave it HIGH.
  • Joe-BotJoe-Bot Posts: 24
    edited 2013-04-17 18:51
    Well mine without the PAUSE fluctuates, causing the music module to reset. Maybe I need to start looking for a latching relay.
  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-17 19:50
    You don't need a latching relay. It won't solve your problem. What does the music module do when the music is over? Does it stop (and go into standby) or does it repeat the music continuously until you turn it off? If it just stops, you can turn it off any time it's convenient (to save power). If it plays continuously, then you need to time the music so your program "knows" when to turn it off ... after a set period of time.

    If you want your robot to do something while the music is playing, you just turn the module on (with a HIGH 7), then go do whatever your robot needs to do and keep track of roughly how much time that takes. If you're using a BoeBot, you have some kind of main loop based on the 20ms requirement for control pulses for the servo motors. That gives you a 20ms time "tick" that you can count (each time through the main loop). When the counter indicates that 27 seconds or whatever has gone by, your program does a LOW 7 and stops counting.
  • ercoerco Posts: 20,256
    edited 2013-04-17 20:07
    Are you certain that your driver circuit is wired correctly ? And shouldn't the module trigger to play a complete cycle from a single, brief closing of the relay, maybe a quarter second? Here are 2 things for you to try:

    1) Drop your transistor bias resistor from 470 to 330 or even 220 to see if performance improves.

    2) Your 20 mA reed relay can be driven directly by a Stamp pin, no driver transistor. Just use the flyback diode, but forget the LED unless it's a 1 mA type.
  • Joe-BotJoe-Bot Posts: 24
    edited 2013-04-17 20:24
    The music stops when it’s done, but it keeps resetting, so who knows when it going to get done. And any maneuvers I program are going to be out of time the first time it resets
  • Joe-BotJoe-Bot Posts: 24
    edited 2013-04-17 20:35
    I had it set up without the transistor and the LED at first, but it did the same thing. So that’s when I tried the transistor to see if that would cure the problem. Then I added the LED to make the issue more visible. No it stops when you break contact and resets.

    I just tried something, from Pin 1 threw a 220 resistor, to a LED then Vss(-). At HIGH 1 without a PAUSE duration it has that same pulse like blink.
    Is there any way to stabilize that momentary power drop with out adding a duration?

    If someone could solve this little issue, well that would make my endeavor fun again, and I’d like to buy that person a drink.
  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-17 22:06
    The circuit you posted in #1 is correct and, as erco mentioned, you can do without the transistor and drive the relay (but not the relay and LED ... too much current) from a Stamp I/O pin. I've done that lots of times ... works fine. Your program should work (keeping in mind the comments I've mentioned before). Unfortunately, the whole setup doesn't work, so there must be something not mentioned or something you've shown that's not really what's there. We've already suggested the most common problem that causes this sort of behavior ... an inadequate power supply. Adding a capacitor to the supply lines is unlikely to help. Perhaps posting a complete schematic will help us. Perhaps posting several good photos of the setup will help catch a discrepancy.
  • ercoerco Posts: 20,256
    edited 2013-04-18 02:45
    I wonder if you might need a normally closed relay instead of normally open. Is this sound module out of a greeting card? Those typically only play while the card is open, which would explain why you have to activate the relay for the entire 27 seconds. If you keep the relay closed for say, 40 seconds, does the song repeat?

    BTW, if your program just ends, the BS2 resets every 2.5 seconds, which would blip your relay that often. Is that the stuttering you are seeing?
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-04-18 08:04
    The 2n2222 transistor does have an internal voltage drop of 0.7 to 1.0 volts at saturation. So if your battery voltage is low to begin with, you may just not have enough voltage to hold the reed relay contacts in proper position.

    Will these reed relays behave well at 3.5 volts?
  • Joe-BotJoe-Bot Posts: 24
    edited 2013-04-18 19:00
    That’s exactly what it’s out of Robbie the robot, and it was activated by a photocell when you opened the card. Then when you closed the card, it would stop and reset. Also if you left it open it would not play again. But I’m not following you on the normally closed relay.
    And yes that must be the stuttering I ‘m seeing, it’s about every 2.5 seconds. That’s what’s causing my blip, :smile: how can I cure that?
    1024 x 768 - 49K
  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-18 19:27
    At the end of the program, put

    DO : LOOP
  • Joe-BotJoe-Bot Posts: 24
    edited 2013-04-18 19:46
    Okay problem solved.
    Boy do I feel dumb, so all I had to do, was get out of the test mode and program so maneuver (like Mike was suggesting) and the basic stamp would not reset every 2.5 seconds. You know I had some maneuvers programed and I ran them, now I’m not sure what happened. I know I wasted a lot of time. Live and learn.
    Okay so I owe you both a drink. Now I have a good reason to come to the convention. :thumb:
  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-18 20:34
    As to why ... as erco mentioned, when a program just ends, the Stamp goes into a mode where it sleeps for a while (about 2.3 seconds) to reduce the power consumption. When it wakes up from this sleep, the I/O pins all get set to input mode briefly before going back to the state they were in at the end of the program. In the case of a relay or transistor and relay, it'll turn off for an instant. The Basic Stamp Reference Manual discusses this under the END statement.
  • Joe-BotJoe-Bot Posts: 24
    edited 2013-04-18 20:58
    You know I read that some where. I remember the part about reducing power consuption, but it didn't sink in, Apparently, but I'll remember it now.
    Thanks again for your patients.
Sign In or Register to comment.