View unanswered posts | View active topics It is currently Thu Apr 24, 2014 10:56 pm






Reply to topic  [ 11 posts ] 
Program doesn`t start after turning brick off and on 
Author Message
Rookie

Joined: Wed Apr 25, 2012 11:56 am
Posts: 6
Location: Russia, Tomsk
Post Program doesn`t start after turning brick off and on
Afetr compile and downloading program to brick it works perfectly. But when I turn brick off and than turn it on I try to start program. All I see is text "%program name% running". And nothing works. Screen doesn`t siplay any messages. But while according to code it should display some values. What is wrong?


Wed Apr 25, 2012 12:01 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Program doesn`t start after turning brick off and on
FosterChip wrote:
Afetr compile and downloading program to brick it works perfectly. But when I turn brick off and than turn it on I try to start program. All I see is text "%program name% running". And nothing works. Screen doesn`t siplay any messages. But while according to code it should display some values. What is wrong?


Can you post your program?

Like this:

Code:
[code]Hi!  Put your program between these tags![/code]

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Wed Apr 25, 2012 12:05 pm
Profile WWW
Rookie

Joined: Wed Apr 25, 2012 11:56 am
Posts: 6
Location: Russia, Tomsk
Post Re: Program doesn`t start after turning brick off and on
Sure,

But it`s hard to post it here. It uses few .c files.
I have just wrote simple program for testing.

Code:
 
task main()
{
  int iteration = 0;
 
  while (true)
  {
    /* Motors */
    motor[motorA] = 30;
    motor[motorB] = 30;
   
    /* Display */
    eraseDisplay();
    nxtDisplayTextLine(0, "it:%d", iteration);
    wait1Msec(100);
   
    /* Iteration */
    iteration++;
  }
}


This program works great after turning off and on. So, I understand, that this problem depends on program.


Wed Apr 25, 2012 12:16 pm
Profile
Rookie

Joined: Wed Apr 25, 2012 11:56 am
Posts: 6
Location: Russia, Tomsk
Post Re: Program doesn`t start after turning brick off and on
I really don`t get why it doesn`t work after reboot.
My program contains multitasking.

It`s a little bit hard for me to explain. This program was written in NXC first. But then I switched to RobotC.

So, main task makes orders to another tasks. Such as Sensors, Display, Movement and Control task.
There is an array of orders to give.
Each task works in while loop waiting for a new order.

Sensors read values from each sensor (int this version I have 2 light sensors for line follower) and store them into global variables leftSensorValue and rightSensorValue.

Movement task executes the order (order is to follow the line using the PID regulation).
For PID regulation I have a special function in another one .c file.

Display task erases screen each 100 ms and prints desired information.

Code is,

Main Task
Code:
#pragma config(Sensor, S1,     lightSensorLeft,         sensorLightActive)
#pragma config(Sensor, S2,     lightSensorRight,        sensorLightActive)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//
#include "Order.c"
#include "Variables.c"
#include "PidLineFollow.c"
#include "Display.c"
#include "Sensor.c"
#include "Movement.c"
#include "Control.c"
//*!!Special tasks!!*//

void ReadOrder(int order_num);

task main()
{
  InitializeOrderLineMain();

  StartTask(sens, kDefaultTaskPriority);
  StartTask(move, kDefaultTaskPriority);
  StartTask(disp, kDefaultTaskPriority);

  while (true)
  {
    if (masterGiveOrder)
    {
      ReadOrder(masterCurrentOrder);
      if (OrderLineMainNext[masterCurrentOrder] == false)
        masterGiveOrder = false;
    }
  }
}

void ReadOrder(int order_num)
{
  int order = OrderLineMain[order_num];
  if (order == 0x06)
  {
    ord_pid_line_follow = true;
  }
}


Orders File
Code:
int OrderLineMain[100];
bool OrderLineMainNext[100];
bool ord_pid_line_follow = false;

void InitializeOrderLineMain()
{
  OrderLineMain[0] = 0x05; // Wait
  OrderLineMainNext[0] = true;
  OrderLineMain[1] = 0x06; // pid line follow
  OrderLineMainNext[1] = false;
}


Global Variables
Code:
/*Motors*/
int powerLeftMotor,
    powerRightMotor;

/*Sensors*/
int leftSensorValue = 0,
    rightSensorValue = 0;

/*Master*/
bool masterGiveOrder = true;
int masterCurrentOrder = 1;


Sensors
Code:
task sens()
{
  while (true)
  {
     leftSensorValue  = SensorValue[lightSensorLeft];
     rightSensorValue = SensorValue[lightSensorRight];
  }
}


Movement
Code:
task move()
{
   while(true)
   {

     if (ord_pid_line_follow)
     {
       PidLineFollow(100);
     }
   }
}


PidLineFollow (this is exemple code). Anyway, even with empty fucntion problem persists.
Code:
void PidLineFollow(int speed)
{
   motor[motorA] = speed;
   motor[motorB] = speed;
}


Wed Apr 25, 2012 12:38 pm
Profile
Rookie

Joined: Wed Apr 25, 2012 11:56 am
Posts: 6
Location: Russia, Tomsk
Post Re: Program doesn`t start after turning brick off and on
Well, if immediately turn brick on after turning it off the program still starts and works. But after 10sec waiting it won`t start


Wed Apr 25, 2012 1:18 pm
Profile
Moderator
Moderator
User avatar

Joined: Thu Dec 22, 2011 7:42 am
Posts: 43
Post Re: Program doesn`t start after turning brick off and on
This is more a question than a tip:
Does the fact to download a program reset something in the brick ? (something that is not reset by a simple program launch).

