Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   CIM->Victor 884->Arduino not working (http://www.chiefdelphi.com/forums/showthread.php?t=111424)

jamie_1930 16-01-2013 23:25

CIM->Victor 884->Arduino not working
 
I'm trying to control a CIM Motor (Foward, Reverse, Stop, Etc.) with a Victor 884 controlled by an Arduino Uno Microcontroller. So far I've tried a couple different things and well I'm fed up and figured I'd show you guys how everything is hooked up to see if someone see's what I'm doing wrong.

Before you guys respond I want to set a few things: I'm not going to use a Crio I'm not going to use the IFI control system I'm not using a FIRST control system. It doesn't matter if any of this is against FIRST rules I'm not doing this for FIRST. However despite the fact that this is not for FIRST I'm going to ask the questions here because it contains the largest amount of people that could help.


This is how everything was hooked up originally and I've also tried hooking up a mosfet powered by the 5v line of the arduino. And I've also tried putting a 5v regulator powered by the FRC battery and then using the 5v line to power a mosfet to boost the signal to the victor, but everytime the victor just flashes orange (no pwm)

Whippet 16-01-2013 23:32

Re: CIM->Victor 884->Arduino not working
 
Have you tried connecting the grounds between the FRC battery and the Arduino?

Radical Pi 16-01-2013 23:40

Re: CIM->Victor 884->Arduino not working
 
I've never tried this personally, but if I had to hazard a guess it would be that delay takes an unsigned long as an argument, but you're passing a floating-point time. You probably want to use delayMicroseconds(). Also, the WPILib comments say that the Victor prefers 10ms periods.

You might also want to check out the Servo library. It's designed for servos that go to specific angles, but it should work for this case as well. I think you'd want to use writeMicroseconds() for the high pulse, and then just delay for the remainder of the period.

ajlapp 16-01-2013 23:51

Re: CIM->Victor 884->Arduino not working
 
You want to use the Arduino Servo class to generate a PWM signal.

Connect the cable to a PWM pin rather than a DIO and use the functions in the Servo class to drive the Victor.

Alan Anderson 17-01-2013 00:01

Re: CIM->Victor 884->Arduino not working
 
The ground pin on a Victor is at the other end of the PWM input connector from the signal pin. The center pin is not used, but it's typically labeled as the power input. Your picture shows the ground and power connections reversed.

jamie_1930 17-01-2013 00:17

Re: CIM->Victor 884->Arduino not working
 
The pin on the arduino and frc battery are grounded together i forgot to put that in. Also the pwm wires on the victor are correct in real life I forgot to put them in the right order in the drawing. Also the servo library gives the same results

TAHIRisHERE 17-01-2013 03:45

Re: CIM->Victor 884->Arduino not working
 
you will have to use the aruidno servo library to have the arduino generate PWM signals. As seen here, http://playground.arduino.cc/ComponentLib/servo

you would have to attach the black wire(from victor) to any ground pin.
Then the white to an arduino pin with PWM(i think its has a curvy line next to pin number label.)
Then the red wire you have no use for.

so a simple sample:


#include <SoftwareServo.h>

Servo myservo(any name can be put here this example uses myservo); // create servo object to control a servo
// a maximum of eight servo objects can be created

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}

void loop()
{ myservo.write(0) (writing the servo at value of 0 will spin motor full speed coutnerclockwise. and a value of 180 will spin motor to full speed in clockwise direction. and a value of 90 is no spin or stop) }


I will assume you know how to wire the battery to the victor.

the sample code is not perfect there are mistakes. but i hope it helps.

DampRobot 17-01-2013 04:38

Re: CIM->Victor 884->Arduino not working
 
I've done a similar project before, but with Jags instead. I used the PWM generating function onthe Arduino, and I beleive I mapped the desired power value onto a 900 microsecond to 2100 microsecond range (full reverse to full forward).

With the Arduino, I've always found that the premade libraries work far beter than a function you tried to put together yourself. Just a word of advice.

omalleyj 17-01-2013 08:40

Re: CIM->Victor 884->Arduino not working
 
