Quote:
Originally Posted by yash101
Ah. I get it. However, that seems a little complicated because you will need to craft the code to emulate DI/O. I'm just wondering but has anyone succeeded in using the analog communications with the Jags?
|
The code? Easy- Replace the 2 with any voltage you need.
Code:
package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.AnalogChannel;
public class AnalogAsDigital {
AnalogChannel analogInput;
public AnalogAsDigital(int channel){
analogInput = new AnalogChannel(channel);
}
public double getAnalog(){
return analogInput.getVoltage();
}
public boolean getDigital(){
return analogInput.getVoltage() < 2;
}
}
As for the analog on the jaguar, you can use a gyro/other analog sensor if the output is 0 to 3 V, or any type of potentiometer or variable resistor.
From the datasheet
Quote:
Analog Input
The analog input accepts a 0-3 V sensor signal for implementing position control mode. Position control can
also be implemented with a single- or multi-turn potentiometer. Potentiometers with continuous rotation are not
supported. The Jaguar contains a built-in bias pin for use with 10kΩ potentiometers. If another potentiometer
value or analog source is used, it must have a 0-3 V range.
If the P, I, and D parameters are positive (or zero), the Jaguar expects that a forward condition (+ voltage on
White terminal, - voltage on Green) will generate an increasing voltage on the analog input.
If the P, I, and D parameters are positive (or zero), the Jaguar expects that a forward condition (+ voltage on
White terminal, - voltage on Green) will generate a decreasing voltage on the analog input.
The analog input is not electrically isolated.
Table 5 on page 6 lists the electrical requirements of an external control signal.
|