View unanswered posts | View active topics It is currently Wed Oct 22, 2014 11:05 pm






Reply to topic  [ 5 posts ] 
Working when stepping thru, not when run (sonic sensor, EV3) 
Author Message
Rookie

Joined: Sun Jul 20, 2014 6:56 pm
Posts: 6
Post Working when stepping thru, not when run (sonic sensor, EV3)
This works when we step thru, but not when run freely:

Code:
task main()
{
motor[motorA] = 50;
motor[motorB] = 50;

while(SensorValue[sonicSensor] > 15)
{

}

motor[motorA] = 0;
motor[motorB] = 0;
return;
}


We began trying to step through when we ran the program, and nothing happened. Then, it worked when stepping through. Weird?

Any thoughts on why?

Thanks.


Wed Jul 23, 2014 11:35 am
Profile
Expert
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 137
Post Re: Working when stepping thru, not when run (sonic sensor,
Is there something sitting within 15 cm of the ultrasonic sensor when you run the program? If there is, when you run it straight through, it will appear as if nothing happens because the motors will turn on, the loop will exit immediately, then the motors will be immediately shut off again. Stepping through the program delays the shutting off of the motors to when you step to that section of code, so you will be able to observe the motors turning on, then turning off.

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://cof7468.weebly.com/.


Wed Jul 23, 2014 1:56 pm
Profile
Rookie

Joined: Sun Jul 20, 2014 6:56 pm
Posts: 6
Post Re: Working when stepping thru, not when run (sonic sensor,
Just retried it, making sure there was nothing in front of the sensor, and it still shut off right away. FRUSTRATING.


Wed Jul 23, 2014 2:37 pm
Profile
Rookie

Joined: Sun Jul 20, 2014 6:56 pm
Posts: 6
Post Re: Working when stepping thru, not when run (sonic sensor,
Whoa. Does the sensor initialize itself or something at the beginning of a program? I'm noticing that the light on the sensor turns off right at the beginning, and then comes back on after 1/2 a second or so. When I step through, I think I've given it time to run through whatever it is doing, while running it straightaway doesn't give it that time, and the while statement then has nothing to go on, so errors out. When I add a wait statement right at the beginning of the code, it works!


Wed Jul 23, 2014 4:23 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3225
Location: Rotterdam, The Netherlands
Post Re: Working when stepping thru, not when run (sonic sensor,
This program works as intended. Could you try this? Please note that I am using an internal build.

= Xander

Code:
#pragma config(StandardModel, "EV3_REMBOT")
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

/*
This program assumes you are using the standard LEGO Education robot
Sensor Ports:
S1 = Touch
S2 = Gyro
S3 = Color
S4 = Sonar (Ultrasonic)

Motor Ports:
A = Arm Motor
B = Right Motor
C = Left Motor
*/

task main()
{
  motor[motorC] = 50;
  motor[motorB] = 50;

  while(SensorValue[sonarSensor] > 15)
    sleep(10);

  motor[motorC] = 0;
  motor[motorB] = 0;
  return;
}

_________________
| 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]


Fri Jul 25, 2014 1:31 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 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:  
cron



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