Shop OBEX P1 Docs P2 Docs Learn Events
S2 crash (stall) detection? — Parallax Forums

S2 crash (stall) detection?

levrek1levrek1 Posts: 6
edited 2011-03-25 13:08 in Robotics
Maybe we are missing something, but we cannot get the S2 to detect a crash )stall) using code from the GUI. I can even hold the wheels still with my hand and it shows no sign of detecting it. (note: the factory-demo program seems to accomplish this detection). Is there a trick/tip here??

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-03-04 13:07
    Could you post the Spin code that the GUI produces, please?

    Thanks,
    -Phil
  • WhitWhit Posts: 4,191
    edited 2011-03-04 17:17
    @levrek1,

    Attached is a simple stall program. If stalled, the S2 sounds an alarm, backs-up, turns and moves forward. It there is no stall, the S2 continues forward. I have attached as spin file (archived).

    Give it a try and see if it works.

    Hope this helps!

    @Phil,

    For some reason, I can't attach a GUI .scb file. Any ideas? Edit - Now that Bump has this fixed. I will attach the GUI (scb) file.
  • Ken GraceyKen Gracey Posts: 7,387
    edited 2011-03-07 15:55
    I think the problem is that you believe the stall sensor is on the drive wheels - this is how it worked on the original Scribbler (S1). On the S2 the sensor is optical and mounted on the rear tail wheel.
  • WhitWhit Posts: 4,191
    edited 2011-03-07 17:28
    Ken Gracey wrote: »
    I think the problem is that you believe the stall sensor is on the drive wheels - this is how it worked on the original Scribbler (S1). On the S2 the sensor is optical and mounted on the rear tail wheel.

    @Ken, I thought so too, until I read that he was holding the S2 (and it still didn't stall). If I hold mine in the air (not holding wheels), the tail wheel stops spinning and it detects a stall - That is the way it works, eh? If he was holding his (and the wheels to stall it) wouldn't the tail wheel stop spinning and read a stall anyway?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-03-07 18:43
    That's the reason I wanted him to post the Spin code. If the .ini file has been corrupted, he may not have the the autoreadsensors parameter set to its default value of 2. That would show up in the Spin code with the test for stall not being preceded by a read of the stall condition.

    -Phil
  • ercoerco Posts: 20,256
    edited 2011-03-07 18:47
    Check PhiPi's reply at: http://forums.parallax.com/showthread.php?127601-How-to-detect-motor-stall

    Re: How to detect motor stall?
    During the early phases of the S2 design, there was much discussion about stall detection. I was of the opinion that motor current detection, in combination with the wheel encoders, would be adequate to determine a stall condition. Ben Wirz, the project's hardware guru, pointed out -- rightly, as it turns out -- that in many "stall" situations, the drive wheels are simply spinning in place on a slick surface as the robot struggles against an obstacle. In such a case, neither the motor current nor the wheel encoders yield sufficient clues about a stall condition.

    As a consequence, it was decided to add an encoder to the idler wheel. Even with the drive wheels turning, the idler will be stationary if the 'bot isn't moving. However, since the idler on the S2 is not gimbaled, it will also not rotate when the 'bot is turning in place. As a consequence, the S2's stall detection algorithm has to consider a number of factors in coming up with a stall/no-stall decision.
    -Phil
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-03-07 19:05
    As erco points out (quoting me), stall detection in the S2 is a good example of what's known as "sensor fusion". But I have the feeling that the OP's problem has, at its core, a simpler explanation than the failure of a complex algorithm -- especially since the same algo is employed in the factory demo program which, as he indicates, works correctly.

    -Phil
  • ercoerco Posts: 20,256
    edited 2011-03-08 09:35
    @Phil: You're eminently quotable.

    Can you give me a quote on whether sensor fusion leads directly to sensor confusion?
  • WhitWhit Posts: 4,191
    edited 2011-03-08 10:16
    There is also the test for the tail (or idler) wheel sensor in the S2 default program. Usually, if I have my S2 sitting on its stand (peanut butter jar lid) when I program it. It will read a stall pretty quickly with something like the program attached above.
  • levrek1levrek1 Posts: 6
    edited 2011-03-25 12:22
    crashDetect3.scbOK, so to be honest, I don't know what our problem was with crash detection. Various simple programs didn't seem to work. Finally got around to trying again and I cannot write something that DOESN'T work:--- detection in 'main', detection in a sub, detection in a loop in a sub- it all works fine. So, I am blushing. Thanks for everyone's time and interest.

    Side Question: it seems to me that there are these occasional 'temporary mysteries' with the scribbler and S2. My superstitious solution is to always load the factory program, and then my own program. Without that, it seems like the robot can get into strange states. Is this true or just another thing to blush about?
  • levrek1levrek1 Posts: 6
    edited 2011-03-25 13:08
    Ah, but wait. Now I see another posting about the S2 stall/crash detection not working consistently( http://forums.parallax.com/showthread.php?130346-S2-stall-sensor-is-not-working-every-time). I might be blushing less.On the other hand, I just took 6 S2s (it IS a classroom) and tried the stall code above on each one and everything worked
Sign In or Register to comment.