|
Page 1 of 1
|
[ 11 posts ] |
|
Program doesn't execute 2nd time without power cycle.
Author |
Message |
tabbycatrobots
Rookie
Joined: Wed Dec 03, 2014 5:57 pm Posts: 22
|
 Program doesn't execute 2nd time without power cycle.
I have a line following robot with multitasking code. When I power up the robot, and start the program, all works okay, the robot follows the line (detailed description below). After a time, I push the BACK / ESCAPE button to stop the program. And the robots stops okay at this time. I then choose the program again, push the center button, and the screen shows: mindstorms CKLW09TestPadEV <-- this is the correct program name but the robot doesn't move. If I power down the robot, power it up, and start the program, all works okay. The screen shows the battery voltage, and min and max reflective light values, and the robot begins line following. Robot details: The robot does line following using an NXT B/W sensor, and 2 NXT motors. It follows the left side of the line on the NXT 2 test pad (8547). The robot has an EV3 color sensor to "see" the colored blocks on the right side of the line. When it sees a colored block, the robot stops and says the name of the color, then continues line following. The robot also has an NXT sonar sensor to slow down and stop if an obstacle is in its path. Program details: I define the sensors using the configuration wizard. It generates the following code: #pragma config(Sensor, S1, COLOR_SENSOR, sensorEV3_Color, modeEV3Color_Color) #pragma config(Sensor, S3, BW_SENSOR, sensorLightActive) #pragma config(Sensor, S4, SONAR_SENSOR, sensorSONAR) #pragma config(Motor, motorB, MTR_B, tmotorNXT, openLoop, driveRight, encoder) #pragma config(Motor, motorC, MTR_C, tmotorNXT, openLoop, driveLeft, encoder) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*// The main task starts a task to monitor the color sensor, and a task for line following. When the color detect task sees a color it puts a message in circular queue for the line following task. The line following task monitors the BW sensor, the sonar sensor, the queue from the color detect task, and controls the motors. Do I need to reset anything having to do with the sensors at the beginning of the program? Should I have my code monitor the BACK / ESCAPE button and stop the tasks in an orderly fashion, rather than having the BACK / ESCAPE button simply stop the program? Thanks for any info or suggestions. Howard
|
Wed Jan 21, 2015 4:39 pm |
|
 |
tabbycatrobots
Rookie
Joined: Wed Dec 03, 2014 5:57 pm Posts: 22
|
 Re: Program doesn't execute 2nd time without power cycle.
Additional detail - I'm using 4.28 BETA RobotC for EV3.
|
Wed Jan 21, 2015 4:41 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Program doesn't execute 2nd time without power cycle.
Do you have the complete source code for this?
= Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Thu Jan 22, 2015 3:45 am |
|
 |
tabbycatrobots
Rookie
Joined: Wed Dec 03, 2014 5:57 pm Posts: 22
|
 Re: Program doesn't execute 2nd time without power cycle.
I'm attaching the code as files rather than as listing in the message as there are 7 files in the program. Let me know if you prefer the code as listing in the message. The main program file is <CKLW_09_Test_Pad_EV.c>. The other 6 files are include files. The program compiles with no errors, but with some warning. These are due to variables in the include files that I do not use in this particular program. I just previewed this message, and it only shows that it is attaching 3 files. I will submit it and see what gets posted. If only 3 files are allowed, I will post 2 more messages. Some background: This code is ported from my earlier NXT / NXC project. I'm retired and a reading volunteer and I take my robots into a classroom whenever a teacher or principal requests. This robot and code has been visiting classrooms for 3 years. So, the code has been reliable. I suspect it may be something that I don't yet fully understand about starting and stopping tasks in RobotC, but this is a guess.
|
Thu Jan 22, 2015 2:13 pm |
|
 |
tabbycatrobots
Rookie
Joined: Wed Dec 03, 2014 5:57 pm Posts: 22
|
 Re: Program doesn't execute 2nd time without power cycle.
Here are 3 more include files. I'll attach the last file to the next message.
|
Thu Jan 22, 2015 2:20 pm |
|
 |
