Shop OBEX P1 Docs P2 Docs Learn Events
Vibration Circuit To Turn On Led, When Circuit Is Open. — Parallax Forums

Vibration Circuit To Turn On Led, When Circuit Is Open.

Tony11Tony11 Posts: 41
edited 2012-03-22 11:47 in Accessories
Hi

I need some help on programming the BS2 to use the (ZD02) vibration switch sensor and one led with resistor. When it is done, vibrating it will turn on the led for 3millsec. So what I am trying to do is. Set the BS2 and the vibration circuit and the led on A running motor. When the motor is turned off,(witch means the vibration switch is not moving) the led will turn on for 3millsec. Then the BS2 will reset, (So the motor is on and vibrating, the BS2 reads this using the vibration Switch, when the motor is stopped and not running the vibration switch will be off, the led will come on for 3millsec, then the BS2 will reset till, the motor is turned on running and then off.)

Can this be done with the BS2 ?


=: The http, that I have at the bottom of the page is the vibration switch sensor, that I would like to use.




http://www.aliexpress.com/product-fm/500825000-wholesale-ZD02-vibration-switch-sensor-module-for-smart-car-free-shipping-wholesalers.html

Comments

  • davejamesdavejames Posts: 4,047
    edited 2012-03-14 16:59
    Hello Tony - I don't see a problem with what you're suggesting. The sensor has a simple active-low interface.

    So the answer to your question would be yes, it can be done with the BS2.

    Setting the sensor's sensitivity to the vibration of your motor would be the only tedious part. Might need a scope for that.

    BTW - the BS2 doesn't have to be set on the motor. In fact, it might be better to position it off the motor in case the motor outputs a lot of heat. And that raises the question: what type of motor are you using?

    Regards...
  • Tony11Tony11 Posts: 41
    edited 2012-03-16 23:16
    Hi

    What kind of motor do I want to put the sensor on. I have A Maytag Dryer, that I want to know when it stops running. So the vibration switch sensor and the BS2 will set on the Dryer. When the vibration switch sensor knows when the dry is done, then the BS2 will turn the led on for 3millsec. then off.

    Pins one BS2
    (Vibration Switch = Pin1)
    (Led = Pin5)


    ' SimpleDryerSensor.bs2
    '{$STAMP BS2}
    '{$PBASIC 2.5}

    x VAR Word

    DO
    PULSIN 1, 1, x
    DEBUG CLS, ? x
    PAUSE 100

    ELSEIF (x < 300 ) THEN
    PAUSE 50
    LOOP UNTIL (x = 0)

    HIGH 5
    PAUSE 30
    LOW 5

    ELSE
    PAUSE 50
    LOOP





    So this is what I am shooting for is =

    When the dryer is off and BS2 and vibration switch sensor are on and setting on top of the dryer.
    (Led is off)

    When the dryer is on and running.
    (Led is off)

    When the dryer is on and running and then it stops.
    (Led is on for only 3millsec. then turns off)

    Thank You
  • davejamesdavejames Posts: 4,047
    edited 2012-03-17 09:10
    Hello Tony,

    IIRC, the vibration senso outputs a "1" or "0", not a pulse train. So setting Pin 1 to be an input, and then checking it to see if it's LOW would be sufficient.

    I'm not sure what you intended with the ELSEIF and LOOPING until x is zero.

    Also, if you're depending on actually seeing the LED light up with 3 milli-seconds of on-time, you're gonna miss it. Unless you're going to use that signal to drive something else.
  • Tony11Tony11 Posts: 41
    edited 2012-03-20 15:02
    Hi

    What I want to do is, when the dryer is off the Vibration Circuit is off. When the dryer is running the Vibration Circuit, it's output is 1. But the output, goes to 1 then 0 then 1 then 0. It flip flop's between 1 and 0. That is why I thought to use A pulse train, So it would have to start at 300 pulse's when the dryer is on and then sit there till the dryer goes off. wait untill 100 pulse's. Then the led would blink.

    All I am looking to do is, watch for the dryer to turn on in the program and watch for it to turn off, then blink A led. It sound easy, but it's not.
  • davejamesdavejames Posts: 4,047
    edited 2012-03-20 15:41
    ...the output flips? That sucks as that is not what the description says it's supposed to do.

    Looking again at the schematic, at adding some capacitance (experiment with the values) across the 104 cap may help in providing a static level.

    Do you have an oscilloscope to view the output of the sensor board?
  • Tony11Tony11 Posts: 41
    edited 2012-03-21 17:00
    I do not have an oscilloscope, or maybe there is some other way of doing it, that is easy. When something
    is moving A little bit, it will turn power on, and sitting still it is off.
  • davejamesdavejames Posts: 4,047
    edited 2012-03-21 23:29
    ...without a scope, I can't think of a way to check the output for a stable level.

    Maybe a Forum Wizard can chime in and make a suggestion.
  • Tony11Tony11 Posts: 41
    edited 2012-03-22 10:12
    Hey davejames Thanks for your help, for all the mail you sent back on the
    Forum's.
  • davejamesdavejames Posts: 4,047
    edited 2012-03-22 11:47
    Tony11 wrote: »
    Hey davejames Thanks for your help, for all the mail you sent back on the
    Forum's.

    You're welcome Tony...although I regret that we weren't able to resolve this.
Sign In or Register to comment.