Go to Post To think that one can "learn" engineering in 6 weeks while under the strain of building a robot too is proposterous. FIRST isn't about teaching. It's about inspiring. - Collin Fultz [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 09-24-2015, 12:00 AM
AnonymousPencil AnonymousPencil is offline
Registered User
FRC #1660
 
Join Date: Jan 2009
Location: New York
Posts: 5
AnonymousPencil is an unknown quantity at this point
Arduino UNO to CIM Motors via Victor Sp

I have my connections pretty much as it says in the title. I am having issues getting my motors to turn competently. I am using the Servo library and I've been fiddling around with the template program but I cannot seem to get my motor to stop turning in one direction. Theres no while loop,

Servo rightVictor;// create servo object to control a servo
int rightVictorPin = 10; // twelve servo objects can be created on most boards

void setup()
{
rightVictor.attach(rightVictorPin);
pinMode (rightVictorPin, OUTPUT);
analogWrite (rightVictorPin, 192);
}

void loop ()
{


rightVictor.writeMicroseconds(1000);

delay (15);


}

Why wont the motor stop?
Reply With Quote
  #2   Spotlight this post!  
Unread 09-24-2015, 07:26 AM
Unsung FIRST Hero
Al Skierkiewicz Al Skierkiewicz is offline
Broadcast Eng/Chief Robot Inspector
AKA: Big Al WFFA 2005
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1996
Location: Wheeling, IL
Posts: 10,763
Al Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond reputeAl Skierkiewicz has a reputation beyond repute
Re: Arduino UNO to CIM Motors via Victor Sp

Have you calibrated the Victor? It may be offset from a previous calibration. What are the Victor LEDs telling you?
__________________
Good Luck All. Learn something new, everyday!
Al
WB9UVJ
www.wildstang.org
________________________
Storming the Tower since 1996.
Reply With Quote
  #3   Spotlight this post!  
Unread 09-24-2015, 08:32 AM
jalburty jalburty is offline
Joe Alburty
AKA: Joe Alburty
FRC #1763 (Paseo Pirates)
Team Role: Mentor
 
Join Date: Oct 2006
Rookie Year: 2005
Location: Kansas City
Posts: 25
jalburty will become famous soon enoughjalburty will become famous soon enough
Send a message via ICQ to jalburty
Re: Arduino UNO to CIM Motors via Victor Sp

What language is it you're using?
It appears you just need to send a value of 0 to the output pin. In C++ the speed range is -127 to 127, with 0 being stop.
Reply With Quote
  #4   Spotlight this post!  
Unread 09-24-2015, 08:44 AM
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 429
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: Arduino UNO to CIM Motors via Victor Sp

Quote:
Originally Posted by AnonymousPencil View Post
Theres no while loop,
In an arduino sketch, the code in the void loop() section gets called repeatedly forever.
Quote:
Code:
void loop () {
    rightVictor.writeMicroseconds(1000);
    delay (15);
}
Quote:
Why wont the motor stop?
You never told it to.

What your code is doing is repeatedly updating the output PWM signal going out to the motor controller to the same value (1000). It never changes the "speed" you've commanded the motor to travel at. If you wanted the motor to drive for a period of time, then change speed/stop, you need to have that change of event occur within the loop() function.


Something else, you're setting the speed of the motor in the setup function using the AnalogWrite function. AnalogWrite would be used when you're actually trying to approximate an analog voltage. The output frequency is lower than what you need for some motor controllers. Side note: on paper it looks like it should work with the Victor SP.

I'd suggest revising your code to something more like the following. The reason is the values you use to command the motor speed are different depending on which library you use, and the following code examples won't work correctly unless you are using the servo library.
Code:
Servo rightVictor;// create servo object to control a servo 
int rightVictorPin = 10; // twelve servo objects can be created on most boards

void setup() {
  rightVictor.attach(rightVictorPin);  // attaches the servo on pin 10 to the servo object
}

void loop() {
    rightVictor.write(23);  // turn the motor at 75% speed in one direction 
    delay(5000);
    rightVictor.write(90);  // stop the motor
    delay(5000);
}
The above code will loop through the following actions repeatedly:
  • run the motor at ~75% speed in one direction
  • wait for 5 seconds
  • stop the motor from tuning
  • wait for 5 seconds


The above code uses the Servo write() function. It accepts values from 0 to 180. where 0 is full speed in one direction and 180 is full speed in the other direction. Speeds output by the motor controller will be scaled for values between 0 and 180. So a value close to 90 will be off. For this to work perfectly, you may need to calibrate the motor controller for outputs of the above range (0, 180, 90).

Hopefully that helps get you moving in the right direction.
__________________
http://team2168.org

Last edited by otherguy : 09-24-2015 at 08:46 AM. Reason: typo
Reply With Quote
Reply


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 10:49 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