Shop OBEX P1 Docs P2 Docs Learn Events
can PULSOUT cause interference?? — Parallax Forums

can PULSOUT cause interference??

AnnoyingAnnoying Posts: 50
edited 2010-04-21 16:27 in BASIC Stamp
I have had this issue for so long and have not found a solution! I will be so happy if this can be explained...So I am using xbees to communicate between two BS2's, which works very well. My program has an IF condition for the pulse·data received being greater than 3100, and it is supposed to remain in a loop until the received pulse value is below 2000. When I simply print out the word "hello" in the loop, it works as it should, prints the word repeatedly until the UNTIL pulse <2000·condition happens. HOWEVER, when I include the line PULSOUT 11, 770, the program exits the loop immediately after the condition pulse > 3100 is violated and does not remain in the loop. Because the program worked properly with·DEBUG "hello", I know the problem must be with PULSOUT, and I am spellbound as·to why this is. THANK YOU FOR READING THIS! tongue.gif

RX PIN 7 ' Receive Pin
TX PIN 6 ' Transmit Pin
pulse VAR Word 'received data value
HIGH TX ' Idle transmit pin
DO
SERIN RX, 84, [noparse][[/noparse]WAIT ("*"),pulse.HIGHBYTE,pulse.LOWBYTE]
·· IF pulse > 3100 THEN
·· DO UNTIL pulse <2000
····· SERIN RX, 84, [noparse][[/noparse]WAIT ("*"),pulse.HIGHBYTE,pulse.LOWBYTE]
··· PULSOUT 11, 770
··· DEBUG "hello"
·· LOOP
·· ENDIF
DEBUG ? pulse

LOOP

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-04-20 06:47
    "Interference" will not cause it to exit the loop, but if P11 is driving a heavy load, it could cause the Stamp to reset and start from the beginning. Try putting a DEBUG at the beginning of your program, ahead of the outer loop, to see if this is what's happening.

    -Phil
  • AnnoyingAnnoying Posts: 50
    edited 2010-04-20 07:23
    oh so how do you prevent the Stamp from resetting if the pin is driving a heavy load? I've never heard of that problem before.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-04-20 08:01
    -- by making sure your power supply provides enough current and is adequately filtered to prevent brownout, for one thing. And by making sure the load on individual pins or groups of pins does not exceed the device specs, for another.

    BTW, did you try the experiment I suggested?

    -Phil
  • AnnoyingAnnoying Posts: 50
    edited 2010-04-20 18:56
    ahh I tried the experiment and you're right about it resetting! thank you for the insight. so does this mean that the basic stamp isn't getting enough current? I have a servo with a high current draw connected to a 6 V power supply that is also shared by the basic stamp...so is the solution just to give the stamp its own power supply? you seem really knowledgeable, could you give me more information about the load on pins issue? If it helps, this is a link to the servo I'm using:
    http://www.superdroidrobots.com/shop/item.asp?itemid=670

    this is the BS2:
    http://www.parallax.com/Store/Microcontrollers/BASICStampOEM/tabid/135/ProductID/21/List/0/Default.aspx?SortField=ProductName,ProductName

    thank you so much!
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-20 19:07
    The problem is that the servo is drawing a lot of current and the battery and/or the wiring can't handle the load. The battery voltage sags below around 5V briefly and the voltage at the Stamp itself drops low enough for the Stamp to reset.

    The documentation for the servo doesn't say anything about the maximum current draw of the servo, only that it draws at least 700mA under very light mechanical load. You can be sure that it will draw at least 3-4 times that under heavy load or when first starting up under light load.

    You may need to give the Stamp its own power supply. Make sure all the grounds are connected together.

    If your supply should be adequate, you may need to provide a direct connection from the Stamp to the power supply. You may want to provide some filtering (like a 1000uF electrolytic capacitor) across the power supply leads at the Stamp.
  • AnnoyingAnnoying Posts: 50
    edited 2010-04-20 19:19
    right now the Vin of the Stamp is directly connected to the 6 V supply, are there any more tests I can do before I jump into getting a separate power supply? would a capacitor really help? so inconvenient, ahhhh!
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-20 19:49
    I can't answer your questions because I don't know anything about your power supply other than it supplies nominally 6V. I also don't know what the peak current demand of the servo might be. It's easy enough to try a separate power supply. The Stamp will run fine from a 9V alkaline battery, at least for a couple of hours. You'll know quickly whether a separate supply would solve your problem.

    Something else to consider would be noise conducted into the control signal line from the servo. It's probably not what's causing the reset, but try a 1K resistor mounted close to the Stamp between the I/O pin and the servo's control line.
  • AnnoyingAnnoying Posts: 50
    edited 2010-04-21 03:35
    THANK YOU SO MUCH, IT WORKS NOW after giving the Stamp its own 9 V supply! i'm still curious about some things though--before I fixed the problem, I had a program that just consisted of the pulsout command, and it worked. so why would this current draw be different than a program that does other things before it gets to the pulsout command? also why do you need to connect the grounds together of the separate power supplies?
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-21 04:01
    1) If you had a program consisting of just a PULSOUT you probably didn't have an xBee connected. Although an xBee doesn't draw that much current, it may have been enough to make a difference.

    2) A single PULSOUT doesn't cause much movement of a servo since the servo will shut down if it doesn't receive another pulse within a little more than 20ms. Your program won't work very well either since I don't see it repeating the pulse within 20ms. If the info comes in fast enough from the xBee, that might happen, but the DEBUG statement will probably push the timing beyond 20ms.

    3) Any voltage is determined in reference to two locations in a circuit. By convention, we refer to a single reference point as the circuit's ground point. If you power the Stamp from a separate supply and there's no common ground connection, what determines the voltage that the Stamp's I/O pins see or produce? The Stamp's PULSOUT statement produces pulses that go from 0V to 5V in relation to the Stamp module's power supply ground. What voltage would the servo see if there's no common ground? Nobody knows. In any event, it wouldn't work as expected.
  • sumdawgysumdawgy Posts: 167
    edited 2010-04-21 16:27
    Ah, the power ripple. (I know i'm a junior member....But i have 2 cents for the theory here.....)

    Another thought is to give the Stamp a small filter cap at it's VDD output. Since that's hard wired between regulator & stamp functions..The power can't bleed back into the main circuit. AND, This will protect against any ripple the regulator gives while it's adjusting to sudden volatge fluctuations from the "shared" supply voltage.

    If you're wanting a larger cap...I would suggest a diode/resistor combo. Use the diode to allow high draw demands by the Stamp. Meanwhile, the properly valued resistor will limit the charge current from the onboard regulator to avoid damaging it. Just schedule in a few moments of initial inactivity after power-up...while the cap charges.

    My personal nominal stamp circuit includes a small cap on the VDD (Just out of paranoia/training). My military radio systems used shared power supplies with diode switching between Internal & External power. That way, if one failed/choked the others could take the slack. for as long as needed. But, the Caps were the REAL lifesavers.
    (BTW i am aware that he's NOW using a seperate supply.· This is just FFT.)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Before you criticize someone, walk a mile in his shoes. That way if he gets angry, he'll be a mile away and barefoot. - unknown

    Post Edited (sumdawgy) : 4/21/2010 4:36:30 PM GMT
Sign In or Register to comment.