tabbycatrobots
Rookie
Joined: Wed Dec 03, 2014 5:57 pm Posts: 22
|
 Re: Program doesn't execute 2nd time without power cycle.
Here is the 7th and last file for this program. Thank you again.
Howard
|
Thu Jan 22, 2015 2:22 pm |
|
 |
Sigtrygg
Rookie
Joined: Mon Apr 08, 2013 12:50 pm Posts: 30
|
 Re: Program doesn't execute 2nd time without power cycle.
Hello!
I have the same Problem. The program works once a time and after pressing back button it blocks and I have to start the EV3 brick again. In one program I added "stopAllTasks();" before the end of main Task ():
task main() {
code....
stopAllTasks();
}
You can try it. But for my other program it doesn't work either.
Maybe the functions or while commands aren't stoped properly.
I never had these problems with the NXT-brick.
Regards,
Sigtrygg
|
Fri Jan 23, 2015 1:22 pm |
|
 |
tabbycatrobots
Rookie
Joined: Wed Dec 03, 2014 5:57 pm Posts: 22
|
 Re: Program doesn't execute 2nd time without power cycle.
I agree that the problem may in the task handling. I replaced the NXT BW sensor, that I was using, with an EV3 color sensor, for the line following and got same error. I wanted to rule out that it was an NXT sensor problem. I am simplifying my program to try to see where the problem begins. I need to test more, but. When I have just the main task and one other task that has stopped, I am able to restart okay. When there are the main task and 2 others, the problem occurs. I will try inserting the "stopAllTasks()" at various points to try to find the fail point and the minimum amount of code to reproduce the problem. Best guess now is the problem occurs when the back button is pushed when the main task and more than one other task are executing.
|
Sun Jan 25, 2015 3:47 pm |
|
 |
jkandra
Rookie
Joined: Thu Sep 25, 2014 8:34 pm Posts: 26
|
 Re: Program doesn't execute 2nd time without power cycle.
This is a problem with Multitasking on the EV3. If you run the Multitasking sample program, you will get the same problem. Once you run a program with multitasking on the EV3 and press the back button, you basically cannot run any other program on the EV3 without a complete power down unless you are connected to the computer and use the RobotC development environment to start the program. The back button will terminate the multitasking program. However, it does not terminate properly and therefore will prevent any other programs from running on the EV3 until you either 1) reboot the EV3 or 2) restart a program through the RobotC development environment. This happens even with the sample program provided by RobotC. I modified my programs to disable the back button using: setBlockBackButton(true); Then I set a combo-button press to execute the stopAllTasks() function. It's not a perfect solution. But it does work. This problem definitely adds to the excitement of Lego competitions when your robot freezes (not allowing you to run any programs) and you have to wait for it to power down and power back up before you can use it. The EV3 definitely takes more time to reboot than the NXT did. This issue has been discussed in several other posts over the past few months. viewtopic.php?f=63&t=9420and viewtopic.php?f=63&t=8910I know that multitasking is reserved for special cases and should generally not be used in most programs. However, I like the ability to create a robot that seems more able to react to events that occur (e.g., button presses, stalled motors, sensor readings). In an event driven robot, a button press may stop the current action and return the control to the menu system. In an event driven robot, a stall condition might stop the current action and continue with the next action in the program. It isn't necessary to program a stall function inside of each separate move function. A single stall function that is monitored through multitasking can provide input and control to all movement functions.
|
Wed Jan 28, 2015 9:59 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Program doesn't execute 2nd time without power cycle.
The multitasking issue is currently being investigated.
= Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Thu Jan 29, 2015 1:52 am |
|
 |
tabbycatrobots
Rookie
Joined: Wed Dec 03, 2014 5:57 pm Posts: 22
|
 Re: Program doesn't execute 2nd time without power cycle.
Thank you jkandra and Valter1966. I read through your comments and code in the issues and bugs forum, related to setBlockBackButton(true); and task StopAllTasksWithExitButton(). I've added a similar task to my failing code. All works okay now. And this is very important to me, and I expect others, as I imagine multitasking code as a solution for all but the simplest robots. Howard
|
Thu Jan 29, 2015 7:00 pm |
|
|
|
Page 1 of 1
|
[ 11 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
|
|