3V3 digital signal to the cRIO

The code? Easy- Replace the 2 with any voltage you need.


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

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.

I guess I want to take a step back and ask the intent.

Are you simulating digital input to test programing on the cRio, or are you using it to pass information the Pi has already determined to the cRio to take action?

I ask because if you are looking to pass information it may be much easier to use i2c if you don’t want to use hub points on the radio, or just pass the data between the two on an ethernet connection (UDP or TCP).

But if you are looking to simulate other sensor data then the other discussions here definitely apply. I would look at the logic level shifters from spark fun. That would be the safe way to do it.

Network isn’t the best approach when you want to get the newest data with the least delay. Also, if you are processing a sensor a thousand times a second, offboard, you want a very fast and reliable connection. While ethernet can get close, it isn’t exactly the “best” way to go!

It is also relatively easy to code i2C on the Pi compared to another technology because of the libraries out there and the documentation that they have!