New and confused...

FatfendersFatfenders Posts: 35
edited April 18 in BASIC Stamp Vote Up0Vote Down
New to the game. ( few years ago a played around with a BOE-BOT but have forgotten nearly everything!)
1. Parallax BS2 BOE
2. Easystepper.
3. Mercury Motor SM-42BYG011-25: 30 tooth GT-2 timing pulley; belt, same pulley on the "other end" 12" away.
4. Typical micro switches mounted on either side used to limit travel.

So far I have constructed a slider on on a discarded inkjet printer rail and can run the slider back and forth... no big deal.
Now I am attempting to incorporate left-right limit switches into the code. Can't even get to 1st base.
I am using model airplane servo wires/connectors (3 wire).
Q1: Here I have a 6" servo wire connected to pin9 (right), another to pin10 (left) and the 3rd to Vdd. But the 'other end' is not connected to anything. In the main loop, why does the pin display as '0' but if I even touch the insulation (or grasp a plastic connector) it will change to '1'.
Q2: If I connect that 6" servo extension to the servo wires that are connected to the left-right micro switches ('C' and 'NO') pin9 (the one I am testing with) ALWAYS shows as '1' yet both micro switches are open.

I have more years of experience than I care to admit with automotive DC electrics (no need to ask about hooking up and testing the micro-switches, etc) but not much at all with this stuff. There are some other random issues with pin state but I will leave than for another discussion.

Any advice greatly appreciated.


  • 12 Comments sorted by Date Added Votes
  • Connecting a wire to a Stamp pin configured as input without a pull up or pull down resistor will usually exhibit the situation you described. A Stamp input pin has very high impedance and will act like an antenna if left unconnected, adding an open ended wire just increases the sensitivity to stray EMF fields.
    Since you are connecting one of the three wires to Vdd (+5) and the other two wires to the Normally Open contacts of two microswitches, you need to connect those two wires to ground through a resistor, such as 4.7K so that the input to the stamp is not floating. This way the input is seeing ground through the resistor, and when the switch is activated it will "see" Vdd (+5). The resistor is needed to keep current to a very small value when the switch closes. Keep in mind that micro switch contacts bounce like crazy so the stamp will see multiple high speed pulses from the switch. One way to deal with that is to stop the motor when the input goes high from the switch, then don't "look" at that switch again for about 15 - 20 milliseconds, which is usually enough time for the contacts to settle down.
    Florida, between St. Petersburg and the Gulf of Mexico

    Do not look directly into laser with remaining good eye...
  • Hal,
    Thank thank you thank you! I was afraid, when I posted my questions, I would get a response that way beyond my ability (or desire) to understand since concepts such as 'impedance' have always tended to mystify me. Your response was just what I was looking for and I actually understood it on the first read! I did what you said and Waa-Laa... works perfect now. But typically, an answer to one question often times leads to another question. As I sat down to incorporate that resistor into the circuit I realized that I would not be able to determine (without more coding) which limit switch had closed so I wired in a diode to each NO pin. Much to my disappointment and confusion, they made no difference. So I checked the voltage on one limit switch as I manually closed the 'other' limit switch. I was surprised to find that the voltage on the 'other' NO pin was .3 volts on one and .5 volts on the other. Enough, I guess, to change the state.
    I don't even know if I will eventually need to know which limit switch was closed and, of course, I could determine which one using a little code but I would like to understand what is happening.
    Can you help me out... again?
  • Something is not right. You should be seeing the full swing from 0V to +5V when you operate the switch.
    Let's recap:
    You have a wire going from pin 9 to the NO (Normally Open) contact of the Right switch.
    You have another wire going from pin 10 to the NO contact of the Left Switch.
    You have a wire from Vdd (+5) going to C or Common contacts on BOTH switches.
    You have two 4.7K resistors connecting pin 9 and pin 10 to ground.
    REMOVE the diodes, You don't need them in this circuit.
    You have pins 9 and 10 configured as INPUT.

    Is this correct?

    Can you post a picture of your setup that clearly shows the connections and the code you loaded into the BS2?
    Florida, between St. Petersburg and the Gulf of Mexico

    Do not look directly into laser with remaining good eye...
  • Hal,
    Got it. As soon as I read your 'You have two 4.7K resistors..." I knew what I had done wrong. I had connected a single resistor to both NO pins. I changed it like you say to do and now all is working fine.
    Am wondering if you might now advise me on getting my stepper motor to turn faster. I can only get it to turn at about 60 rpm. Would like to double or triple that. Am I expecting too much from the configuration I have?
    Here is an example of some code:

    FOR j = 1 TO 200*10
    LOW _MS2 ' Select Full Step...
    LOW _MS1
    LOW _DIRECTION ' Travel 'right'
    PAUSE 2
    IF IN9 > 0 THEN GOTO nudge_left
  • Hal,
    I got things to a point where I had the slider running back and forth between the limit switches just fine. Then all of a sudden it went crazy. Kept going back as if I had hit the reset button. Oddly, the first time it happened 'DEBUG" displayed 'righÿ' ('Y' with an umlout)
    instead of 'right' (see attachment). Then if I shut 'er down and restarted things would work OK for a random number of iterations, then just stop.
    I had one other BOE around from my 'BOE-BOT" days. Swapped over to it... work OK for a few times, then it failed too??? Now if I try'n upload the blue/red LED's near P0/P1 on the BS2 flash a few times (on both BOE's) and I get an error message "No Basic Stamps found".
    Have you ever seen anything like this?
    I am committed to get this project working and cost is no object (within reasonable limits). Would you have any recommendations for going with a different or newer technology?
    Parallax or otherwise?
    532 x 516 - 41K
  • Hal,
    I shut everything down and went off to do some other chore. Came back after a while, fired up BOE (2) and it worked fine! Switched over to BOE (1) and it works fine too!
    Is heat the issue?
  • I spoke too soon... tried 'em both again after sending the previous post. They both works a coupla times now neither one will work as described previously.
  • Sounds like a problem with your code. Can you post the entire code using the code tag C in the toolbar at the top of the comment box?
    Florida, between St. Petersburg and the Gulf of Mexico

    Do not look directly into laser with remaining good eye...
  • ercoerco Posts: 17,667
    New batteries.
    "When you make a thing, a thing that is new, it is so complicated making it that it is bound to be ugly. But those that make it after you, they don’t have to worry about making it. And they can make it pretty, and so everybody can like it when others make it after you."

    - Pablo Picasso
  • Hal,
    Thanks for all your help.
  • Hal,
    I think I tracked down the problem. I musta fried the easystepper. I tried something today I had not thought of before. I had never attempted to load a program with all the pins from/to the easystepper pulled. Both BS2's loaded and ran a test program just fine. Then I tested with the leads TO the easystepper connected. Still loaded/ran OK. Then I hooked up the leads FROM the easystepper to the motor and duplicated the load/run problem. Somewhere along the line I musta fried the easystepper. (Note to self... "be really really careful with this stuff!"). I just ordered another easystepper.
  • Make sure you set up the current limiter on the Easystepper, the motor you indicated has a nominal 330mA draw per coil. The Easystepper data sheet should have the instructions for setting the current. Unless the load is somewhat heavy I would start out with a setting well below 330mA and see if the motor misses any steps. Also make sure to heed the warning about disconnecting the motor leads while running, a sure way to blow the Easystepper. When it is running feel the chip on the Easystepper and make sure it does not get too hot, it may require a heatsink if it does.

    Florida, between St. Petersburg and the Gulf of Mexico

    Do not look directly into laser with remaining good eye...
Sign In or Register to comment.