Shop OBEX P1 Docs P2 Docs Learn Events
Emergency stop for robotic arm. — Parallax Forums

Emergency stop for robotic arm.

SandhuamarinderSandhuamarinder Posts: 85
edited 2010-04-05 13:45 in Learn with BlocklyProp
I am working on Robot arm project. My professor is asking if you ·press the Emergency button robot arm should freeze. The arm doesnt freeze with what i am doing so. Thats the program·which i am working on.

i var word

Goto main:

For i = 110 to 1100 step 1
if switch= 0 then
GOTO·M1
pulsout shoulder,i
next
Goto Main

M1:
For i = 500 to 1100 step 1
pulsout shoulder,i
next

M1 loop is use less but it does what ever it needs to do but it doesnt freeze.




Post Edited (Sandhuamarinder) : 4/5/2010 2:47:10 AM GMT

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-04 04:26
    Usually when you have an "emergency freeze" button, that button turns off the power to whatever you have. If there's a heavy weight on the arm, the servo will not hold its position, so your program has to maintain the servo's position. You do that by sending out the same pulse width over and over again.

    In what you showed, the current servo position is in the variable "i" and your program exits from the movement loop when the switch on pin 0 is turned off (logic 0). The routine M1 should just output the same value ("i") every 20ms like

    M1:
    pulsout shoulder,i
    pause 20
    goto M1
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-04 14:34
    There is no "by writing some few commands how can I freeze it". There are no "freeze" commands. You have to think about what is meant by "freeze" as I've mentioned already and do that.

    Think about what your FOR loops do:

    For i = 110 to 1100 step 1
    pulsout shoulder,i
    pause 20
    next

    This moves one servo over a range with control pulses from 0.22ms to 2.2ms in steps of 0.002ms which should take about 20 seconds to do at 20ms per step. Somewhere you have an emergency button which, when pressed, causes I/O pin 0 to go to ground, so you can add a test to every PULSOUT loop as you've done:

    For i = 110 to 1100 step 1
    if switch = 0 then goto M1
    pulsout shoulder,i
    pause 20
    next

    When the emergency switch is pressed and this test succeeds, the program jumps to M1 with the most recent value of "i" still in the variable. Every place in your program that moves this servo should leave "i" set to the last value used for a pulsout and go to M1 if the switch is closed. For M1, use the loop that I've shown above. This will lock the servo to the last position used until the Stamp is reset.

    If you have multiple servos, use a different variable for each one for any loops and add other pulsout statements to the M1 loop for them like:

    M1:
    pulsout shoulder,i
    pulsout elbow,j
    pause 20
    goto M1

    Think about what I'm suggesting. Work out in your mind what happens. Try it. See what happens.
  • SandhuamarinderSandhuamarinder Posts: 85
    edited 2010-04-04 14:59
    Great

    It worked

    Thanks Alot
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-04 15:11
    Please do not delete your original message. You're not the only person with this sort of question and I'm not just answering your question for you personally. Hopefully someone else with a similar question would read this thread in the future and find the information they need without needing to post another question.
  • John R.John R. Posts: 1,376
    edited 2010-04-04 16:03
    So, If I understand what you're (Sandhaumarinder) saying, is that it's OK for you to "cheat" and get outside help, but it's not OK for your classmates to do the same?

    There is a thin and fuzzy line we collectively face here on the forums when it comes to questions having to do with classwork on any level. There is an obligation to help those who are working in our fields, while at the same time, there is also a conflicting obligation "not to do the work for the student". Somewhere, there is an honorable middle ground that we all try to find, guiding students to the answer, but not outright doing the work.

    As a student works through the problem, and shows that they are at least trying to not just "copy code", but understand what's happening, more and more details are revealed.

    When a student such as this starts "playing games" like this, it becomes very discouraging to those of us trying to find the right balance. The entire premise of these forums is to share knowledge, or as the statue in front of Fraber College says "Knowledge is Good".

    I've seen fewer problems like this on the parallax forums, but I can say that on a couple of other forums, there is not a whole lot more discouraging than posts along the lines of "My semester long project is due next week, how do a make my project [noparse][[/noparse]insert specifics here]". One things that does top this is something along the lines of "I've deleted key information from my post so that anyone else can't use the information".

    Hint to original poster: Most of your classmates have probably been working on this for a while, and had the answers long ago. I could be wrong, but my experience suggests I'm not.

    The worst part about this stuff is that the folks like Mike Green who answer the questions rarely, if ever get credit. If they did, the number of degrees, both undergraduate and even graduate, they would have would indeed make a very nice "ego wall" display.

    Continuing on my "editorial" comments, I can say, one of the most rewarding things I've ever experienced came from a semester long tutelage of a graduate student on another forum (robotics related), he posted a link to his final thesis. Listed as "advisers", with the same provenance as the professor guiding the graduate student on his thesis were the names of a number of the forum members (including myself). This student got what things were about - learning and sharing - not just "give ME the answers". Based on his grade and award of a Masters Degree, this was a lesson not lost on his professors.

    Mike: Thank you for all your time and effort on these forums, and please don't let his jerk discourage you! I suspect that in the end, it's the idiots like this who wonder why they don't make it very far in the "real world" once they graduate (if they graduate). I guess we need to add another member to the "entitled society"...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John R.
    Click here to see my Nomad Build Log
  • John R.John R. Posts: 1,376
    edited 2010-04-04 17:44
    Selfish. The only word I can think of.

    As Mike stated, he didn't just answer the question for your benefit. This is a forum for Sharing.

    The job of a professor is to teach you how to learn, not teach you everything there is to know, so don't blame the professor for "just" teaching you BASIC.

    Typical of the "Entitled Society". Give ME the stuff, and do MY work FOR ME, and DON'T LET ANYONE else have it, because even though YOU DID IT for me, its MINE, all MINE!, and when all else fails blame somebody else ("My proffesor had teached us Basic just BASIC nothing else" and "He said sorry man do the research and figure it out by your self. So what was that.")

    Did it ever occur to you that somebody else may have seen other ways to improve your program, and helped further, had you left things in place and had a better attitude? Did you ever hear the phrase "don't burn your bridges"? How much are people here going to be willing to help you in the future?

    I'm sorry, I personally find the attitude disgusting. If you don't want to share, don't ask for help in a public open forum.

    Moderators: If you find it necessary and/or desirable to delete my rantings, I understand. The Original Poster has hit a sensitive nerve...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John R.
    Click here to see my Nomad Build Log
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-04 18:06
    First of all, you never actually posted your program, just very small fragments of it, enough for a discussion of principles. What you did in deleting your original message was similar to going to the library, taking a reference book with important information for a test, and cutting out the portion of the book with the information in it so others would not have the benefit of it. Admittedly, deleting a message you posted to a public forum is not quite the same as defacing the property of a library, but it's similar. I went to a college that had an honor system that would not have tolerated either. Any unacknowledged help on a class project would be grounds for discipline including a possible F on the project. If discovered, defacing a library book would result in dismissal from the college with the facts of any investigation made a permanent part of ones public academic record.

    One of the things about an honor system is that you have to behave honorably even if others do not. You have an obligation to report any knowledge you have of others' dishonesty to the authorities and they have an obligation to investigate and punish any infractions.
  • BeanBean Posts: 8,129
    edited 2010-04-04 22:06
    Sandhuamarinder,
    Have you seen any other "CLOSED THREAD" titles in this whole support forum ?
    No you have not, there aren't any. So I have change the thread title back to what it was.

    What you have done is very selfish. If all the members had your attitude no one would get any help.

    And to claim that WE are harassing you just shows you're ungrateful mindset.

    Many other members in this forum get paid very well to help clients. They provide their services here out of compasion. Something you have none of.

    When/if you grow up you will find that there is much more satisfaction in helping others than there is in winning.

    If you care to pay close attention you will learn much more from this thread than how to implement an emergency stop. You will learn a very important life lesson.
    I truely hope that you do.

    Bean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Use BASIC on the Propeller with the speed of assembly language.
    PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

    March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There are two rules in life:
    · 1) Never divulge all information

    Post Edited (Bean) : 4/4/2010 10:16:44 PM GMT
  • Peter KG6LSEPeter KG6LSE Posts: 1,383
    edited 2010-04-05 01:04
    IMHO it depends on the size of said arm .... I Would allmost never rely on a MCU to perform E-Stop functions .. it said arm is like the GE Fanucs In my colleges lab I would preferr a normal ESTOP in the main drive PSU contactor this keeps the logic guts alive but kills the juce to the drive ... this is how real industral robots do it .... if its just RC servos then a "soft eStop" might be ok .........

    Peter KG6LSE

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "Carpe Ducktum" "seize the tape!!"
    peterthethinker.com/tesla/Venom/Venom.html
    Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway. —Tanenbaum, Andrew S.
    LOL
  • SandhuamarinderSandhuamarinder Posts: 85
    edited 2010-04-05 03:00
    Ok everything is working fine but now new problem. My loop is becoming big and loop is losing control for every milli second with that emergency command and which is making my arm hitting the ground only when it goes to grasp the part from the floor. So now i should just remove that command from the loop or what.

    i am using this

    i var word
    Switch pin 0

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

    M1:
    Pulsout shoulder,i
    pause 18
    Goto M1

    This is what i am using any way to figure it out. And my ic memory is almost full.

    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-05 03:49
    You really need to post your whole program (as an attachment to a message). It's really difficult to help you if you only supply small fragments of your program, particularly since you're now talking about a problem that doesn't seem to be related to your fragments. The issue of how to make a program smaller also depends on your coding style which can only be seen with a larger view.
  • SandhuamarinderSandhuamarinder Posts: 85
    edited 2010-04-05 04:44
    Sir i think i am using command

    if switch = o then

    goto m1

    endif

    i think this command is the problem i have to arrange it in some order to fix that falls of arm. Bcoz of this command it is lossing control

    Like if you use debug with in the loop your robot arm shakes and gives vibrations becoz of that bcoz debug takes some mille seconds from that loop to debug it i think same here but this is taking less milli seconds thats why no vibrations. And loop is running bigger each time stamps checks it. Is the switch pressed or not. And there it is spending some milliseconds and loop is becoming bigger i think and it loose control at some points.

    I am not sure if i am right.

    But i think thats the problem for that. i had pm you my whole program but i think the problem is just in the loop the way i am using it.

    Biggest problem·now my brain is not working any more. I am wroking on this project from last 3 days continously writting the code.

    And other problem is due date of project is close. Boom shakehead.gif
    And its 4 people project i am working alone here. Rest are not helping me.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-05 04:57
    Sandhuamarinder posted his source code in a private message. For the reasons I've mentioned before, I generally don't help people privately and I'll post my replies here for others to have the benefit of them, but I'll give more general examples rather than using his code.

    I notice that you have 5 servos. This is a lot for a Stamp to control, but you're not doing anything really complex with them, so it should work. I had mentioned before that you need to have a separate variable for each servo and you need to keep these variables up-to-date so that the servos can all be locked in their position when necessary. In some of your loops, you use constants for some of the servo pulse widths and you don't update the variables. For simplicity and to save code space, you might consider using a single subroutine for moving the servos like this:

    a VAR word
    b VAR word
    c VAR word
    d VAR word
    e VAR word
    ' ***** This is an example of a typical loop in your program
    b = 400
    c = 600
    d = 750
    e = 1000
    for a = 110 to 1100 step 1
    gosub moveit
    next
    ' ***** Here's the subroutine to do the actual servo movement
    moveit:
    pulsout servo1,a ' output a pulse to each of the servos
    pulsout servo2,b
    pulsout servo3,c ' these will range from 0.22ms to 2.2ms
    pulsout servo4,d
    pulsout servo5,e
    pause 20 - (a+b+c+d+e)/500 ' adjust pause for the pulse widths
    if emergency = 0 then goto moveit ' stay in this loop if emergency
    return

    Note that the variables are always up to date with the current position.

    The servos need a control pulse about once every 20ms. The pause statement takes into account that the control pulses take time and the overall pause needs to compensate for this, particularly when you have more than 2 or 3 servos. Using a subroutine also allows you to build in the emergency switch test in one place rather than having it repeated throughout the program.

    Note that, if you turn off the emergency switch (so it's value is 1), the program will continue where it left off. This may not be what you want, particularly if the emergency switch is a pushbutton rather than a toggle switch. If this is the case, you'll have to change the subroutine. You should be able to figure out how at this point.
  • SandhuamarinderSandhuamarinder Posts: 85
    edited 2010-04-05 05:07
    Sir thanks for the help

    ·i try fixing·it now·and i will notify as the problem get fixed.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-05 05:31
    Note: You have some long text messages in your program. If you get close to running out of room, shortening the messages is an easy way to free up some memory.
  • SandhuamarinderSandhuamarinder Posts: 85
    edited 2010-04-05 06:53
    Sir, I try making them short but still there is a problem cant make anymore short

    ERROR after doing all that

    Data occupies same memory as program

    i am now Out of memory shakehead.gif· Not a good sign.

    I have 2 stamps with me if someone can teach me how to use 2 stamps together then problem would be solved in easy way and i can write more codes. PLZ be at student level i am very dumb kid. I doesnt get complex stuff easily

    Does any one know how to connect to stamps together and which pins i have to connect together of the stamps to make a commuication between each other and how i will give them a commands i am using basic stamp. BS2 version 2.5 Do i have to download program·in both stamps or in just one. How it will work can some put some picture of connection of pins or just describe·in detail·and some short example of program plz so i can understand how i have to serin and serout.

    And one another question i am trying to pulsout 2 servos now in this way to give both of them motion so i can reduce my program size.

    i var word

    j var word

    For i = 110 to 1100 step 1

    ·· For j = 500 to 1000 step 1

    Pulsout shoulder,i

    Pulsout elbow,j

    Pause 20

    next

    next

    I am geting vibrations which is obvious How i can make 2 servo move in the loop with out vibration this will reduce my program size and· will also look better to see. Arm doing 2 moves together.

    Post Edited (Sandhuamarinder) : 4/5/2010 8:00:57 AM GMT
  • BeanBean Posts: 8,129
    edited 2010-04-05 11:09
    Welcome back.

    If you want the two servos to move at the same time, try something like this:

    i var word
     
    For i = 0 TO 500 step 1
      Pulsout shoulder,110 + (i * 2)
      Pulsout elbow,500 + i
      Pause 20
    next
    
    

    That should move the shoulder and elbow servos at the same time.·You can play around with the STEP value and PAUSE value to get the speed right.

    As for being out of memory, see if you can put repeated code into a subroutine.

    Bean


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Use BASIC on the Propeller with the speed of assembly language.
    PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

    March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There are two rules in life:
    · 1) Never divulge all information

    Post Edited (Bean) : 4/5/2010 11:14:03 AM GMT
  • SandhuamarinderSandhuamarinder Posts: 85
    edited 2010-04-05 12:00
    Thanks sir for the help.

    Nice. I am learning here alot.

    if some one can teach me how to connect 2 stamps together that would be great. lol.gif

    2 basic stamps together (BS2) both of same (version 2.5)

    Post Edited (Sandhuamarinder) : 4/5/2010 12:30:15 PM GMT
  • BeanBean Posts: 8,129
    edited 2010-04-05 12:45
    Well, the problem with connecting two stamps together is that handling the communication between them is pretty complecated and seems to undo the advantage of having two stamps.

    I'd keep trying to accomplish what you need to do with a single stamp.

    I understand that you do not want to show all of your code, and that's fine. But is hard to give you advise on making the code smaller without seeing all of it.
    Basically you want to look for section that are the same, and put that code into a subroutine.

    Bean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Use BASIC on the Propeller with the speed of assembly language.
    PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

    March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There are two rules in life:
    · 1) Never divulge all information
  • SandhuamarinderSandhuamarinder Posts: 85
    edited 2010-04-05 13:04
    Sir i am already using subroutines.

    Thats the problem.

    Ok so now i will try working 2 servos movement at same time it will save some space. I will catch you guys soon.

    I was just thinking to do that bcoz one of my class mate did it . I dont know how. And i try asking him he just dont wants to give idea to anyone bcoz of the prize lol.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-05 13:11
    Hooking two Stamps together will not solve your problem (too much program). If you're just interested, there is a pair of articles (columns) in Nuts and Volts Magazine, Volume 2, Numbers 55 and 56: www.parallax.com/tabid/272/Default.aspx.

    The reason you're getting vibrations is that the time between control pulses is too long. These servo control pulses have to occur at least 50 times a second or the servo will turn itself off until the next pulse comes along. The constant turning on and turning off causes the vibration. If you have a PAUSE 20 plus two PULSOUT statements that each take about 2ms, that's a total of 24ms which is too long for some servos. That's why I wrote the expression in the PAUSE statement the way I did earlier ... to compensate for the variable delays from the PULSOUT statements so the total time between pulses stayed around 20ms.
  • SandhuamarinderSandhuamarinder Posts: 85
    edited 2010-04-05 13:45
    Thanks for the help sir
    Connecting 2 stamps is complicated kind of stuff Seems like i cant do that now with small amount of time what i am left with. Needs alot of time understanding that what i see in manual RS- 485 so stessfull etc etc. Slave stamps and master.

    Now i am trying figuring out the pause problem but sir i tried doing that what you said above using var word. But i am running out of memory new problem there sir.

    Now i am just frustrated from this project mad.gif . New problems again and again. Cant solve this any more shakehead.gif· break time now.redface.gif

    After the break may be things get better. And my brain which is working on low battery now·needs recharging.

    Thanks for all of your Help Mike Sir and Sir Bean

    Post Edited (Sandhuamarinder) : 4/5/2010 1:52:45 PM GMT
Sign In or Register to comment.