AGV Wheel Controll

Dear All I built a AGV and set a guide sensor on the front.The sensor has 6 segments inside(No.1,2,3,4,5,6).The AGV have 2 wheel and each wheel drive by motor. It walk alone one maganet tape on ground .When AGV run,if the tape between on sensor No3 and 4.The 2 side wheel runnig speed is same. When the tape exceed 3 to 4,for example on 4 to 5.Then right wheel make it faster and little bit turn.Make AGV always alone the tape. The other side as the same. I'd like to write a code but have no ideal.Could you give me some example or simple code for this one?

Best Regard!

I'd like to write a code but have no ideal.

You didn't think this through before you started did you ?

Could you give me some example or simple code for this one?

I think it unlikely that any existing program will match your exact setup so it will need amending. With your level of knowledge it is unlikely that you will be able to do this. In any case the code will not be simple.

Have you written any programs for the Arduino or looked at and run any of the examples ?

Can you provide a link to the vehicle that you have built ? It is possible that there are example programs on the supplier's or manufacturer's websites.

Hi,My friend!
I used CAD Photo as attachnent to description.It’s make us can see the construction easier.
And I write a simple code as blow.But only make motor Run/Stop/Speed Up etc…
The logical code that make AGV walk alone the tape still no ideal.

int lss = 52; int rss=53; //High=Start ; Low=Stop
int lrb_ip = 50; int rrb_ip=51; //High=Run ; Low=Brake
int lcww = 48; int rcww=49; //High=Forward ; Low=Backward
int ralarm_reset=47; //High=Alarm ; Low=Reset
int lvrm_ip=3; int rvrm_ip=4; //Voltage output with PWM

int lmotoralarm = 42; int rmotoralarm=43; //User Extend to Motor Pin1 //High=Alarm ; Low=Reset

void setup() {
// put your setup code here, to run once:
pinMode(lss, OUTPUT); pinMode(rss, OUTPUT); //High=Start ; Low=Stop
pinMode(lrb_ip, OUTPUT);pinMode(rrb_ip, OUTPUT); //High=Run ; Low=Brake
pinMode(lcww, OUTPUT);pinMode(rcww, OUTPUT); //High=Forward ; Low=Backward
pinMode(lvrm_ip, OUTPUT);pinMode(rvrm_ip, OUTPUT); //Voltage output with PWM
pinMode(lmotoralarm,INPUT);pinMode(rmotoralarm,INPUT); //High=Alarm ; Low=Reset
}

void loop() {
// put your main code here, to run repeatedly:
digitalWrite(lss, LOW); digitalWrite(rss, LOW); //Motor Stop
digitalWrite(lrb_ip, LOW); digitalWrite(rrb_ip, LOW); //Motor Brake
digitalWrite(lcww, HIGH); digitalWrite(rcww, LOW); //One motor Forward & the other Backward //AGV turn one Side

analogWrite(lvrm_ip, 120); analogWrite(rvrm_ip, 120); //Motor speed up to 47%
}

Attachment send again

attachment send again 2

AgvView.zip (52 KB)

Those pictures show us nothing important except which order the sensors are in across the front bar. Without more detail the only help I can give is as follows

Read all 6 sensors If sensors 3 and 4 both see the line run both motors at the same speed if sensor 3 sees the line but not sensor 4 speed up the left motor a little or slow down the right a little or both if sensor 4 sees the line but not sensor 3 speed up the right motor a little or slow down the left a little or both if sensor 2 sees the line speed up the left motor more or slow down the right more or both if sensor 5 sees the line speed up the right motor more or slow down the left more or both if sensor 1 sees the line speed up the left motor much more or slow down the right much more or both if sensor 6 sees the line speed up the right motor much more or slow down the left much more or both

You have not said what type of sensors are being used, how far apart they are and whether only one can sense the line at any one time because of their spacing so it is impossible to give more help.

Do you know how to read the sensors ? Are they analogue or digital sensors ? Does the tape have to be magnetic for the sensors to work ? How is the vehicle powered ?

Sorry, I do not describe very clearly. The detail as blow.
1.『what type of sensors are being used』
→Like attachment
2. 『how far apart they are』
→10mm
3.『whether only one can sense the line at any one time』
→Always 2 sensors ON.
4.『Do you know how to read the sensors ?』
→See Attachment.
5.『Are they analogue or digital sensors ?』
→digital sensors
6.『Does the tape have to be magnetic for the sensors to work ?』
→Yes, I used the way right now.
7.『How is the vehicle powered ?』
→Battery DC24V ride on vehicle,sorry I didn’t show it on picture.

16SensorField.pdf (5.07 KB)

The attachment is not much help in answering some of the questions. The main one for me is "Do you know how to read the sensors ?" If you do not have that basic level of knowledge then you are going to have immense problems. If you do know how to do it then start by writing a program that reads all the sensors and prints the result to the Serial monitor. Then we can talk about the logic needed to steer the vehicle.

Another question. How are the motors going to be connected to the Arduino ?

I will try to write a code and see what happen. And the way of connection as attachment.

Connection.pdf (74.6 KB)