View Full Version : boe bot project
12-06-2009, 06:05 AM
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.
12-06-2009, 06:54 AM
What immediately comes to mind for situations like this is a State Machine (http://en.wikipedia.org/wiki/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.
Lunch cures all problems! have you had lunch?
12-06-2009, 06:59 AM
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.
12-06-2009, 07:36 AM
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.·
12-06-2009, 08:34 AM
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?
12-06-2009, 09:43 AM
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.
12-06-2009, 10:32 AM
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.
12-06-2009, 12:07 PM
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.
12-06-2009, 12:35 PM
What makes the pushbuttons read as high?
12-06-2009, 12:38 PM
well i dont have a pushbutton only the swithces and the reset button.
12-06-2009, 01:47 PM
A pushbutton is a kind of switch. What makes the switches read as high?
12-07-2009, 12:12 AM
Post Your code!
The Truth is out there············___$WMc%___······················ ······ BoogerWoods, FL. USA
Post Edited ($WMc%) : 12/6/2009 4:18:08 PM GMT
12-07-2009, 02:58 AM
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.
12-07-2009, 03:03 AM
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.
12-07-2009, 03:32 AM
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.
12-07-2009, 04:45 AM
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.
12-07-2009, 05:04 AM
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.
12-07-2009, 05:40 AM
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.
12-07-2009, 05:49 AM
Here's a typical datasheet for a dipswitch: www.components.omron.com/components/web/pdflib.nsf/0/7F945D4364E525688625730F00558EE1/$file/A6S-H_0607.pdf (http://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
12-07-2009, 06:16 AM
ok OMG its a workin program It was a switch wiring problem. Thanks so much
12-07-2009, 06:50 AM