You can use the analogWrite() function for PWM so you don't need the Servo library. (that is not a typo, analog, not digital even though you are on a digital pin)
We are currently using this on our test disc shooter.
I did find that the PWM output is not a perfect match for our Victor (an old one, not an 888). Even after calibrating I found that a value above 253 caused a problem.
We are using a potentiometer as input and map the ADC range of 0-1024 to 183 to 253 (one direction, deadband) works pretty well for our particular Victor. You should probably profile yours to find a good range.
I have not put a scope on the PWM out, but I supect it (the output pulse width) is not perfect for the Victor.

HTH

tr6scott 17-01-2013 13:19

Re: CIM->Victor 884->Arduino not working
 
This is working code, I have two pots, one is set only goes one direction, the other pot goes full rev -> 0 -> full forward. This was hacked together a couple of years ago, and put in an Altoids can, we are using it to prototype again this year.

Code:

#include <Servo.h>
 
Servo myservo;  // create servo object to control a servo
Servo myservo1;  // create servo object to control a servo
 
int potpin = 0;  // pot in is 13 pwm analog pin used to connect the potentiometer
int potpin1 = 1;  // analog pin used to connect the potentiometerint val;    // variable to read the value from the analog pin
int val =0;
int val1=0;
void setup()
{
 myservo.attach(9);  // attaches the servo on pin 9 to the servo object
 myservo1.attach(10);  // attaches the servo on pin 9 to the servo object
}
 
void loop()
{
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023) //
  val1 = analogRead(potpin1);            // reads the value of the potentiometer (value between 0 and 1023)
  val = map(val, 0, 1023, 0, 179);    // scale it to use it with the servo (value between 0 and 180)
  val1 = map(val1, 0, 1023, 90, 179);    // scale it to use it with the servo (value between 0 and 180)
  myservo.write(val);                  // pwm 13 sets the servo position according to the scaled value
  myservo1.write(val1);                  // sets the servo position according to the scaled value
  delay(15);                          // waits for the servo to get there
}


jamie_1930 17-01-2013 13:30

Re: CIM->Victor 884->Arduino not working
 
Quote:

Originally Posted by tr6scott (Post 1217256)
This is working code, I have two pots, one is set only goes one direction, the other pot goes full rev -> 0 -> full forward. This was hacked together a couple of years ago, and put in an Altoids can, we are using it to prototype again this year.

Code:

#include <Servo.h>
 
Servo myservo;  // create servo object to control a servo
Servo myservo1;  // create servo object to control a servo
 
int potpin = 0;  // pot in is 13 pwm analog pin used to connect the potentiometer
int potpin1 = 1;  // analog pin used to connect the potentiometerint val;    // variable to read the value from the analog pin
int val =0;
int val1=0;
void setup()
{
 myservo.attach(9);  // attaches the servo on pin 9 to the servo object
 myservo1.attach(10);  // attaches the servo on pin 9 to the servo object
}
 
void loop()
{
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023) //
  val1 = analogRead(potpin1);            // reads the value of the potentiometer (value between 0 and 1023)
  val = map(val, 0, 1023, 0, 179);    // scale it to use it with the servo (value between 0 and 180)
  val1 = map(val1, 0, 1023, 90, 179);    // scale it to use it with the servo (value between 0 and 180)
  myservo.write(val);                  // pwm 13 sets the servo position according to the scaled value
  myservo1.write(val1);                  // sets the servo position according to the scaled value
  delay(15);                          // waits for the servo to get there
}


Could you show me how you set up this up electrically? In the victor manual it says to use a pwm signal driver if you are not using an ifi controller and I can't really find one on the internet. So I assumed I could boost up the amount of current by using a mosfet. I got that working and then I measured the current over time with an oscilliscope and it's pretty noisy. The voltage is a perfect square wave, but the current starts of at 0A and curves up to around 500mA and does a 10-20mA bounce as it goes up.

Ether 17-01-2013 13:32

Re: CIM->Victor 884->Arduino not working
 
Quote:

Originally Posted by jamie_1930 (Post 1217259)
..500mA

You are pushing 500 ma into the Victor's opto-isolator ??



jamie_1930 17-01-2013 14:37

