User:LoveMango/ENES-100/Project 1: The Line Bot Project

Back to my project page: https://en.wikiversity.org/wiki/User:LoveMango/ENES-100

Week0 Preferences
The goal of this project is to program the line following robot to solve a maze made of black electrical tape. I've broken the project down into four tasks.

Task 1: Get the line bot moving.

Task 2: Test the sensor board responsible for feedback to the Arduino microcontroller.

Task 3: Program the Arduino to sense and follow a black line against a white background.

Task 4: Get the Arduino to remember previous paths taken and generate the fastest way possible to the end of the maze.

My other team members are working on building a new line bot using the 3D printer to recreate the structure. There may be a chance that a new model will be produced-- one that is more efficient than the prototype we began with.

Week1 Narrative
I mostly spent this week gathering information on how the Arduino works, how the sensor array board functions, and how the cycle of feedback occurs.

The Arduino picks up various impulses from the sensor inputs and supplies this continuous stream of numerical input to express the amount of light being detected on the sensor array board.

Long story short, the sensor board senses the line & shoots numbers about where it went at about 10 reads per second. The Arduino then shoots these numbers towards the motor. It's all about following the higher numbers.

There is a special monitor with a string of numbers, 8 in total, that represents the sensory input from each LED infrared sensor on sensor array board. When the numbers read close to 0 or within double digits, that means the sensor is over a white background. When the numbers shoot into the triple digits, that means the sensor is hovering over the black electrical tape, or is receiving a malfunctioning signal. When the Arduino turns towards the computed higher numbers, as long as the sensors are functioning properly, the Line Bot follows the line.

When the numbers drop, the path is lost. It will turn in search of the highly numbered pathway, then continue.

Week2 Narrative
It took forever just getting a reading from the sensor array board (I had trouble finding the serial monitor thinking it was supposed to be in a whole different program altogether... Epic fail).

When the sensors are exposed to the white sheet of paper, I get fairly low ratings.

On a scale of 1 to 1000, when the sensors are on lighter ground the ratings tend to stick to the lower hundreds (100-200) and both single and double digits (1-90s).

When the sensors detect the electrical tape it goes up to the 600s maxing out at about 1000.

www.youtube.com/embed/Lk0v5YXtSF4

The problem with the sensor board:

When the furthermost right sensor on the serial screen picks up the white sheet of paper, it continuously displays the value "1000". When placed under the electrical tape, it skyrockets to the 2000-3000s. This is how I know it picks up some information, but does not explain why its so drastically different from the others.

It seems to me that the furthermost right part of the sensor is not working. It could also just be that my way of holding it, being right handed, makes the sheet of paper appear closer to that sensor making the readings off of it a lot different than the rest. It still gives some input.

Aside from that, I have other things to worry about. Now I need to figure out how this cycle of feedback fits into the running of the motors.

Then, I'll need to figure out how to make the line bot remember & calculate paths to take.

The final step will be to make it able to differentiate between different paths and solve a maze in as little of time as possible.

Task 2 ✔

Week3 Narrative
This week mostly comprised of getting the robot up and running for testing. The rubbers of the tires kept falling off mid run. While the robot was successfully following a line the motor wire fell out! The robot kind of just kept spinning in circles after that. It took a while to realize. The motor wires kept getting disconnected and the battery pack case needed replacing. In the process of correcting this, the negative wires on the motor ended up a bit... crossed. I've been dabbling in sketches but I hadn't quite gotten the hang of accounting for the crossed negative wires on the robot. It followed the line pretty okay prior to the wires being crossed, but now it doesn't move. One wheel turns one way, while the other turns the opposite.

Notes:

I did a presentation on soldering. It's really hard to solder a brushed motor without melting down the plastic and rendering it useless. This is why I couldn't simply just uncross the wires.

On a similar but unrelated note, you have to properly clean the soldering iron! Or it just serves as another hot piece of metal that sucks at gluing wires together...

There was a short in the old sensor array board. I need to test the old sensor array board (the one with two headers) to make sure it's still functioning, as well as the Arduino and the Sparkfun motorshield I'd been using with it. I know for sure that two wires I'd been using are no longer functioning.

The short was caused by connecting all the GND pins of the infrared LEDs to a bread board so they'd all fit into the GND pin in the Arduino. This was while the sensor pins were being fed to the digital pins. The labels can be misleading. Don't do it. It doesn't light up like it seems to in the YouTube videos. Haven't found anything specifically about it in the QTR-8RC manual yet. I'm hoping the sensor array board and the Arduino & motorshield haven't been damaged in the process.

Task 1 ✔

Week4 Narrative
When the sensor array board is functioning, it reads 0 for the minimum amount of light reflected, and 1000 for maximum.

So if you calibrate for open air versus your finger, the open air will read 1000, and your finger against the sensor will read 0 or somewhere in the double digits.

If calibrating for electrical tape on top of a sheet of white paper, the paper will read 0 while the electrical tape will read at 1000, giving a pretty good visual of where the electrical tape is in respect to the sensors on the array board. A mistake I made frequently with testing out the sensor array boards was using the QTR-A Example sketch when programming the Arduino rather than the QTR-8RC. It will appear that none of the sensors are working, [0, 0, 0, 0, 0, 0] when really it's looking for a fewer amount of sensors connected to the analog ports.

