21/2 The Drop-Off Detector-Problem Solving

Published April 7, 2012 by Tareef Lodhi

Last class I started doing the Drop-Off Detector activity. I wrote the program and understood it.  I tried it several times, but the program didn’t work properly. My Boe-Bot moved, but not the right way. It was supposed to go forward while it was on the board. As soon as it reached the drop-off zone, it was supposed to turn. This didn’t happen. Instead, my Boe-Bot kept going in circles. It kept turning and turning. I tried restarting everything but nothing work.

The first thing that I did was check my circuit. I wanted to make sure that I had a complete circuit, and that I had used the right resistors. I remembered that I had to replace two of the resistors. I started to doubt whether I had done that step or not. I was right. I had forgotten to replace one of the resistors. I had put only one red-black-red. I forgot to replace the other one. I thought that this might be the reason my Boe-Bot was acting so weird. I simply took out the resistor and put the red-black-red one instead. I guess the resistors caused some problems in the way the headlights “saw” the tape or something. Maybe since it wasn’t limiting enough power, my Boe-Bot saw the tape which was really far away, causing it to turn.

I tested my Boe-Bot once again. Once again, my Boe-Bot did the same thing. It kept turning I circles. I tried resetting it, but it didn’t work. This made me think that maybe something was wrong with my program. I went back to the PDF and looked over the program that they had given. I checked each and every step with the program that I have written to make sure I made no mistakes. I did this because I know that even the smallest mistakes can cause big problems. To be a hundred percent sure, I copied the program from the PDF to the BASIC Stamp Editor. This would ensure that there are absolutely no difference between what is on the PDF, and what I have written.

I tested my Boe-Bot once more on the board. Once again, it did the exact same thing. I started getting really annoyed. Nothing seemed to be working. I had already spent so much of my class trying to make it work. Trying my best not to lose my patience, I tired thinking of other possible reasons for why this was happening. I realized that maybe the headlights were pointed the right way. Gently, I turned the headlights in different ways and tested my Boe-Bot every time I made a change. I was hoping that at least one of these positions would work. My headlights were originally pointing down and outward, the left one to the left, and the right one to the right. I tried pointing both of them straight down, without pointing outward. When I did this, my Boe-Bot started moving forward for a while, but then started doing the same thing again. I tried other positions. I pointed both of the headlights outward again at a different angle. This didn’t seem to work either.

As I was testing the Boe-Bot, it decided to turn off. My batteries started troubling me. This made me pretty angry. I was in the middle of solving a problem when my batteries decided to die. At first I thought of replacing my batteries. I didn’t do that immediately because I remembered my past experiences. I once had trouble like this. I thought the batteries were dead, but it turned out that the batteries’ position in the battery pack was messed up. Also, the Boe-Boost had moved out of place. I figured it would be the same problem once again. I took out my batteries, and put them back in. This didn’t take me much time. I easily slipped the Boe-Boost back in. This made me remember a few months ago. When I tried putting the Boe-Boost in for the first time, it was very difficult. I thought that it as impossible to place it in the right place. Now, I can do it in a matter of a few seconds. After placing my batteries, I turned on the Boe-Bot. It worked. I was relieved. At least I got something to work.

After fixing the battery problem, I went back to working on my headlights. I decided to change the way the IR detectors were bent. As I saw from the PDF, I had bent them a little bit so that they would point down to the IR headlights. I decided to make them straight again. I thought maybe the way they were bent hindered the process. When I did this, and turned on my Boe-Bot, I was surprised at what had happened. My Boe-Bot moved forward. I started in the white part. It kept moving forward and forward. When it reached the black part, of the drop-off zone, it turned. I literally jumped with joy when this happened. I finally got it to work. I tried it again and again. I got the same results. When it reached the drop-off zone, it realized that there is nothing there, therefore it needs to do an action.

After I finished this, I went on to doing the Your Turn. I had to do this.

Modify AvoidTableEdge.bs2 so that it follows the edge of the electrical tape

delimited course by adjusting the pulseCount values so that the Boe-Bot

doesn’t turn too far away from the edge.

This didn’t seem too hard to do. I figured that since we need the Boe-Bot to turn less, we need to reduce the pulseCount. The larger the pulseCount, the more it would turn. I have learned this by doing many previous activities such as The Ultimate Whisker Candy Challenge. Obviously, if it won’t go so far away, the Boe-Bot will stay close to the edge. Here is the program that I wrote.

‘ Robotics with the Boe-Bot – AvoidTableEdge.bs2

‘ IR detects object edge and navigates to avoid drop-off.

‘ {$STAMP BS2}

‘ {$PBASIC 2.5}

DEBUG “Program Running!”

irDetectLeft VAR Bit ‘ Variable declarations.

irDetectRight VAR Bit

pulseLeft VAR Word

pulseRight VAR Word

loopCount VAR Byte

pulseCount VAR Byte

FREQOUT 4, 2000, 3000 ‘ Signal program start/reset.

DO ‘ Main Routine.

FREQOUT 8, 1, 38500 ‘ Check IR detectors.

irDetectLeft = IN9

FREQOUT 2, 1, 38500

irDetectRight = IN0

‘ Decide navigation.

IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN

pulseCount = 1 ‘ Both detected,

pulseLeft = 850 ‘ one pulse forward.

pulseRight = 650

ELSEIF (irDetectRight = 1) THEN ‘ Right not detected,

pulseCount = 6 ‘ 6 pulses left.

pulseLeft = 650

pulseRight = 650

ELSEIF (irDetectLeft = 1) THEN ‘ Left not detected,

pulseCount = 6 ‘ 6 pulses right.

pulseLeft = 850

pulseRight = 850

ELSE ‘ Neither detected,

pulseCount = 10 ‘ back up and try again.

pulseLeft = 650

pulseRight = 850

ENDIF

FOR loopCount = 1 TO pulseCount ‘ Send pulseCount pulses

PULSOUT 13,pulseLeft

PULSOUT 12,pulseRight

PAUSE 20

NEXT

LOOP

Not sure if this works yet. I’ll just have to wait till next class to test it and fix it if there are any problems. Hopefully there aren’t any. Although I couldn’t get a whole lot done today, I did learn many things. Not only did I learn about programming, but I also learned about having patience and staying calm. If things are done with patience, the problems will be solved easily. Let’s just wait and see what will happen next class.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: