Thread: Ramping Motors?
View Single Post
  #2   Spotlight this post!  
Unread 26-01-2013, 22:37
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: Ramping Motors?

In execute, try something along the lines of:

if (currentVoltage < targetVoltage)
currentVoltage += 0.01
else if (currentVoltage > targetVoltage)
currentVoltage -= 0.01

This will bump your voltage closer to your target voltage each iterative loop.

Of course you'll want to clean it up, but this should give you a general idea.

Do not use loops inside your command executes. They are already looped for you each during iteration. Unlike the SimpleRobot template, you cannot loop inside your command executes for a long period of time. Your execute methods need to run as quickly as possible, so any other parallel commands can be run immediately after. If you loop, you will stall the rest of your code, thus losing the ability to run things asynchronously.
__________________
In life, what you give, you keep. What you fail to give, you lose forever...
Reply With Quote