Miki.

_________________
Visit my project RainBot v0.11 on source forge, a 6 wheels robot featuring A* & Dijkstra's path finding, motors & sensors emulation, small font, fifo & sorted list libraries, using Xander's drivers for HT Compass, and documented with doxygen.


Thu Apr 26, 2012 6:07 am
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Program doesn`t start after turning brick off and on
Have you tried it on a different NXT? Since your program is in multiple files, could you pleas upload a .zip (or similar) containing them all? I've never heard of a problem like this before.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Fri Apr 27, 2012 3:19 pm
Profile WWW
Rookie

Joined: Wed Apr 25, 2012 11:56 am
Posts: 6
Location: Russia, Tomsk
Post Re: Program doesn`t start after turning brick off and on
I`ll try to run this on a different NXT and will tell you the results soon.


Sat Apr 28, 2012 3:09 am
Profile
Moderator
Moderator
User avatar

Joined: Thu Dec 22, 2011 7:42 am
Posts: 43
Post Re: Program doesn`t start after turning brick off and on
Hi FosterChip

Did you try to switch on the option 'zero variables before program starts (n/a VEX)' ?
This option is located in 'View' menu, 'RobotC preferences' dialog box then 'Compiler' tab, according that the option 'Super User' is set in 'Window'/'Menu Level'.

Miki

_________________
Visit my project RainBot v0.11 on source forge, a 6 wheels robot featuring A* & Dijkstra's path finding, motors & sensors emulation, small font, fifo & sorted list libraries, using Xander's drivers for HT Compass, and documented with doxygen.


Mon Apr 30, 2012 11:44 am
Profile
Rookie

Joined: Wed Apr 25, 2012 11:56 am
Posts: 6
Location: Russia, Tomsk
Post Re: Program doesn`t start after turning brick off and on
Hi everyone!

Well, I`ve found the source of problem.
As you noticed, in task main() I call StartTask function with followint arguments:
StartTask(sensors, kDefaultTaskPriority);

So, writing kDefaultTaskPriority was a mistake. Since I deleted this parameter from StartTask function, program works properly after rebooting brick.

It`s interesting that in Multitasking sample program there are return statements at the end of each task. I`ve thought that this is the reason of improper work, but I was wrong.

Thanks for the help!


Fri May 04, 2012 4:53 am
Profile
Moderator
Moderator
User avatar

Joined: Thu Dec 22, 2011 7:42 am
Posts: 43
Post Re: Program doesn`t start after turning brick off and on
Hi FosterChip,

I'm glad you found a workaround to this problem :-), even if I don't understand how it solves the issue :eek: .
The documentation says
Quote:
StartTask(TaskID, nPriority);
StartTaskWithPriority(TaskID, nPriority);
A functional call to start or restart the execution of a specific task. The "nPriority" command is optional, and can be used to assign a priority to a task at the time the task is told to start executing. If the "nPriority" command is not specified, the task will start with a default priority of "7".
A reading at first glance suggests that StartTask(TaskID, kDefaultTaskPriority) is the same than StartTask(TaskID);.
Another reading of this documentation chapter suggests that if you want to change the priority of a task, you should use StartTaskWithPriority(TaskID, nPriority); rather than StartTask(TaskID, nPriority); But in RobotC v3.08 and fw9.12, this function StartTaskWithPriority(TaskID, nPriority); doesn'exist :-(
So the documentation is obsolete (because StartTaskWithPriority() doesn't exist) and probably false (because it seems that StartTask(TaskID, kDefaultTaskPriority) doesn't behave like StartTask(TaskID))

Would you submit a ticket about that on http://www.robotc.net/support/ with a link on this topic (posting.php?mode=reply&f=1&t=4470)?
Thanks for sharing information.

Best regards
Miki

_________________
Visit my project RainBot v0.11 on source forge, a 6 wheels robot featuring A* & Dijkstra's path finding, motors & sensors emulation, small font, fifo & sorted list libraries, using Xander's drivers for HT Compass, and documented with doxygen.


Fri May 04, 2012 7:55 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 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

Search for:
Jump to:  



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