Go to Post So basically, the advantage of #35 is that it allows you to be sloppier in your design and fabrication. If you pay close attention to these details, you will never have a problem with #25 chain. - Jim Zondag [more]
Home
Go Back   Chief Delphi > Technical > Electrical
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
  #7   Spotlight this post!  
Unread 13-03-2013, 20:14
thinker&planner thinker&planner is offline
Registered User
AKA: CAAAAAD
no team
Team Role: Mechanical
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Tallahassee, FL
Posts: 115
thinker&planner is a splendid one to beholdthinker&planner is a splendid one to beholdthinker&planner is a splendid one to beholdthinker&planner is a splendid one to beholdthinker&planner is a splendid one to beholdthinker&planner is a splendid one to beholdthinker&planner is a splendid one to behold
Thumbs up Re: arduino victor 884 and a cim

I recently had to do a bunch or research on this topic, so here's my code. I read joysticks as pots through analog pins, so it might be a little different. I would love to know how you end up getting raw pot data from attack 3 because I looked for a bit but couldn't find out how.
Also, I set this up as tank drive with two joysticks. The important part is treating the Victor as a "servo" because it uses "RC" PWM frequencies, which are not at all the same as Arduino's analogWrite function.

#include <Servo.h>

Servo LeftMotor; //not really a servo!
Servo RightMotor; //not really a servo!



int JoyLY = A0; //value of Y axis on left joystick
int JoyRY= A1; //value of Y asis on RIght joystick

int LYval = 90; // variable to store the read LYvalue
int RYval = 90; // variable to store the read RYvalue


void setup() {
LeftMotor.attach(9);
RightMotor.attach(10);
}



void loop() {

LYval = analogRead(JoyLY); // read the left Y input
LYval = map(LYval, 0, 1023, 0, 180); //converts to "degrees"
RYval = analogRead(JoyRY); // read the right Y input
RYval = map(RYval, 0, 1023, 180, 0); //This statement is switched because one of the joysticks was inverted. (Just so you know how to invert it)

if(LYval < 87 || LYval > 93) { //Deadband
left();
}
else{
LeftMotor.write(90);
}

if(RYval < 87 || RYval > 93) { //Deadband
right();
}
else{
RightMotor.write(90);
}

}


void left() {
LeftMotor.write(LYval); // analogRead values go from 0 to 1023 (Only using 512-1023), analogWrite values from 0 to 255
}

void right() {
RightMotor.write(RYval);
}


EDIT:
So that you know, the Victor will treat a "servo angle" from 91-180 as forward speeds and values from 89-0 as reverse speeds.

Last edited by thinker&planner : 13-03-2013 at 20:17.
 


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 06:15.

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