Re: CIM->Victor 884->Arduino not working
 
Quote:

Originally Posted by Ether (Post 1217261)
You are pushing 500 ma into the Victor's opto-isolator ??



That's what I got on the o scope. I put a 10 ohm resistor in line with the signal wire and took the voltage above and below the resistor then hooked the other channel on the o scope to a constant 0.1v and used the math function to multiply the channels
V=IR
I=V/R
I=Voltage drop across resistor/10 ohms
I=Vresistor*.1

Ether 17-01-2013 15:29

Re: CIM->Victor 884->Arduino not working
 

500 ma seems way too high. You might even have damaged the opto-isolator's emitter.

I've never been able to find a Victor schematic, but the datasheet for the Jag's opto-isolator says it has an absolute maximum continuous current rating of 60 ma for the input.

The cable I am using for my test equipment here delivers about 5.6 ma to the Victor during the pulse, and it works fine.

Can you post a picture of your scope's current waveform?


jamie_1930 17-01-2013 15:44

Re: CIM->Victor 884->Arduino not working
 
Quote:

Originally Posted by Ether (Post 1217348)

500 ma seems way too high. You might even have damaged the opto-isolator's emitter.

I've never been able to find a Victor schematic, but the datasheet for the Jag's opto-isolator says it has an absolute maximum continuous current rating of 60 ma for the input.

The cable I am using for my test equipment here delivers about 5.6 ma to the Victor during the pulse, and it works fine.

Can you post a picture of your scope's current waveform?


I won't be able to get back into the school till later tonight or tomorrow, but I'll get that to you as soon as i can. Next time i'll try putting a larger resistor in line to lower the current down to 50mA and see if that changes anything. I just hope i haven't damaged the victor.

BitTwiddler 17-01-2013 15:47

Re: CIM->Victor 884->Arduino not working
 
Quote:

That's what I got on the o scope. I put a 10 ohm resistor in line with the signal wire and took the voltage above and below the resistor then hooked the other channel on the o scope to a constant 0.1v and used the math function to multiply the channels
Forgive me for asking the obvious question but are both probes set to the same gain (x10, x1)?

ericomoura 17-01-2013 15:59

Re: CIM->Victor 884->Arduino not working
 
Here, this might help you.
http://imageshack.us/photo/my-images/185/victormc4.png/

tr6scott 17-01-2013 16:04

Re: CIM->Victor 884->Arduino not working
 
Quote:

Originally Posted by jamie_1930 (Post 1217259)
Could you show me how you set up this up electrically? In the victor manual it says to use a pwm signal driver if you are not using an ifi controller and I can't really find one on the internet. So I assumed I could boost up the amount of current by using a mosfet. I got that working and then I measured the current over time with an oscilliscope and it's pretty noisy. The voltage is a perfect square wave, but the current starts of at 0A and curves up to around 500mA and does a 10-20mA bounce as it goes up.

I will have to check, but I do not remember doing anything with the circuit. From 50 year old memory, I think I have the white PWM wire going to the arduino output, red to the +5v and black to 0V, and it worked. It isn't pretty but has worked for a couple of years.

I powered it with a Usb cable, we have a utility tote that has an old battery, power cut off, and a plate with 4 auto cigarette lighter sockets for powering cell phone charges at events, and a built in usb charger.

Ether 17-01-2013 16:24

Re: CIM->Victor 884->Arduino not working
 
Quote:

Originally Posted by jamie_1930 (Post 1217359)
Next time i'll try putting a larger resistor in line to lower the current down to 50mA

50 ma is still way too high.

In the Jag's opto-isolator, there's a 150 ohm series resistor. In the DSC, there's a 330 ohm series resistor in the PWM signal output. Total 480 ohms. Do the math. 11 ma should be enough.

I just measured a Vic I have here. With 1.5 VDC applied to the input, the current is 0.00562 amps. Subtract 0.7 volts for the LED (I think?) and use R=V/I = (1.5-0.7)/0.00562 = 142 ohms series resistor. So it seems to be similar to the Jag.




tr6scott 17-01-2013 16:36

Re: CIM->Victor 884->Arduino not working
 
