View unanswered posts | View active topics It is currently Fri Oct 31, 2014 2:15 am






Reply to topic  [ 2 posts ] 
Should I use multitasking? 
Author Message
Rookie

Joined: Thu Jan 30, 2014 9:28 am
Posts: 8
Post Should I use multitasking?
I am trying to program a toy jeep that is equipped with a Cortex, motors and GPS. I needed to make it so that the jeep will autonomously move to given coordinates, using the GPS which is connected through UART. The way I'm planning on doing this is by first making the jeep spin in a circle until it's facing north or south(depending on current coordinates and destination coordinates). Then, it will move straight until longitude matches the destination longitude and then continue with the latitude, the same way, until it finally reaches the destination.

Do I need to use multitasking since I need for the Cortex to refresh the coordinates from the gps and move the motors at the same time?


Wed Mar 05, 2014 9:11 am
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Should I use multitasking?
If it's as simple as you described it, then no. You can easily do it like the following pseudo-code. Your logic will be more complex than this but you get the point.
Code:
// Spin to face north or south.
while (readGPS() != north or south)
{
    motor[left] = 50;
    motor[right] = -50;
    wait1Msec(100);
}
motor[left] = 0;
motor[right] = 0;

// Drive to target longitude.
while (readGPS() is not reaching the longitude)
{
    motor[left] = 100;
    motor[right] = 100;
    wait1Msec(100);
}
motor[left] = 0;
motor[right] = 0;

// Spin to face east or west.
while (readGPS() != east or west)
{
    motor[left] = 50;
    motor[right] = -50;
    wait1Msec(100);
}
motor[left] = 0;
motor[right] = 0;

// Drive to reach latitude.
while (readGPS() is not reaching the lattude)
{
    motor[left] = 100;
    motor[right] = 100;
    wait1Msec(100);
}
motor[left] = 0;
motor[right] = 0;


Wed Mar 05, 2014 3:20 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.