Shop OBEX P1 Docs P2 Docs Learn Events
New and confused... — Parallax Forums

New and confused...

FatfendersFatfenders Posts: 39
edited 2017-04-18 06:09 in BASIC Stamp
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.


Comments

  • 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.
  • 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?
  • 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'
    PULSOUT _ONE_STEP, 300
    PAUSE 2
    IF IN9 > 0 THEN GOTO nudge_left
    NEXT
  • 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?
  • ercoerco Posts: 20,257
    New batteries.
  • 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.

    Hal
  • Erco,
    Thanks. You were right. I had let my batteries run down and had not noticed it. I have (2) small 6 volt (emergency lighting) SLA 6 volt batteries that I use for my automotive testing. Seldom need to charge them for those purposes but testing the stepper musta run 'em down.

    Hal,
    I have made some progress on this project I am working on and have pretty much figured out how to do most of the things I want to. That said, I am confused about what I want to do next. I have (8) off/on switches that I want to connect to 8 IO pins. The switches have 3 connectors... positive, negative, and acc. with a small LED on the top of the switch handle. My plan is run a common wire along all 8 negative connectors (to ground the LEDs), then to Vss. Do the same with the plus connectors and run that wire to an external 5 volt regulator connected to one of the 6 volt batteries.
    Then I want to test the pins for a HIGH condition whenever they are turned on.
    On page 14 of the reference manual in fig. 1.2 it states that I can sink 25ma and source 20ma on 1 pin but the total for either set of (8) pins cannot exceed 50ma / 40ma.
    I just can't get my head wrapped around what that means to me. Lets say all I turn on all 8 switches so they all would all test HIGH (and all 8 LEDs would be on). Will that be a problem?
    I am thinking that since the LEDs get their + and - connection at the switch the stamp will be unaffected. So if that is true then I am simply providing 5v to each i/o pin when the switch is turned on. Do those sink/source limits need to be considered here?


  • kwinnkwinn Posts: 8,697
    As long as the current to light the leds is coming through the switches and NOT from the I/O pin it is fine. A picture (or schematic in this case) is worth a thousand words.
  • Kwinn,
    Thanks. I have attached my best effort at a schematic...
    773 x 580 - 36K
  • kwinnkwinn Posts: 8,697
    That will work, but for safety I would put a 1000 ohm resistor between the acc terminal and the stamp input pin. That way if you make the pin an output by mistake it is protected from an over current.
  • kwinn,
    Thanks, I will do that if I ever get that far. Everything was going along fine for several days of testing... typical stuff, running the stepper motor in both directions, playing with rpm and torque, etc, then I fried a Big Easy because (I think) I was using the breadboard on the BOE to connect the controller to the motor. I have noticed some of the sockets in the breadboard were getting loose and I think that caused a open circuit. Anyway I had another Big Easy so I soldered it up and double, triple, etc. checked all my connections (I now run wires directly from the controller to the motor). Hooked everything up and applied 12 volts to the Big Easy and the ground wire which I had connected to Vss (the one next to the step connection) went up in smoke. I had no idea why. So anyway I then wired in an A4988 and when I applied 12V the ground wire to the 12volt power supply went up in smoke. Now I am afraid to do anything!
    It is so weird that I had everything working fine and now I can't get anything to work.
  • kwinnkwinn Posts: 8,697
    There is an old carpentry/construction saying "measure twice, cut once" that is just as applicable to electronics and electrical work. While it takes time to do, it saves time on all but the smallest projects.

    Have a neat and clear wiring diagram or net list that shows all the power supplies and their connections individually (the +, -, common, and ground if applicable). Do the same for the signal connections if practical, or at least show where they connect on each module. Verify each connection either as they are made or after they are all done with an ohmmeter. Verifying as made and after is even better. Use the software tools you have (schematic, paint, draw, spreadsheet programs) to help with this.

    As a bonus you end up with a very well documented project.
  • I figured out what I had done wrong! Refer to the attachment.
    988 x 493 - 107K
Sign In or Register to comment.