FYI, that Altoids Can ran the old victors, and currently running Jags without issue. I have not tried with Talon, or the new Victor.

dyanoshak 17-01-2013 16:58

Re: CIM->Victor 884->Arduino not working
 
Quote:

Originally Posted by Whippet (Post 1216996)
Have you tried connecting the grounds between the FRC battery and the Arduino?

This is not necessary because of the optocoupler that Ether has mentioned.

Your PWM source just has to be able to turn on the LED in the optocoupler.

For the Jaguar, the Turn On Threshold Current for the optocoupler (H1L1M - Datasheet) is 1.6 mA. I don't know the exact optocoupler used in the Victor, but it should be very similar.

Even though I have never played with an Arduino, I would think that its outputs should be able to source >1.6mA at 5V.

I agree that the optocoupler could very well be damaged (pending validation on the 500mA measurement) and possibly the Arduino pin as well if the first attempt was made without a series resistor.

-David

tr6scott 18-01-2013 07:56

Re: CIM->Victor 884->Arduino not working
 
I checked last night, and I do not have have any circuitry between the arduino and the white of the pwm, except for a solder joint to switch it to solid wire to plug into the arduino socket.

I just plugged it in and it worked.




jamie_1930 18-01-2013 13:39

Re: CIM->Victor 884->Arduino not working
 
Ok so here's the update I tryed putting a resistor in line with the signal wire to lower the current, but it still didn't work. So I opened up the victor (which just as an fyi on the pcb says Victor 883 rev F so it's still mainly the same as the victor 883) and found that it had a CNY17F optocoupler inside and based on the data sheet I was pretty sure that I blew it. I then hooked in some alligator clips to test and again I was pretty sure that it was busted. Now we've soldered out the CNY17F and are going to replace it with a PS2501 optocoupler. The pins don't match up exactly so we've snapped of two pins of a 4DIP IC socket and am soldering into where the CNY17F was and we're going to stick the PS2501 into another 4DIP IC Socket and join the two socket by the appropriate pins.

When this is all finished the victor should (fingers crossed) function.

cny17f

BitTwiddler 18-01-2013 17:31

Re: CIM->Victor 884->Arduino not working
 
Quote:

This is how everything was hooked up originally and I've also tried hooking up a mosfet powered by the 5v line of the arduino. And I've also tried putting a 5v regulator powered by the FRC battery and then using the 5v line to power a mosfet to boost the signal to the victor, but everytime the victor just flashes orange (no pwm)
After taking another look at the wiring diagram that was originally posted I think I see a problem concerning the PWM cable wiring. If the diagram is correct, the ground wire from the Arduino board is connected to the +5 V in of the Victor. In PWM, the ground and signal are on the outside wires and the +5V wire is on the inside.
Don't know if this observation is helpful.

**** Please disregard. Mr. Anderson already pointed this out ******

Ether 18-01-2013 17:35

Re: CIM->Victor 884->Arduino not working
 
Quote:

Originally Posted by BitTwiddler (Post 1218136)
If the diagram is correct, the ground wire from the Arduino board is connected to the +5 V in of the Victor. In PWM, the ground and signal are on the outside wires and the +5V wire is on the inside.
Don't know if this observation is helpful.

The center +5 wire is required when using a PWM cable to control a servo (that's how the servo gets its power)

BUT

Only the GND and Signal (outside pins) are required for the PWM input to the motor controllers. The center pin goes nowhere and does nothing.




BitTwiddler 18-01-2013 17:47

Re: CIM->Victor 884->Arduino not working
 
Quote:

Originally Posted by Ether (Post 1218140)
BUT

Only the GND and Signal (outside pins) are required for the PWM input to the motor controllers. The center pin goes nowhere and does nothing.




Ether,
I didn't know that. Thanks.

Ether 18-01-2013 17:51

Re: CIM->Victor 884->Arduino not working
 
1 Attachment(s)
Quote:

Originally Posted by BitTwiddler (Post 1218146)
Ether,
I didn't know that. Thanks.

Excerpt from the Jag schematic attached. Notice the center pin.


All times are GMT -5. The time now is 02:52.

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