Shop OBEX P1 Docs P2 Docs Learn Events
Trouble with switch (button) and stepper — Parallax Forums

Trouble with switch (button) and stepper

CyrussvallCyrussvall Posts: 8
edited 2010-04-28 20:17 in Propeller 1
Hi everyone

I'm having some trouble with a microswitch that i have connected to my propeller chip. The thing is that i have a stepperdriver(keling) and steppermotor connected to the board as well. When i have the driver and motor connected and running the switch acts as if ot is pressed randomly.

I have the switch connected as sutch:


3.3 V ---- switch
Pin 5
|
---- 10K ---- GND


code:


repeat

Axis.MoveInc(-1,True)

if ina[noparse][[/noparse]INTERRUPT] == 1
do something



Is there anyother way to do this that is not affected from the stepper?

Everything works great when i unplugg the stepper.

I hope someone knows a way!

Many thanks!
/Lars

Sorry for the bad english (from sweden)

Comments

  • CyrussvallCyrussvall Posts: 8
    edited 2010-04-28 19:09
    hmm, my schematic of the connection ended up wrong. The ( 10K --- GND )is supposed to be after the switch.
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-04-28 19:09
    You connected the resistor to the wrong side of the switch. The resistor has to pull down the PIN when the switch has not been pushed. If the switch is pushed, the direct connection to 3.3V will set the PIN to high-level.

    As you have it in the picture the PIN is free floating and can be affected easily by the stepper.
  • BTXBTX Posts: 674
    edited 2010-04-28 19:11
    My idea is:
    Check your hardware configuration, How do you are powering the stepper ?? from the same +Vcc ??
    Chek wirings, use decoupled capacitors, it seems that you've noise in the propeller board.
    Are you using a resistor in the pchip input,... so down a bit it. (1Kohm)
    Do a doble check for the input at the code. like a:

    if ina[noparse][[/noparse]INTERRUPT] == 1
    waitcnt(clkfreq/1000+cnt)
    if ina[noparse][[/noparse]INTERRUPT] == 1
    do something

    Only my oppinion.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Regards.

    Alberto.
  • CyrussvallCyrussvall Posts: 8
    edited 2010-04-28 20:03
    Yes, the board and the stepper is connected to the same powersupply. I have tried to read up on these decoupled capacitators. Any idea on what kind to use?
    I connected a 1Kohm resistor between the switch and pin5. The only difference is that now it dosent react to the switch at all when i have the stepper powered. When it's unplugged it works just fine.

    Are there anyother way to connect a button. How does the built in reset button work on the probeller. Are there any way to do the same on another button?
  • CyrussvallCyrussvall Posts: 8
    edited 2010-04-28 20:12
    After a bit more testing i have found out that the switch works with the stepper connected in the beginning of the repeat loop.

    repeat
    Axis.MoveInc(-1,True)

    if ina[noparse][[/noparse]INTERRUPT] == 1
    waitcnt(clkfreq/1000+cnt)
    if ina[noparse][[/noparse]INTERRUPT] == 1
    do something

    After a while, about 2 sec the stepper starts to "sound" different. Sounds like it starts to move smother, like the repeat loop executes in a more exect timeline.
    After that 2 sec, there is no response from the switch...
  • LeonLeon Posts: 7,620
    edited 2010-04-28 20:17
    Use a separate power supply for the stepper and driver.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Leon Heller
    Amateur radio callsign: G1HSM
Sign In or Register to comment.