|Marble Sorter With Line Follower Help
|Page 1 of 1|
|Author:||whs001 [ Sun May 10, 2015 2:29 pm ]|
|Post subject:||Marble Sorter With Line Follower Help|
For my school project I need to make a marble sorter that automatically sorts 3 different types of marbles (Clear, Metal, and Wooden). In my design I have a gate using a servo, 2 conveyor belts that combined use a total of 3 motors, a line follower, and a bump switch. In my code I am multitasking to allow the belts and gate to operate at the same time, but I came across an issue. In my task main() I have 1 if statement which has 2 sub-if statements. When the first If statement runs, I want to stop the task which runs the first conveyor belt so my line follower can get an accurate reading to then run one of the 2 sub-if statements. My task does not stop when I use the stopTask() command. A friend told me to just make another task which will stop the task that controls my first belt, but that did not work. He then told me to have it manually stop the first belt (So that task does not have stopTask(taskname), it has the stopMotor(), wait(), and startMotor() commands), but that also did not work. Can someone here please help me out to see why this one section of the code will not run?
|Author:||jpalnick [ Mon Jun 22, 2015 9:54 am ]|
|Post subject:||Re: Marble Sorter With Line Follower Help|
You may have already solved this issue. However, this is a perfect example of how multitasking is not always the solution. There are times where multitasking can help, but this is not one of them.
In this particular case, you should look at your process. Is there anything that can't happen out of a sequential process order? If you don't need to process multiple things at the same time, there is almost never a reason to use multitasking.
From my understanding of your code and problem, you could simply have a single task with a single loop. In this one loop, you constantly check for a marble. When you detect a marble, you execute a specific set of commands for that marble type. In this case you could use something like the psudocode below as a base to work from.
|Page 1 of 1||All times are UTC - 5 hours [ DST ]|
|Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group