Shop OBEX P1 Docs P2 Docs Learn Events
Where to find simple programs online? — Parallax Forums

Where to find simple programs online?

ScottBScottB Posts: 8
edited 2005-03-24 23:09 in BASIC Stamp
Hello everyone,

I need to write a very simple program, we are going to have a four button joystick and basically when you push forward it will close a switch that will be an input to the stamp that will have an output to a relay that will drive a motor until it hits a limit switch.

Then repeat that process for each of the four directions.

I expect someone has written something similar to this, is there any online program library I can access?



Thank you,

Scott

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2005-03-18 20:59
    Actually, this is so simple I don't think anyone will have written a library for it. It probably won't take you more than 8 hours to write this and debug it.

    Use 'InA' to read P0..P3 for the joystick buttons.

    Write a small routine that will start moving the motor, based on joystick inputs.

    In your 'main' loop, monitor the state of the limit switches, and gosub to turn off any 'hit' motors.

    I expect you have 4 joystick switches, 4 motor control lines (reversible, right?· That makes it a little difficult), 8 limit switches (one for each extreme of each motor).

    Okay, you just ran out of I/O pins on the BS2 -- it has 16.· If you replace the 'Motor' with modified Servo's, you save 4 pins, and can now have 8 limit switches.

    Post Edited (allanlane5) : 3/18/2005 9:05:39 PM GMT
  • ScottBScottB Posts: 8
    edited 2005-03-18 21:13
    Thanks Allen,
    I read through the form a little and maybe I should explain what·I am trying to do (although Allen seems to have gotten the idea)
    We have a joystick that will close·one of four·switchs depending depending which direction you push it.
    We have an airplane model with motors and limit switchs in it.
    Push joystick forward, close switch, tail flaps motor run until limit switch is closed.
    repeat for roll, turn, etc.

    Thanks,
    Scott
  • BeanBean Posts: 8,129
    edited 2005-03-18 21:16
    Why not just use a rc servo ? They are made for this. Would be very simple to program.
    Bean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out· the "SX-Video Display Module"

    www.sxvm.com

    "A problem well defined, is a problem·half solved."
    ·
  • ScottBScottB Posts: 8
    edited 2005-03-18 22:44
    Problem is I have this model that is already pre-wired and was using a allen-bradly process controller that has been problematic, no one here understands ladder logic... and after studying it for some time... no one wants to... and the company that built the exhibit for us went out of business (surprise). My supervisor has given me the project and we have a couple of basic stamps kicking around the shop so he suggested I try one of them. Technically it could be done with only relays but we may want to add more features later. We have a 32 I/O stamp ordered and on the way, besides the servos and limit switches in the plane there are three outside motors with limit switches that move the plane nose up/down, turn left/right, roll left/right.

    Joystick to right, tail rudder to right, plane rotates right, etc.

    Once I have code for one function I'm thinking I can just copy it for the others, problem being that although I like programming in basic I haven't done so since school days (+ ten years) so any help will greatly be appreciated. Do you think it would help if I posted this over at the robotics form? Heck we have the robot sumo here!

    Thanks,

    Scott
  • ScottBScottB Posts: 8
    edited 2005-03-18 22:58
    allanlane5 said..

    I expect you have 4 joystick switches, 4 motor control lines (reversible, right?· That makes it a little difficult), 8 limit switches (one for each extreme of each motor).

    Okay, you just ran out of I/O pins on the BS2 -- it has 16.· If you replace the 'Motor' with modified Servo's, you save 4 pins, and can now have 8 limit switches.
    ·

    Actually 4 joystick switches - nose up/down - roll left/right - AND two buttons turn left/right

    3 motors in plane

    6 limit switches in plane

    3 motors outside plane

    6 limit switches outside plane

    I count 12 outputs and 18 inputs - we plan on using a 32 I/O Parallax stamp.

    Anyone want to help me reanimate a F-20? turn.gif

    Thanks,

    Scott

  • Alan BradfordAlan Bradford Posts: 172
    edited 2005-03-21 17:42
    Hi Scott,

    Are you trying to access the motors through the A-B PLC? Which PLC is it? This sounds like one of the Slic-50 or 500 series Controllers?

    Ladder logic is easy but takes a diffrent mind set. Also A-B Has made the entry level programming software very expensive.

    If you are trying to eliminate the A-B then the stamp is a good way to go.

    What type of motors are you using? There is a way to use a BS-2 , as you can put some of the travel limit switches in series with the direction control relays.

    My assumption is that the control feedback loop is using good old Mark I eyeballs.
    Set up the direction limit switch in series with the direction relay coil. When the limit has been reached, the relay shuts off and no further travel will occur. And you saved an output. When you drive the motor in the oppisit direction with the other relay it will drive off the likit switch and head to the other direction limit. Wire this switch the same way.

    If all you are trying to do is make the plane follow the Joystick you almost dont need a stamp at all (Sorry Parallax!!).
    If you want some automatic preprogrammed movements then the stamp will be necessary and you will need the Stamp to read the limit switches.

    You can also cheat the I/O limit by putting all the limit switches in parallel for a particular axis of movement.(Assuming more than one axis will move at a time).

    The software is what is making the motor move and knows which direction it is moving. Therefore there is only one limit it can hit. Drive the motor till it·sees the limit·input activate,·and you know which one it is by the direction. It dosent matter that 2, or 4 are in parallel you know which one based on the direction of the motor.

    I use this in my X-Y·drive systems that use Stamps and run out of I/O's. It works slick. More software overhead but less I/O pins.

    Let me know if you have any more questions.

    Alan Bradford
    Plasma Technologies

    ·
  • ScottBScottB Posts: 8
    edited 2005-03-22 20:06
    Thank you Mr Bradford,

    I actually would like to learn ladder logic however I am more familiar with Basic even though it has been some time since I have fooled around with programming other that simple DOS.

    We are (were) using an A-B micrologix 1500 however we are using parallax stamps in more of our exhibits so it is more practical and cost effective to use the stamp.

    I tried to talk my supervisor into just hard wiring the exhibit but he prefers using the stamp so we can add more features later, for now we just want to see it work ASAP.

    All the limit switches are run to the PLC and the motors that physically move the plane are rather large (the plane model is over three feet long)



    They say a picture is worth a thousand words so...

    640 x 480 - 68K
    480 x 640 - 74K
    480 x 640 - 100K
  • steve_bsteve_b Posts: 1,563
    edited 2005-03-22 20:13
    What's it not doing that it shoudl be doing?

    Maybe it's current software program is alright but there's a hardware failure....That might be just as easy to diagnose then to redo the whole thing!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    Steve
    http://ca.geocities.com/steve.brady@rogers.com/index.html
    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-22 21:27
    If the hardware issue is in the PLC, it is not likely anyone has enough knowledge to figure out where the error is, especially since it is unlikely they would have access to the program. Without looking at the specifics of the 1500, I read that some PLC's use battery backup ram to store the program, if the battery died, the program is lost, but again without access to the program it is of no help.

    I am convinced using the proper interface components the F-20 can be revived. I would start by confirming the proper operation of each motor and limit switch, by manually driving each. If you plan on keeping each interface component (relays and what not), test each one of those and replace any that aren't functioning.

    If you confirm that all mechanical parts are operating properly, you can be assured that reviving the display is possible. The best way of devising your control program is by creating a flow chart. Start with action boxes and decision boxs describing general behavior. Take a look at the attached example, once you do this you'll find the programming to be pretty straightforward. Also you should test and verify the operation of each operation by itself such as "pitch up" in a ground up approach of programming it, that way whenever you experience a problem, you know its at your current level and lower level functions performed are not the culprit.

    The attached flow diagram is not complete obviously but hopefully it will get you on your way. One thing you may consider is incorporating the limit switches as a kill switch for the motor (ie hardware not under control of the stamp), so that the motor is energized if and only if neither of the·limit switches·for that motor are activated. This way you will aleviate some of the control nessesary for the stamp to perform and it will also prevent damage if for some reason the stamp goes into lala land either in development or operation.

    PS sorry about the quality of the flow diagram, I only have access to MSpaint at the moment (Adobe Illustrator is at home)

    Post Edited (Paul Baker) : 3/22/2005 9:31:40 PM GMT
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-22 23:07
    One note, the above flow diagram does not properly act upon the information presented by the limit switches (a limit switch should have the near immediate effect of shutting off the corresponding motor), nor does it turn off a motor whenever a direction button is unpressed.
  • Alan BradfordAlan Bradford Posts: 172
    edited 2005-03-23 00:21
    Hi Scott,

    I think the easiest way to fix this is to junk the PLC, if no one has any idea what the ladder looks like. Even if the program is in the PLC to extract it you will get a ladder without any documentation as to what each element does.

    The flowchart method is a good place to start. You need to know what you want to happen when. Then you can hook up the motors and limit switches.

    It looks like the motors are turned on/off with relays. This will be easy to do with a stamp. I use Solid State Relays driven from the stamp pins, to drive relays. You can use AC or DC SSR's depending on the Relays you want to drive.

    I would take out everything that is not needed, and then wire the stamp into the circuit.

    Looks like it should take about 8 hrs to wire and the same to program. A fun project.

    It beats controlling dirty, greasy cutting machines.

    Good Luck,

    Alan Bradford

    Plasma Technologies
  • ScottBScottB Posts: 8
    edited 2005-03-23 00:31
    Yes, after brainstorming a little we would like to have the limit switches hard wired however I am not sure how we are going to make it happen, I'm going to put together some sketches, shouldn't be too hard.

    Thanks for that idea and the running the limits in parallel.

    No one here know ladder logic however many of us know basic so we are much more enthused about converting to a basic. Converting to something other than the PLC has already been determined.

    Yes it could all be done using nothing more than relay however there are some extra things we may want to add down the line such as. Joystick right - rudder right - momentary delay - plane move right. also we may want to have the plane center itself if left idle for a predetermined amount of time.

    Thanks for all the help, I'm open to any other ideas.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-23 00:51
    Oh it just occured to me when you rephrased my idea, you'll need to have a form of override since when one of the limit switches is activated, you want to permit motor operation in the opposite direction otherwise the display will become stuck (since the switch is killing the source).

    Perhaps you can adapt a form of this circuit http://www.edn.com/article/CA323022.html?spacedesc=designideas·you would take out the current sensing portion (IC2) since it is performing the same function as your limit switches, and feed the limit switch into the reset of appropriate D-flip flop, to deactivate the motor via the button no longer being depressed, would require the feeding a stamp signal in there as well. And perhaps this isn't the best circuit, but I like the idea of using the reset of a register to disable the motor. Anyways its some food for thought.

    Ah it just occured to me, the reason the feedback between the two flip flops is there is to ensure that both portions of the hbridge aren't simulatenously activated (a very bad thing) by pressing both switches, but your joystick (plus your stamp being thrown into the decision making process) will prevent this from happening, so you can feed the output from the stamp directly into the D input, the clock would need to be driven by a clock source (provide by stamp or otherwise) to cause an update of the output of the D flip flop.

    If I get bored tonight and my roomate isn't using my computer (she's studying for an insurance liscence, and I boffo'ed up her computer by accidentally visiting a malware site) I'll redraw the schematic with the changes and post it.

    Post Edited (Paul Baker) : 3/23/2005 1:05:26 AM GMT
  • ScottBScottB Posts: 8
    edited 2005-03-24 22:18
    Thanks Paul.

    If you are ever in Los Angeles and visiting the Science Center I can get you into the IMAX.

    Two of the guys here in the shop have some kind of similar flip flop circuits I have been looking at trying to incorporate.

    I am open to any other ideas

    Thanks,

    Scott
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-24 22:26
    Cool, thanks, sorry I didnt get to the updated schematic, my roomate was indeed studying her brains out the last two nights. She passed the test today, and we're going to Ruth Chris's Steak House in a few hours to celebrate. Now she can afford to pay half the rent and utilities, meaning more money in my pocket, woohoo!
  • Beau SchwabeBeau Schwabe Posts: 6,557
    edited 2005-03-24 23:09
    Paul Baker said...

    Oh it just occured to me when you rephrased my idea, you'll need to have a form of override since when one of the limit switches is activated, you want to permit motor operation in the opposite direction otherwise the display will become stuck (since the switch is killing the source).

    One way would be to place a reverse biased diode in parallel with each limit switch.
    That way the only time the diodes (one on each switch) would need to "work" would
    be at the extreme ends when switching direction.

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

    National Semiconductor Corporation
    Latest Company News
    (Communication Interface Division)
    500 Pinnacle Court, Suite 525
    Mail Stop GA1
    Norcross,GA 30071
Sign In or Register to comment.