Shop OBEX P1 Docs P2 Docs Learn Events
Pause button for Robot arm and or function for multiple switches each performin — Parallax Forums

Pause button for Robot arm and or function for multiple switches each performin

SandhuamarinderSandhuamarinder Posts: 85
edited 2010-04-17 05:37 in Learn with BlocklyProp
Hi Guys

I am using this and it makes the arm stop where it is right now problem i had made it emergency stop but now whats about the pause so if i press another button it continues from there

i Var word
switch pin0
switch pin1

For i= 110 to 1100 step 1
If switch=0 then
Goto M1
Pulsout shoulder,i
pause 18
Next

M1:
Pulsout shoulder,i
pause 18
Goto M1

Now this what i am using for emergency stop but now i dont know how i can make it as a pause if i pressed the button again how i can continue again from where i was before this what i have to do

M1:
Pulsout shoulder,i
if switch1 = 0 then what stuck here

i am stuck how to continue from there where i was before.

Post Edited (Sandhuamarinder) : 4/12/2010 11:47:27 PM GMT

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-10 04:54
    1) Please do not start a new thread when this is just a continuation of your previous thread

    2) Did you read the message I wrote on 4/4 at 10:57? It will do something like what you want, not for when you press the button a 2nd time, but when you release it. It's pretty easy to modify what I wrote to make it work when you press the button a 2nd time.
  • SandhuamarinderSandhuamarinder Posts: 85
    edited 2010-04-10 05:18
    Ahhh sorry sir i still didnt got it
    I am too dumb does not get stuff easily.

    And i dont know how to deleate the topic can some one tell me.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-10 14:40
    If you've only just started a thread, you can delete it by clicking on the "X" icon in the upper righthand corner of your message. Once there's more than one message in the thread, you can't delete it. Only one of the forum moderators can do it at that point.

    Like I said, you have to reread the message. If you don't understand what I wrote, try to come up with specific questions about the technique and the parts you do and don't understand.
  • SandhuamarinderSandhuamarinder Posts: 85
    edited 2010-04-12 14:30
    Sir i had re read the message but i still didnt got anything.
    Sir can you just give me a quick example bcoz i am already left with a less time now

    And can some one tell me
    How to use or statement
    Like i wants to use. I wants eithier emergency button is pressed or pause button is pressed it should goto M2 do i have to use OR like that or i have to use / like this.
    Some one plz tell me i am running out of time and still lot of work do.

    For i= 110 to 1100 step 1
    If switch = 0 OR switch1 = 0 Then
    Goto M2
    Endif
    Pulsout shoulder,i
    Pause 18
    Next
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-12 14:43
    1) You can certainly say "if switch1 = 0 or switch2 = 0 then goto m2" and it will work the way you think. If you have a lot of these statements, you will probably run out of program memory though.

    2) In the message on 4/4, I suggested moving all of this testing for an emergency stop and the PULSOUT itself and the PAUSE with it all to a subroutine and calling that from the different loops in your program. This has two advantages over what you're currently doing. One, it saves program space. Two, it allows you to return from your emergency button testing loop so your program can continue (and the emergency button will cause a pause, not just a stop). If you just use the GOTO as you've shown in your most recent message, there's no way for the program to continue. You could do the following, but you'll quickly run out of program space as you duplicate this loop over and over again:

    for i = 110 to 1100 step 1
    do
    if switch2 = 0 then goto m2
    loop while switch1 = 0
    pulsout shoulder,i
    pause 18
    next
  • SandhuamarinderSandhuamarinder Posts: 85
    edited 2010-04-12 18:08
    Thanks for the help sir
    i had not tried new codes yet bcoz i don't have robot arm with me right now.
    Hope fully i will try it very soon and i will post the results.

    Post Edited (Sandhuamarinder) : 4/12/2010 6:27:28 PM GMT
  • SandhuamarinderSandhuamarinder Posts: 85
    edited 2010-04-14 04:26
    For i =110 to 1100 step 1
    if switch = 0 then
    Goto M2
    Puslout shoulder,i
    Pause 18
    Next

    M2:
    Pulsout shoulder,i
    if switch = 0 then
    Return
    Pause 18
    Goto M2


    Now i Got it what u are saying sir

    I will try it tommorrow and i will post the results

    Post Edited (Sandhuamarinder) : 4/14/2010 4:32:48 AM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-14 04:27
    You cannot have a RETURN without a corresponding GOSUB. Read the chapter on the GOSUB and RETURN statements in the Basic Stamp Manual or the Stamp Editor help files.

    Please reread the 4/4/10 message in the other thread. This cross-thread referencing is one reason why it's bad to start a 2nd thread on a subject rather than continue the discussion in the same thread.
  • SandhuamarinderSandhuamarinder Posts: 85
    edited 2010-04-14 04:32
    for i = 110 to 1100 step 1
    do
    if switch2 = 0 then goto m2
    loop while switch1 = 0
    pulsout shoulder,i
    pause 18
    next

    But sir if i am sitting in M2 which is like this
    M2:
    Pulsout shoulder,i
    Pause 18
    Goto M2

    Sir i am just wondering it will return with that up statement if i am sitting in M2 Loop if i had pressed switch2 just wondering i had not tested the codes yet. And it will start from same place if i pressed switch1= 0
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-14 04:44
    The way you have your code written, switch1 acts as a pause button. While switch1 is pressed, the program pauses and continues when switch1 is released. It won't maintain the servo's position (because you're not sending pulses to the servo). Switch2 acts as an emergency stop button. Once the program acts on switch2, it can't continue. The program will maintain the servo's position, but there's no return.

    If you move the PULSOUT and PAUSE into the DO / LOOP, the program will pause when switch1 is pressed and will maintain the servo position. In other words:

    for i = 110 to 1100 step 1
    do
    if switch2 = 0 then goto m2
    pulsout shoulder,i
    pause 18
    loop while switch1 = 0
    next
  • SandhuamarinderSandhuamarinder Posts: 85
    edited 2010-04-14 04:48
    Got it Sir.

    Sir i need ur brain. Can i borrow it for this project.

    U are awesome.

    Thanks alot sir
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-14 05:27
    Thanks, but I've just been working with this stuff for about 50 years. You learn a lot over time. I started with Amateur Radio when I was about 13, built a lot of electronic equipment using kits when those were popular. I was lucky to get to play with computers when they were just becoming available for business use and I studied Computer Science in college.

    You have a brain, you just need to practice using it more. You may not like to read manuals, but that can be a good way to learn, particularly when they're as well written as Parallax's. Get used to trying things out, particularly in robotics and computer stuff. Sometimes things work differently than they seem like they'd work on paper or with a simulator. You learn a lot from that sort of thing.
  • SandhuamarinderSandhuamarinder Posts: 85
    edited 2010-04-15 05:49
    Sir now new problem the pause i was using it only works till the time i hold it and i dont wants to use it like that in case if i pressed the stop it will stop there and what if i wants to continue from there. I wants to release the button once i pressed to stop it and again press it to continue its motion i think i can use counter for that to make that work.

    But i dont know how to make that work and i dont even have to figure it out right now. I have at such a critical situation.

    And sir one more problem. Like if i press the emergency button right it goes to m2 loop but i wants to pizeo electric speaker there to freqout siren so where should i put freqout in M2 loop. So that siren should also work and also one LED should blink and also my Alarm will work and arm should also stay at the same position.

    For i =110 to 1100 step 1
    if switch = 0 then
    Goto M2
    Puslout shoulder,i
    Pause 18
    Next

    M2:
    Pulsout shoulder,i
    Pause 18
    Goto M2


    if i do like this i get trouble i think arm falls down i remember i did that before but not remember what happened but something was wrong in there. Last time when i did this
    And i wants my RED LED to be blinking and by siren gets of and on. I can another subroutine in that for making siren and LED to make of and on but problem is my arm doesnt stay there. Sir i wants to solve this my self but problem is i am out of time now.

    M2:
    Pulsout shoulder,i
    freqout 1, 2000
    High LED
    Pause 18
    next
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-15 13:02
    One of the things you have to learn at some point is that, when you're out of time or close to it, you have to stop trying to add features to a project. In fact, when you're near a deadline, you have to switch to "cleanup" and "polish" mode where you stop adding anything new and just try to clean up little sloppy things or little errors.

    From your questions, it's clear that you don't really understand yet how to do some simple things in programming and, before you go on, you need to spend time learning the basics and working through a lot of the exercises in the introductory tutorials (like "What's a Microcontroller?" and "Robotics with the BoeBot"). If there's no time left to do this, then I'm sorry, but that's what you need to do.
  • SandhuamarinderSandhuamarinder Posts: 85
    edited 2010-04-17 05:37
    Sir you helped me alot with many problems in this project.
    Thanks for the help Sir.
Sign In or Register to comment.