Go to Post We want to go out and build something right away. But it is better to think a little bit first. - ChrisH [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 02-17-2016, 08:22 AM
Tominator368 Tominator368 is offline
Registered User
AKA: Thomas Schweich
FRC #4500 (Robohounds)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2013
Location: STL
Posts: 5
Tominator368 is an unknown quantity at this point
TeleopPeriodic doesn't seem to iterate fast enough to smoothly run motors

Once we finished wiring our robot, we decided to quickly throw together a program which would allow us to test all of our motors. It was simply an iterative robot which instantiated motors controllers like
Code:
Victor motor = new Victor(0);
for each motor we wanted to test, and then in TeleopPeriodic, had code that looked like:
Code:
void teleopPeriodic() {
   motor.set(.5);
}
Just to see if they would run, if we hooked them up right. But when I ran this code on a motor, it behaved sluggishly and was jittery. My theory was that the set() function wasn't being called rapidly enough, so I decided to place the call in a while loop so that it would iterate faster (I know you're not supposed to do this, since it screws up the timing completely) as follows:
Code:
void teleropPeriodic() {
   while(true) {
      motor.set(.5)
   } 
}
Lo and behold, the motor ran perfectly. Isn't the iterative code supposed to iterate fast enough to run a motor? Obviously we don't want to use a while loop in our actual code, since that would literally bring the period to a halt. If you are supposed to be able to do this, what might be causing the problem for us? Thanks.

Last edited by Tominator368 : 02-17-2016 at 08:23 AM. Reason: Spacing
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:04 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi