Shop OBEX P1 Docs P2 Docs Learn Events
BS2 Strange Behavior — Parallax Forums

BS2 Strange Behavior

dcscottdcscott Posts: 3
edited 2014-03-30 13:37 in BASIC Stamp
Hello all. I have a BS2p24 that I am using to control an assembly that has a 24V DC motor and 2 Hall effect sensors (these run through a comparator circuit that provides a logic high when the sensors are tripped).

I'm using the Stamp to control an Allegro A4973 motor driver (providing PHASE and ENABLE output to the motor driver), and the sensors provide input to the Stamp. Additionally, there is a switch provided to set an operation "mode" (input to the Stamp).

In essence, with the unit in the cycle mode, it should travel between the 2 sensors until user input (the switch) changes. In the other mode, the unit should stop motion at the next sensor that is tripped (stop on limit). I additionally have status LEDs for the user to indicate which sensor is tripped and the direction of travel.

On an initial startup, the unit works correctly. In the cycle mode, it will cycle between the sensors correctly, and when switched to the stop on limit mode, the unit stops at the next sensor it trips. I can then set the mode switch back to cycle to initiate movement in the opposite direction and set the switch back to stop on limit mode and the unit will again correctly stop at the next limit. This is repeatable.

However, after only a short period of time (maybe 60-90 seconds), the unit will start behaving erratically. It will start to "miss" the next sensor trip. In other words, when I set the mode switch from cycle to stop on limit, the unit will travel to the next limit, reverse direction, and then stop at the other limit (the position it started from). In my testing, it also appears that the longer the unit runs the more it will miss the sensor trips (often skipping 2 or more sensor trips before deciding to finally stop).

Given that the unit initially functions as expected, I'm biased to believe my code is correctly functioning, so I'm wondering if any of you fine folks have any ideas about what could be causing the erratic behavior I'm seeing?

Comments

  • DavetiefDavetief Posts: 16
    edited 2014-03-27 13:09
    If electric noise was causing the erratic behavior, I would expect it to mess up the initial running also. I have tripped myself up with code ocasionally - missing that I reused some variable or bit in another part of the program. It might be worth a careful double check.
  • Beau SchwabeBeau Schwabe Posts: 6,563
    edited 2014-03-27 13:42
    Do you have anything connected to the serial port? i.e. as a status DEBUG to a local PC ... and if so what is the distance from the Stamp to the PC? You can try "hardening" the reset by placing a 1k resistor on the RST to ground if there happens to be any antenna affects from the BS2 to PC connection.
  • dcscottdcscott Posts: 3
    edited 2014-03-27 13:57
    Davetief wrote: »
    If electric noise was causing the erratic behavior, I would expect it to mess up the initial running also. I have tripped myself up with code ocasionally - missing that I reused some variable or bit in another part of the program. It might be worth a careful double check.

    I've reviewed it several times, but I'll take another look. My thoughts ran along yours; If I had a poorly isolated circuit and noise was the cause, I'd expect it to present earlier as well.
    Do you have anything connected to the serial port? i.e. as a status DEBUG to a local PC ... and if so what is the distance from the Stamp to the PC? You can try "hardening" the reset by placing a 1k resistor on the RST to ground if there happens to be any antenna affects from the BS2 to PC connection.

    The unit is set to run standalone, so no PC is connected and there are no connections to the serial pins.
  • SapphireSapphire Posts: 496
    edited 2014-03-27 16:19
    Post your code if you want a review to see if there is a problem.

    What type of switch are you using to control the mode? Does it have appropriate pull-up/pull-down resistors? If not, a floating input could be interpreted in the wrong state.

    Can you add LEDs to display the mode? It seems from your description that the Stamp is changing modes, so knowing which mode it is actually in would help.
  • dcscottdcscott Posts: 3
    edited 2014-03-28 11:13
    Well I feel a little silly now. I had a co-worker take a look just to ensure I'm not missing the forest for the trees and it turned out the Stamp was loose in it's socket and not making good contact.

    After reseating the Stamp, it all functions normally and for extended periods.

    Thanks for all your ideas for help!
  • Jim RicheyJim Richey Posts: 82
    edited 2014-03-29 10:19
    If it happens again,start adding filter caps to calm down the spikes from the motor.
  • ercoerco Posts: 20,256
    edited 2014-03-30 12:59
    Do they make filter caps to calm down wives?
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-03-30 13:37
    calm down wives?
    I think they call that Valium.
Sign In or Register to comment.