Make sure to use the QTR-8RC Example and have the sensors connected to digital pins 3-8 respectively, or whatever you define them to be in the script.

I tried to get the QTR-8RC Example to work on the sensors while they were connect to the robot itself, but I can't seem to get reads from the first two sensors through the first two analog ports A0 and A1. I know they have a separate function from the other 4 analog points, but I'm trying to figure out a way to manipulate the code to overcome this. I could use this override to help with getting the robot to respond appropriately when sensing the line.

Week5 Narrative
My work on this project is coming to a close as it's being passed on to the next group.

The borrowed script I've been working on tweaking goes as follows.

int LightValueA0; // The value from the sensor (0..1023) int LightValueA1; // The value from the sensor (0..1023) int ENA=5;//connected to Arduino's port 5(output pwm) int IN1=2;//connected to Arduino's port 2 DIRA int IN2=3;//connected to Arduino's port 3 DIR#A -- Motor A Brake int ENB=6;//connected to Arduino's port 6(output pwm) int IN3=4;//connected to Arduino's port 4 DIRB int IN4=7;//connected to Arduino's port 7 DIR#B -- Motor B Brake
 * 1) define SENSOR_PINA0 A0
 * 2) define SENSOR_PINA1 A1

void setup { Serial.begin (115200); pinMode(ENA,OUTPUT);//output pinMode(ENB,OUTPUT); pinMode(IN1,OUTPUT); pinMode(IN2,OUTPUT); pinMode(IN3,OUTPUT); pinMode(IN4,OUTPUT); digitalWrite(ENA,LOW); digitalWrite(ENB,LOW);//stop driving }

void loop { {   LightValueA0 = analogRead(SENSOR_PINA0);  //Read the voltage from sensor Serial.println(LightValueA0,DEC);     // Send result to Serial Monitor delay(100); LightValueA1 = analogRead(SENSOR_PINA1); //Read the voltage from sensor Serial.println(LightValueA1,DEC);     // Send result to Serial Monitor delay(100); if (analogRead(SENSOR_PINA0) >= 900 && analogRead(SENSOR_PINA1) >= 900) {digitalWrite(9, HIGH);  // set the LED on    delay(100);              // wait for a second digitalWrite(9, LOW);   // set the LED off delay(100);             // wait for a second analogWrite(ENA,200);//start driving motorA analogWrite(ENB,230);//start driving motorB digitalWrite(IN1,LOW); digitalWrite(IN2,HIGH);//setting motorA's directon digitalWrite(IN3,HIGH); digitalWrite(IN4,LOW);//setting motorB's directon delay(200); analogWrite(ENA,200);//start driving motorA analogWrite(ENB,230);//start driving motorB digitalWrite(IN1,LOW); digitalWrite(IN2,LOW);//setting motorA's directon digitalWrite(IN3,LOW); digitalWrite(IN4,LOW);//setting motorB's directon delay(50); }   if (analogRead(SENSOR_PINA0) >= 900 && analogRead(SENSOR_PINA1) <= 900) {   analogWrite(ENA,180);//start driving motorA analogWrite(ENB,230);//start driving motorB digitalWrite(IN1,LOW); digitalWrite(IN2,HIGH);//setting motorA's directon digitalWrite(IN3,LOW); digitalWrite(IN4,HIGH);//setting motorB's directon delay(100); analogWrite(ENA,200);//start driving motorA analogWrite(ENB,230);//start driving motorB digitalWrite(IN1,LOW); digitalWrite(IN2,LOW);//setting motorA's directon digitalWrite(IN3,LOW); digitalWrite(IN4,LOW);//setting motorB's directon delay(50); } {    if (analogRead(SENSOR_PINA0) <= 900 && analogRead(SENSOR_PINA1) >= 900) {   analogWrite(ENA,230);//start driving motorA analogWrite(ENB,180);//start driving motorB digitalWrite(IN1,HIGH); digitalWrite(IN2,LOW);//setting motorA's directon digitalWrite(IN3,HIGH); digitalWrite(IN4,LOW);//setting motorB's directon delay(100); analogWrite(ENA,200);//start driving motorA analogWrite(ENB,230);//start driving motorB digitalWrite(IN1,LOW); digitalWrite(IN2,LOW);//setting motorA's directon digitalWrite(IN3,LOW); digitalWrite(IN4,LOW);//setting motorB's directon delay(50); } {    if (analogRead(SENSOR_PINA0) <= 900 && analogRead(SENSOR_PINA1) <= 900) {   analogWrite(ENA,230);//start driving motorA analogWrite(ENB,230);//start driving motorB digitalWrite(IN1,LOW); digitalWrite(IN2,LOW);//setting motorA's directon digitalWrite(IN3,LOW); digitalWrite(IN4,LOW);//setting motorB's directon delay(100); } delay(100); }}}}

So the sketch needs to be changed to account for DIRA & DIRB (as well as their brakes?) being switched, then tested for function on a line. I haven't dabbled into the maze solving sketching yet.