![]() |
arduino victor 884 and a cim
Hello everyone, my goal here is to find a simplified code to get an arduino to run a spike with a cim
so I have looked around for a couple days and sorry but it all seems to come up null. i have seen a lot about servo libraries and endless lines of code just to turn one motor in either direction, here is the ultimate goal i have in mind: hook directly into the potentiometers on my attack 3, and use it to control the speed and direction of 2 cims for a basic drive train. for now i would settle just to see being able to turn it one direction or the other with the code. So i have the ground wire hooked to ground, the wire on the right hooked to pin 10, I have tried analog and digital but neither give me an easy way to control it. I have the victor itself hooked up to the std. 12v battery through a 40 amp breaker to be safe. I would imagine that the code necessary to turn it either way continuously should be encomppased in less than 6 lines and i think the issue is with the delay, any suggestions? Thanks, Nick |
Re: arduino victor 884 and a cim
http://arduino.cc/en/Reference/ServoAttach
I was able to use this for a project last year. It required some finagling, as I could not just use 0-255 and had to figure out what values corresponded to full reverse, full forward, and off. This was for a very light duty application and didn't involve continuous rotation, so YMMV. |
Re: arduino victor 884 and a cim
I can confirm Cory's suggestion. The PWM signal to control a Victor or a Jag is identical as that used to position a Servo. So, just use that library and convert angle to speed. ie. 0 deg = full reverse, 90 deg = stopped, 180 deg = full forward. The exact values will more than likely be a bit different from this, but they are close enough to get you going.
|
Re: arduino victor 884 and a cim
why am i so incompetent at stuff like this, i just dont see how it all adds up, could you post a few lines of example code? just enough to make it run in 1 direction and i can probably figure it out.
Thanks, Nick |
Re: arduino victor 884 and a cim
Quote:
#include <Servo.h> Servo myservo1; Servo myservo2; void setup() { pinMode(10, OUTPUT); //motor pinMode(11, OUTPUT); //solenoid pinMode(12, INPUT); //Switch 0 pinMode(8,INPUT);//Switch 1 digitalWrite(12, HIGH); // turn on pullup resistor digitalWrite(8,HIGH); //turn on pullup resistor myservo1.attach(10); //motor myservo2.attach(11); //solenoid Serial.begin(9600); } void loop() { int button_0=digitalRead(12); int button_1=digitalRead(8); while ((button_0==0) && (analogRead(A0)!=0)) //while button 0 is pressed and A0 is not equal to 0 { myservo1.write(0); //close door } while ((button_1==0) && (analogRead(A1)!=0)) //while button 1 is pressed and A1 is not equal to 0 { myservo2.write(180); //activate solenoid myservo1.write(112); //open door } myservo1.write(92); //turn off motor myservo2.write(92); //turn off solenoid } |
Re: arduino victor 884 and a cim
pullup resistors and solenoids, I read its best to use servo coding even for a cim, but i just cant say i understand how these relate. Solenoid = victor? what would the pullup resistor do (im reading something about returning it to a state if no input is read, maybe to read that the joystick is let off?)? If this is what works for a victor and cim (i guess it doesnt matter what type of motor right?) then maybe it would be best just to look at your wireing diagram, or if you want i can create one for what i have if you would like.
Thanks, Nick |
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):ahh: 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. |
Re: arduino victor 884 and a cim
Quote:
The pullup resistor part had to do with limit switches. |
Re: arduino victor 884 and a cim
Quote:
The easiest way to describe the signal is a pulse train. The frequency of the pulses is usually around 50Hz. Although, some devices can handle frequencies up to 200Hz. The important part is the width of the pulses. A standard "Hobby PWM" signal has a duration varying from 1ms to 2ms. 1ms corresponds 0 deg. on a servo or full reverse on a motor controller. 1.5ms is 90 deg on a servo and neutral on a motor controller. Lastly, 2ms is 180 deg on the servo and full forward on the motor controller. The varying width of the pulse is where the "Modulation" in PWM comes from. By modulating the pulse width, you control the speed of the motor or position of the servo. These values are fairly generic, the exact values may be slightly different from these. So, as you can see, the motor controller can be run by a "Servo Library" because it is the signal coming out that makes the controller drive the motor at the desired speed and direction, and not the fact that it is a "Servo Library". |
Re: arduino victor 884 and a cim
Quote:
ill be looking through this soon but not tonight, it looks promising though so thank you, i was scared people werent understanding my goals. to answer your question, i took apart the attack 3, where the usb comes into the housing there is a red and a black wire, and a few more but dont worry about those, so i ran the red to the 5v supply on the arduino and the black to the ground. then on the right side of the stick there is a 5 pin connector. Red, yellow, green, orange, and blue. The red and blue are power, the yellow and green give direct analog output though, so does the orange but that is for the throttle control on the back of the joystick. So since I gave the entire joystick power through the wires on the usb, I can really get all the buttons to work, but I connected wires to the green and yellow wires and was able to get an analog read on the arduino https://photos-5.dropbox.com/t/0/AAD...?size=1280x960 |
Re: arduino victor 884 and a cim
Quote:
|
Re: arduino victor 884 and a cim
1 Attachment(s)
Attachment 14343
that should be better, sorry not a great way of doing things, but in my case i would like to bypass the use of a computer so its neccessary from what i can reason |
Re: arduino victor 884 and a cim
Quote:
|
Re: arduino victor 884 and a cim
Quote:
|
Re: arduino victor 884 and a cim
The original post here requests information on controlling a CIM with a Spike, not a proportional motor controller. If that is still the case, then you do not want to output PWM signals at all. In fact, you do not even want to wire the cable the same way as if it was a PWM output. What you will need is two digital outputs, one connected to each of the two non-ground pins of a three pin PWM cable.
In this case, the fact that a three pin PWM cable is used for the connection to a Spike can be a source of confusion. The signals are not PWM at all. They are just simple logic signals, one for full forward, and one for full reverse. While connecting a spike to PWM signals may make it do something, it will not act properly. It will most likely either run all the time fully on in one direction only, or run in a jerky maner. A spike simply is not designed to operate with PWM signals If you are in fact still trying to make the Arduino control a Spike relay and not a Jaguar, Talon, or Victor motor controller than do not use the servo library at all. Just connect TWO digital outputs pins rather than one and send them simple high and low output commands. On the spike, the center pin that would be power, if the cable was going to a servo, is actually the other control pin. Change the wiring and use digital output commands and you should have better luck controlling a Spike. Tom |
| All times are GMT -5. The time now is 20:14. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi