View unanswered posts | View active topics It is currently Mon Sep 28, 2020 4:07 pm

Reply to topic  [ 2 posts ] 
Encoder issues 
Author Message

Joined: Fri Jan 31, 2014 4:08 pm
Posts: 3
Post Encoder issues
I have a student working on a AGV and has to program it to travel back and forth. I have also required them to program in a kill switch and safety sensors. These sensors stop the vehicle if something crosses into it path. They are using an encoder to get it to travel the correct distance back and forth. The issue is when the sonar sensors stop the vehicle the encoder zero's out. Thus when the vehicle continues on the count is messed up. Any help? Program Attached. Any help would be greatly appreciated

AGV.c [1.03 KiB]
Downloaded 402 times
Fri Jan 31, 2014 4:15 pm
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 722
Post Re: Encoder issues
The reason you are running into this is because the 'untilEncoderCounts' command automatically resets the encoder counts when it is called (pulled from the NatLang_Cortex.c include file):

void untilEncoderCounts(long distance = 360, tSensors sensorPort = dgtl1)
  SensorValue[sensorPort] = 0;

  while(abs(SensorValue[sensorPort]) < abs(distance)){wait1Msec(1);}

This particular task may be beyond the functionality of the Natural Language programming and could serve as a good introduction to true ROBOTC programming. You can create either a custom function without the 'SensorValue[sensorPort] = 0;' command (or equivalent), or add the while loop directly into the code:

   startMotor(drive, 127);
   while(SensorValue[counter] > -11700);

There are also other ways to perform this behavior and these are only two examples of how to do this.

Check out our Blog! And our Facebook page!
Need help? Take a look at our updated help documentation and the ROBOTC Forums.

Mon Feb 03, 2014 11:25 am
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.