Shop OBEX P1 Docs P2 Docs Learn Events
boe bot project — Parallax Forums

boe bot project

sharon anthonysharon anthony Posts: 17
edited 2009-12-06 22:50 in BASIC Stamp
Hi· I need someone to give me some suggestions on a new project with leds on boe bot.· I am making a 2 signal stop ·light and having a brain block getttin started.· I need some clarifications on the wiring and some help with I am thinking· a case select but not quite sure.

Ayone interested?

thanks

Sharon

Comments

  • LawsonLawson Posts: 870
    edited 2009-12-05 22:54
    What immediately comes to mind for situations like this is a State Machine. Once the appropriate state machine for the project is drawn out, there are several simple ways to convert the machine to code.

    My favorite coding form for a state machine is to use a select-case block inside an infinite loop. I number each case and use an integer valued variable (say "state_variable") in the select statement to determine which state the state machine is running in. Each state then contains code to make sure any outputs are correct for the current state followed by code that checks to see if any of the exit conditions for the current state have been satisfied. If any state exit conditions have been satisfied the "state_variable" is assigned the number of the destination state. Timing and delays are usually done by adding some timer/clock code to the main loop that is monitored/controlled by each state.

    Lawson

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Lunch cures all problems! have you had lunch?
  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-05 22:59
    Since this is a class project, particularly since this is a test, you're going to have to do all the work. Otherwise, it's cheating.

    What we can do here is answer questions and clarify what you understand or don't understand, but you're going to have to be specific about what you ask.

    As with any project, you start with what you know. You might as well start with a description of how you have things connected (or would connect things). If you haven't been working with them already, you need copies (downloaded or paper) of "What's a Microcontroller?" and the "BASIC Stamp Syntax and Reference Manual". These will show you how to connect switches and LEDs to a Stamp and will serve as a reference for PBasic.
  • sharon anthonysharon anthony Posts: 17
    edited 2009-12-05 23:36
    well i believe the wiring is correct with the switches connected to p8 and p9 with the resistors on p1-p6. the leds conncted to those reistor on the left and vss to cathode side of leds.· i am attempting to use a case select program at preset.·
  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-06 00:34
    OK, so the LEDs will light when the I/O pins are made HIGH. How do you have the switches connected?

    You have two modes of operation. How about starting with the simplest mode where the lights flash. How fast? Do they alternate or flash together? Can you come up with a test program that doesn't involve the switches and just flashes the lights?
  • sharon anthonysharon anthony Posts: 17
    edited 2009-12-06 01:43
    WEll mike I have the switches connected on p8 and p9. I dont have them connected to the leds i was trying to find a if then way to say if the p8 is high then it would go into t he normal light program not flashing. it does not say how long the lights are to blink i know to blink they need to be high with a pause then a low with a loop i figured the last 5 seconds of cycle would be enough. it wasnt very specific about that. he had stated that we should start with the program we had used for a 7 segment display which used the dirh outh and case select program. we used that to make a number light up like say 9 for a 0-10% of light was on photsensors and used the rctime command.

    sharon
  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-06 02:32
    If you have the switches connected to I/O pins 8 and 9 and that's all, you'll have two nice little antennas and not much else. Is there anything else involved / connected?

    I'm trying to get you to build your program in pieces starting with the simple part.

    If you're supposed to model your program somehow on something you've done before and you want help with the process, you'll need to post your program. Use the Attachment Manager that you get with the Post Reply forum button.
  • sharon anthonysharon anthony Posts: 17
    edited 2009-12-06 04:07
    ok. I didnt use the case select. I first used just a do...loop and got the lights to go as they were suppose to except the "caution lights " at the end were in the routine for .5 sec. But it showed that my basic wiring was ok. I added the switches on the pins and grounded them with the leds . I tried to add an if...endif with the loop but it just stopped after the first if command and didnt loop on the first swithch. the second switch isnt letting it do anything so i think i have a problem with my endif. When using the if..elseif..endif do u have to use an "else" in there? ok here is what i have so far.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-06 04:35
    What makes the pushbuttons read as high?
  • sharon anthonysharon anthony Posts: 17
    edited 2009-12-06 04:38
    well i dont have a pushbutton only the swithces and the reset button.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-06 05:47
    A pushbutton is a kind of switch. What makes the switches read as high?
  • $WMc%$WMc% Posts: 1,884
    edited 2009-12-06 16:12
    Post Your code!


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············___$WMc%___···························· BoogerWoods, FL. USA

    Post Edited ($WMc%) : 12/6/2009 4:18:08 PM GMT
  • sharon anthonysharon anthony Posts: 17
    edited 2009-12-06 18:58
    ok ur right . it is not acknowledging the switch as high. im trying to figure out how to make that happen. the code needs some tweaking. the way it is working now looks like its reading the switch 1 as low. it is going into flashing light mode.
  • sharon anthonysharon anthony Posts: 17
    edited 2009-12-06 19:03
    ok well actually the switches werent communicating at all. i took out the wires to switch and it make no difference. so i delete the if..then stuff and checked the program and it went thru all sequenes. so maybe i need a case select instead if..then. gonna try somethng from that angle.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-06 19:32
    First fix the switches. The "What's a Microcontroller?" tutorial describes how to hook up switches. Look at Chapter #3. You can download this by going to Parallax's main webpage and clicking on "Downloads", then "Stamps in Class Downloads".

    Your program would go through the various sequences. One question for you is whether your system can wait until the end of a sequence before testing the switches or whether it has to interrupt a sequence to change to the other one.

    You can use a CASE statement, but you only have two switches and only three different cases (including off). It's simpler using IF statements unless you have to use a CASE to demonstrate its use.

    If you have to be able to interrupt a sequence, then your software design has to be different.
  • sharon anthonysharon anthony Posts: 17
    edited 2009-12-06 20:45
    i have looked at that chapter with the pushbuttons and tried to rewire according to that but the switches to me are not like the pughbutttons and i dont get it. i dont know if the wires on the left go up to vdd and then the wires on tight go down to led ground or exactly how to make that work. i have tried it all i think and nothing is making the switches work for me. i see the case would only be 2 or three and havent figured how to make that work either.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-06 21:04
    Without a picture of the switch or a datasheet, I can't advise you. It probably has two terminals (or two wires) and they're probably connected together when the switch is on. In that case, the switch is equivalent to a pushbutton where the two terminals are similarly connected together when the button is pushed. The circuits in "What's a Microcontroller?" should work starting on page 75.

    Like I said, you're better off sticking with IF / THEN / ELSE / ENDIF statements for your simple problem.
  • sharon anthonysharon anthony Posts: 17
    edited 2009-12-06 21:40
    the switch is a dip with 8 switches in a row. the "on side" is on the right. I have it sitting with the left "off " side on the left side of breadboard which is not electrically connected the the right side of the board where the "on" side of the switch sits. it is the rev c education board.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-06 21:49
    Here's a typical datasheet for a dipswitch: www.components.omron.com/components/web/pdflib.nsf/0/7F945D4364E525688625730F00558EE1/$file/A6S-H_0607.pdf

    On the bottom of page 3 is the usual connection diagram. Use that as a guide for hooking it up. Try the test programs in the chapter from "What's a Microcontroller?" to see if you can light up a single LED when a switch is closed.

    I'm a strong believer in starting small, making sure one thing works as expected before moving on to something more complicated. It may seem to be a waste of time, but, if you look at the overall time it takes to get a project to work, the "step at a time" method usually saves overall time.

    Post Edited (Mike Green) : 12/6/2009 9:57:39 PM GMT
  • sharon anthonysharon anthony Posts: 17
    edited 2009-12-06 22:16
    ok OMG its a workin program It was a switch wiring problem. Thanks so much
  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-06 22:50
    Congratulations
Sign In or Register to comment.