Shop OBEX P1 Docs P2 Docs Learn Events
STOP and KILL functions implementation — Parallax Forums

STOP and KILL functions implementation

4Alex4Alex Posts: 119
edited 2009-07-15 22:10 in Propeller 1
Good morning all,

I am seeking some learned advices on the best way(s) to implement two functions: STOP and KILL. The STOP function would bring the propeller to a complete halt, preferably with very subsequent power consumption. The only way to make the propeller working again would be cycling the power switch OFF and then ON again. The second function KILL would delete the eeprom's firmware and then bring the propeller to a complete stop. These two functions are intended as safety measures for robotic devices in my home automation project in case something goes completely wrong.freaked.gif

At this point, I implement the STOP by calling an eternal loop but this is not a stopped propeller and power consumption is consequent. I implemented the KILL by rewriting the lower part of the eeprom with 0's and then rebooted the propeller, but perhaps there's a better (and faster) way to do this.

Thanks in advance for any suggestions.

Cheers,

Alex

Comments

  • MicrocontrolledMicrocontrolled Posts: 2,461
    edited 2009-07-15 18:15
    Why would erasing the EEPROM help if something goes wrong? Is it a shooting robot or what? smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Toys are microcontroled.
    Robots are microcontroled.
    I am microcontroled.



    If it's not Parallax then don't even bother. :-)
    ·

    Mini-Din/PS2 connectors are for sale! 5 for $1! PM me if you wish to make an order.
    Cheap·shipping unless specified!··········150 left!!··


  • Mike GreenMike Green Posts: 23,101
    edited 2009-07-15 18:17
    The COGSTOP statement will do what you want. You just need a loop where one cog stops all the others, then stops itself. To prevent the EEPROM program from running, you just need to erase the first 16 bytes of the EEPROM. Best would be to write $00 in locations $0000 through $000F. That will leave an invalid program in the EEPROM.
    repeat i from 0 to 7
       if i <> cogid
          cogstop(i)
    cogstop(cogid)
    
  • Nick MuellerNick Mueller Posts: 815
    edited 2009-07-15 18:30
    But if something is going wrong, I wouldn't bet that writing to the EEPROM still works.
    When you see that something is going wrong (how do you know?), you'd better shut off the power / disconnect the power to motors.
    If you do that with self-holding relays, it even won't switch back on again.

    I hope you know how emergency-stop switches have to be wired.


    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • 4Alex4Alex Posts: 119
    edited 2009-07-15 19:00
    @ Mike: thanks for your advice, that's exactly what I was looking for. I was not sure if a program really started at $0000 so I thought it was safer to erase it all (dumb me).

    @ microcontroled: no, it's not even a robot, just a kind of SCADA. Its fun but I have to try hard not to burn down the house! The only thing shooting would be me (from time to time) and in the general direction of my electronics...

    @ Nick: thanks for your concerns: I can assure you that I have a pretty good idea on how to wire an emergency switch! My problem is not about a propeller going berserk (propellers are perfect, right?), but it's rather the electromechanicals (motors and pumps) that I monitor with limit switches and sensors. Sometimes you get an unforeseen glitch, a broken belt, gear, pipe, and I want an option to stop or kill that thing completely if certain far-out-of-condition are met. Mainly because it's meant to be autonomous, and I can't watch the home system some weekends. At the cottage, the power sometimes flickers which resets (and restart) the propellers (and also all the clocks in the house!) so this is why I'd like to have a kill function in case anything goes seriously wrong. That way I could see what was the problem when I come back home and not suffer any kind of damages due to resetting. Eventually, I'll put a LiPo battery backup at each point where a propeller runs, thus filtering any flickers, but I'm not at this stage right now.

    Hope this clarifies things. Many thanks to all.

    Cheers,

    Alex
  • Nick MuellerNick Mueller Posts: 815
    edited 2009-07-15 22:10
    > I can assure you that I have a pretty good idea on how to wire an emergency switch!

    Then it's fine! A few people don't know that. wink.gif

    > and I want an option to stop or kill that thing completely if certain far-out-of-condition are met.

    Then it's still an emergency-stop chain. And the propeller (with an relays) is just one link in it. If you want to know what was the cause, write it to EEPROM and then pull the trigger ...
    Upon next boot, inspect that location, display it, confirm erase and go on with normal operation.

    Edit:
    And Propellers *can* go jerks! You only need suitable glitches on the power supply. Don't ask how I know. smile.gif


    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
Sign In or Register to comment.