Simpler Linienfolger

Hello Together

Today I would like to introduce you to a project that we became aware of through a customer request. We build a simple line-following robot.

The project is designed to run the code with both two-wheeled and four-wheeled robots and represents a compromise. For continuous operation, the sketch and the interconnection should be changed, as the load of the four motors on one IC is very high.

With the help of two sensors, the vehicle distinguishes between white and black background and corrects the direction of travel accordingly, we use our new sensor modules without poti.

The principle is quite simple and the corresponding code accordingly compact, which we liked very much about this project. 

For this project I have created a set for you, this can be found Here

So we need:

We start with the assembly of the chassis:

First you should peel off the protective foils, we did not do this, because transparent plates can be photographed even worse.

For easier assembly, you should wire the motors before installation.

To do this, solder cables to the small brass flags of the motors. Where red and black are fastened does not matter for the time being. For a short understanding: the direction of travel of the motors can be changed by turning the pole. 

Next, plug the brackets for the motors through the chassis.

Then fasten the wired motors with the long, enclosed screws and secure them with the nuts:

Then put the brass bolts through the plate and attach them with the enclosed nuts, where you attach them is dependent on your design and later use. The positions are variable.

As a next step, you can already mount the top and screw it on:

For better understanding, here is a picture from the page:

 

You can also determine where you attach your controller and in which direction the line follows. This completes the assembly of the mechanics. As the next step, you should solder the pin headers on the motor shield, as shown here in the picture:

These are required in order to be able to connect the sensors later.

The glued-on heat sinks are not necessarily necessary, but highly recommended. It is easily possible to distribute the load to several ICs and connect all four motors separately to the shield (can also be changed in the Sketch).

Next is the connection of the motors: first we switch the two motors of the left side and the right side together. Here you have to try something until the engines of one side, and the engines of the other side run together in the same direction. As already mentioned, this can be easily changed by swapping the poles.

Connect the motors here:

The connectors are labeled on the board with M3 and M4, each the left motors on one terminal, and the right one on the second terminal.

Now the power supply: The shield also supplies the microcontroller with power.

The two arrows at the bottom right of the image mark the connectors for A4 and A5, where we connect our line follower sensors.

Since we remodel our robo-car more often, we have only temporarily attached the sensors with adhesive tape. The left sensor on pin A4, the right sensor on A5, as shown here in the picture:

It is important not to mount the sensors frontally, but to see them slightly obliquely on the flanks, as seen in the picture above.

Before we devote ourselves to the code we borrowed from Aarav, we need a libary for the Engine Shield. We have used the Adafruit Libary which you Here To find.

Here is the code:

 

   ////////////////////////////////////////////////////////   LinoBot v1.0 /             
 By Aarav Garg
////////////////////////////////////////////////////////

I have added the possibilities of testing
The values of analogRead could be changed for trouble shooting

including the libraries
#include <AFMotor.H>

defining pins and variables
#define lefts A4 
#define Rights A5 

defining motors
AF_DCMotor motor1(4, MOTOR12_8KHZ); 
AF_DCMotor motor2(3, MOTOR12_8KHZ);
/*
AF_DCMotor motor3(1, MOTOR12_8KHZ);
AF_DCMotor motor4(2, MOTOR12_8KHZ);
 */

Void Setup() {   setting the speed of motors   motor1.setSpeed(100);   motor2.setSpeed(100);   declaring pin types   pinMode(lefts,Input);   pinMode(Rights,Input);   begin serial communication   Serial.Begin(9600);    }

Void Loop(){   printing values of the sensors to the serial monitor   Serial.println(analogRead(lefts));   Serial.println(analogRead(Rights));   line detected by both   If(analogRead(lefts)<=400 && analogRead(Rights)<=400){     Stop     motor1.Run(Release);     motor2.Run(Release);   }   line detected by left sensor   else If(analogRead(lefts)<=400 && !analogRead(Rights)<=400){     turn left     motor1.Run(Backward);     motor2.Run(Forward);     /*
 motor1.run(RELEASE);
 motor2.run (FORWARD);
     */   }   line detected by right sensor   else If(!analogRead(lefts)<=400 && analogRead(Rights)<=400){     turn right     motor1.Run(Forward);     motor2.Run(Backward);     /*
 motor1.run (FORWARD);
 motor2.run(RELEASE);
     */   }   line detected by none   else If(!analogRead(lefts)<=400 && !analogRead(Rights)<=400){     Stop     motor1.Run(Forward);     motor2.Run(Forward);     /*
 motor1.run(BACKWARD);
 motor2.run(BACKWARD);
     */   }    }


By the way, the analog pins were used because, unlike the digital pins on the shield, they are easily accessible.

The project is designed to run the code with both two-wheeled and four-wheeled robots and represents a compromise. For continuous operation, the sketch and the interconnection should be changed, as the load of the four motors on one IC is very high.

Setting the running direction for the traction motors can be a bit tricky, here a little patience is required.

Have fun rebuilding & until the next time :) 

 

For arduinoProjects for beginnersSensoren

3 comments

Stefan

Stefan

Der set link funktioniert nicht.

Lg

Moritz

Moritz

Hallo,
die vier Motoren sind im Beitrag oben am Shield an M3 und M4 angeschlossen. Das funktioniert bei uns wunderbar, allerdings ist die Last auf den IC recht hoch. Die Last lässt sich bei zusätzlicher Nutzung von M1 und M2 auf dem Shield verteilen, sprich je einen Motor pro Anschluss. Den Sketch müssen Sie dann erweitern, indem Sie die beiden zusätzlichen Motoren zuerst definieren und anschließend mit motor3.run und motor4.run erweitern.

Frank Raddau

Frank Raddau

Hallo,
Wie würde der Sketch und die Verschaltung für eine Dauerbelastung aussehen?
Danke im voraus.

Leave a comment

All comments are moderated before being published

Recommended blog posts

  1. Install ESP32 now from the board manager
  2. Lüftersteuerung Raspberry Pi
  3. Arduino IDE - Programmieren für Einsteiger - Teil 1
  4. ESP32 - das Multitalent
  5. OTA - Over the Air - ESP programming via WLAN