Shop OBEX P1 Docs P2 Docs Learn Events
Basic Stamp2 and a Mouse — Parallax Forums

Basic Stamp2 and a Mouse

NWUpgradesNWUpgrades Posts: 292
edited 2005-03-11 03:58 in BASIC Stamp
Does anyone know if there is a way to program the Basic Stamp2 to be used with a mouse or do I need a seperate chip?·The reason I ask is that I have 2 pushbuttons that are controlled via P0 and P1 on my Homework Board and I would like them controlled by a mouse or PushButton.

Comments

  • JonbJonb Posts: 146
    edited 2005-03-09 18:50
    I think you should be able to do it.
    I bet many have tried this. Technically its is no more difficult then checking for a pushbutton assuming your mouse is the basic type. I assume mice can vary in architecture but if you look inside you will notice most often micro switches beneath the mouse buttons.

    Many projects in stampworks, nuts and volts, etc. use switches. I suggest you go to parallax.com and click "downloads". In the section you will find many examples to give you ideas. You may or may not have to debounce the switch inputs.




    http://www.parallax.com/dl/docs/books/sw/exp/sw6.pdf


    Post Edited (Jonb) : 3/9/2005 6:57:49 PM GMT
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-09 19:04
    Mouse buttons, shouldn't be a problem, mickey readings from mouse movement are a problem because they can happen very fast.
  • NWUpgradesNWUpgrades Posts: 292
    edited 2005-03-09 20:11
    Please forgive my ignorance, but exactly what is "Debounce"?
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-09 20:26
    a switch when closing or opening will usually "make and break" the contact several times before reaching its final state, if you sample the switch fast enough, it will register as opening and closing several times. One means for debounce is to use saveral samples to make sure the switch has settled, or to use a capacitor which inhibits the voltage from changing too quickly.
  • Beau SchwabeBeau Schwabe Posts: 6,557
    edited 2005-03-09 20:26
    When you close or open a switch contact, at the moment of the transition the signal actually "bounces" in opposition to the change
    caused by opening or closing the switch. Analogous to striking a bell, it rings or "bounces", it continues to ring trying to establish
    an equilibrium. "Debounce" is a way of preventing a false signal. A common way to do this is to simply sample the signal multiple
    times or wait for an extended period after we know that an event has taken place and sample again.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe - Mask Designer III

    National Semiconductor Corporation
    (Communication Interface Division)
    500 Pinnacle Court, Suite 525
    Mail Stop GA1
    Norcross,GA 30071
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-03-09 21:50
    NWUpgrades -

    The PAK-XI Mouse Co-processor is the easiest solution for using a computer mouse for positioning feedback if that's your purpose in using it. Here is a link to the chip:
    http://www.awce.com/pak11.htm

    If you're using it just for the button facility both the mouse and the co-processor are probably overkill. A couple of normally open pushbutton switches would do the job quite nicely and at a lot less cost.

    Regards,

    Bruce Bates
  • NWUpgradesNWUpgrades Posts: 292
    edited 2005-03-10 16:59
    What I am doing is trying to run 2 stepper motors via a mouse. In other words, I want to program up down and left right arrows that when pressed by the mouse it will move the stepper motors in the designated direction. Would your suggestion be the easiest method? The switches are actually normally open until a command is give to close. Thanks for your help.
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-03-10 18:39
    "up down and left right arrows that when pressed by the mouse...". Sir, where are these arrows going to be? On a PC screen, perhaps?

    You've been asking about interfacing a mouse directly to a BS2. You didn't mention the PC with VGA display (and probably Windows?) in the middle, that the mouse is actually connected to.

    I agree with the others -- a picture is definitely needed here. Make sure you include ALL devices you expect to be in your design.

    Right now it sounds like you want a BOX, with SWITCHES on top, which will drive two STEPPER MOTORS through a BS2. In addition, you want a SERIAL CONNECTION to a PC which has a MOUSE and DISPLAY running WINDOWS. You want to be able to control your STEPPER MOTORS either with the SWITCHES on the BOX, or by CLICKING on some GRAPHIC (up-down arrows). This should send a MESSAGE to the BS2 to control the STEPPER MOTORS.

    In design, coming up with a complete statement of what you want the solution to be is half of the battle. The things you've left out so far include the SERIAL CONNECTION, the entire PC, and the graphics program on the PC. All of these things are doable, but it's really hard to give you advice that helps if we don't know all the pieces you want to use.
  • NWUpgradesNWUpgrades Posts: 292
    edited 2005-03-10 21:25
    My apologies for the short description. This project is just in the design stage right now. I pretty much am trying to do exactly what you stated. I will need a window inside another program (not yet developed) that will have the arrows I refer to. Yes, it will be under Windows OS. There are no pics at this point. I want to make sure it is going to work before spending a bunch of time on drawings, etc. The 4 Push Buttons would really not be necessary after the mouse is working. I was just thinking of leaving them in for testing purposes.·I want to keep this as simple as possible.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-10 23:29
    It sounds as though you needent worry about the mouse at all, your operating system will do that for you. It sounds as though you will have 4 buttons in a window program, this program will send data to your stamp via serial which will control your stepper. All you need to worry about hardware wise is connecting your stamp to the serial port of your computer and to the stepper. Everything else is software, your programming environment on your computer will take the data inputted and generate a serial code corresponding to the pressed command, the stamp will decode the serial data and perform the function.
  • NWUpgradesNWUpgrades Posts: 292
    edited 2005-03-11 01:31
    That is where I am confused. How do I "send' the data from the mouse to the stepper motors? If it is through the Basic2 Stamp, I need to know how that is done. Thanks.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-11 02:04
    you said you will have to write a computer program to display four buttons on the screen right? That program is written on your computer in Visual Basic, C or whatever, it will take care of the mouse events, it will also have access to the Serial API which provides access to the computer's serial port, you send a data byte across the serial port containing whatever value you care to make it, one number for each button, the stamp receives the byte on the serial line and and sends the appropriate control singal to the stepper motor to correspond to what the user pressed. If your getting caught up on the computer side of things, this is beyond the scope of the forums. You need to consult your programming language manual, if you dont have a compiler for your computer, you need to buy one, specific advice on programming your computer can't be given if you don't have a compiler because each language has a different way of doing it.
  • NWUpgradesNWUpgrades Posts: 292
    edited 2005-03-11 02:54
    I am considering using Visual Basic, but have experience in C++ also. What would you reccommend as the better of the 2?
  • NWUpgradesNWUpgrades Posts: 292
    edited 2005-03-11 03:42
    Can the Basic2 Stamp be programmed with a GUI, or does that take up more memory than it is capable of? I was thinking of programming the stamp first, before I delve in to the actual program I will be using.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-11 03:45
    Whichever seems more natural to you, some say C has more power, and Basic is easier, but its all a matter of reference. But at least for this application its six one way half a dozen the other, they are both equally capable of performing what you need. Id say go with whatever you have more experience in, that way you'll be up and running more quickly. Ive always been a Borland man so Basic was never an option for me, I have thier C Builder, Pascal and Delphi compilers.
  • NWUpgradesNWUpgrades Posts: 292
    edited 2005-03-11 03:54
    I kick myself every time I think about this. I had a copy of Visual Studio that I "thought" i would never need and sold on E-Bay. I guess I can always go to MS again and do a usability study to get another copy!!! Thanks for your help.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-11 03:58
    The program you use to program the stamp is a GUI, any windows program that has buttons, text input boxes, menus etc is the GUI.

    You can test the stamp aand stepper motor setup first by getting 4 buttons from radio shack or wherever, forget about the mouse during this stage, concentrate on getting the stepper to respond the way you want when pressing each of the buttons, after you get it working properly, you can write the computer program and the serial interface on the stamp.

    This is actually the best method of developing any system in general, the more your capable of breaking a large task into smaller tasks, you can concentrate getting the smaller subsystems right before trying to make the system more complex, when you know the code for each subsystem is working properly, and you experience problems in the larger system, you know it isn't the subsystem, because you already tested it, it will most likely be in the code you use to tie the subsystems together.
Sign In or Register to comment.