Search in sources :

Example 6 with DyIO

use of com.neuronrobotics.sdk.dyio.DyIO in project java-bowler by NeuronRobotics.

the class PWMTest method main.

/**
 * @param args
 */
public static void main(String[] args) {
    DyIO dyio = new DyIO();
    if (!ConnectionDialog.getBowlerDevice(dyio)) {
        System.exit(1);
    }
    PWMOutputChannel pwm = new PWMOutputChannel(dyio.getChannel(4));
    // Loop 10 times setting the pwm output
    float time = 5;
    for (int i = 0; i < 10; i++) {
        System.out.println("Moving.");
        // Set the duty cycle to either 100% or 50%
        int pos = ((i % 2 == 0) ? 100 : 50);
        pwm.setValue(pos);
        // pause between cycles so that the changes are visible
        try {
            Thread.sleep((long) (time * 1000));
        } catch (InterruptedException e) {
        }
    }
    dyio.disconnect();
    System.exit(0);
}
Also used : DyIO(com.neuronrobotics.sdk.dyio.DyIO) PWMOutputChannel(com.neuronrobotics.sdk.dyio.peripherals.PWMOutputChannel)

Example 7 with DyIO

use of com.neuronrobotics.sdk.dyio.DyIO in project java-bowler by NeuronRobotics.

the class SPITest method main.

public static void main(String[] args) throws InterruptedException {
    DyIO dyio = new DyIO();
    if (!ConnectionDialog.getBowlerDevice(dyio)) {
        System.exit(0);
    }
    // Instantiate the SPI
    SPIChannel spi = new SPIChannel(dyio);
    ByteList dataStream = new ByteList(new byte[] { 33, 55, 66, 77, 88, 99 });
    int slaveSelectChannelNumber = 3;
    // Send data to the SPI channel using the given DYIO channel as the slave select.
    byte[] back = spi.write(slaveSelectChannelNumber, dataStream.getBytes());
    // Cleanup and exit
    dyio.disconnect();
    System.exit(0);
}
Also used : ByteList(com.neuronrobotics.sdk.common.ByteList) DyIO(com.neuronrobotics.sdk.dyio.DyIO) SPIChannel(com.neuronrobotics.sdk.dyio.peripherals.SPIChannel)

Example 8 with DyIO

use of com.neuronrobotics.sdk.dyio.DyIO in project java-bowler by NeuronRobotics.

the class BluetoothConector method main.

/**
 * @param args
 */
public static void main(String[] args) {
    DyIO dyio;
    BlueCoveManager manager = new BlueCoveManager();
    String[] devices = manager.getAvailableSerialDevices(true);
    System.out.println("Devices: ");
    for (String d : devices) {
        System.out.println(d);
    }
    if (devices.length > 0) {
        System.out.println("Connecting to : " + devices[0]);
        dyio = new DyIO(new BluetoothSerialConnection(manager, devices[0]));
        dyio.connect();
        if (dyio.ping())
            System.out.println("All OK!");
    }
    System.exit(0);
}
Also used : BluetoothSerialConnection(com.neuronrobotics.sdk.wireless.bluetooth.BluetoothSerialConnection) BlueCoveManager(com.neuronrobotics.sdk.wireless.bluetooth.BlueCoveManager) DyIO(com.neuronrobotics.sdk.dyio.DyIO)

Example 9 with DyIO

use of com.neuronrobotics.sdk.dyio.DyIO in project java-bowler by NeuronRobotics.

the class AnalogInputTest method main.

/**
 * @param args
 */
public static void main(String[] args) {
    DyIO.disableFWCheck();
    Log.enableDebugPrint();
    DyIO dyio = new DyIO();
    if (!ConnectionDialog.getBowlerDevice(dyio)) {
        System.exit(1);
    }
    AnalogInputChannel ana = new AnalogInputChannel(dyio, 15);
    ana.setAsync(false);
    // Loop forever printing out the voltage on the pin
    ServoChannel servo = new ServoChannel(dyio, 1);
    servo.SetPosition(128);
    while (true) {
        // System.out.println(ana.getValue());
        int currentVoltageValue = ana.getValue();
        int scaledVoltageValue = currentVoltageValue / 4;
        servo.SetPosition(scaledVoltageValue);
    }
}
Also used : ServoChannel(com.neuronrobotics.sdk.dyio.peripherals.ServoChannel) AnalogInputChannel(com.neuronrobotics.sdk.dyio.peripherals.AnalogInputChannel) DyIO(com.neuronrobotics.sdk.dyio.DyIO)

Example 10 with DyIO

use of com.neuronrobotics.sdk.dyio.DyIO in project java-bowler by NeuronRobotics.

the class CoordinatedMotion method main.

public static void main(String[] args) throws InterruptedException {
    DyIO dyio = new DyIO();
    if (!ConnectionDialog.getBowlerDevice(dyio)) {
        System.exit(1);
    }
    dyio.connect();
    int[] vals = dyio.getAllChannelValues();
    // Set up the array of channels
    ArrayList<ServoChannel> chans = new ArrayList<ServoChannel>();
    Log.enableDebugPrint();
    float time = 5;
    for (int i = 0; i < 12; i++) {
        chans.add(new ServoChannel(dyio.getChannel(i)));
    }
    // Set the DyIO into cached mode
    dyio.setCachedMode(true);
    int pos = 50;
    for (int i = 0; i < 5; i++) {
        pos = (pos == 50) ? 200 : 50;
        for (ServoChannel s : chans) {
            // Store the cached value
            s.getChannel().setCachedValue(pos);
        }
        // Flush all values to the DyIO
        dyio.flushCache(time);
        Thread.sleep((long) (time * 1500));
    }
    System.exit(0);
}
Also used : ServoChannel(com.neuronrobotics.sdk.dyio.peripherals.ServoChannel) ArrayList(java.util.ArrayList) DyIO(com.neuronrobotics.sdk.dyio.DyIO)

Aggregations

DyIO (com.neuronrobotics.sdk.dyio.DyIO)25 ServoChannel (com.neuronrobotics.sdk.dyio.peripherals.ServoChannel)5 AnalogInputChannel (com.neuronrobotics.sdk.dyio.peripherals.AnalogInputChannel)3 CounterOutputChannel (com.neuronrobotics.sdk.dyio.peripherals.CounterOutputChannel)3 DigitalInputChannel (com.neuronrobotics.sdk.dyio.peripherals.DigitalInputChannel)3 ByteList (com.neuronrobotics.sdk.common.ByteList)2 DyIOChannelMode (com.neuronrobotics.sdk.dyio.DyIOChannelMode)2 BowlerBoardDevice (com.neuronrobotics.replicator.driver.BowlerBoardDevice)1 NRPrinter (com.neuronrobotics.replicator.driver.NRPrinter)1 DHParameterKinematics (com.neuronrobotics.sdk.addons.kinematics.DHParameterKinematics)1 LinkConfiguration (com.neuronrobotics.sdk.addons.kinematics.LinkConfiguration)1 ServoRotoryLink (com.neuronrobotics.sdk.addons.kinematics.ServoRotoryLink)1 NRBootLoader (com.neuronrobotics.sdk.bootloader.NRBootLoader)1 BowlerCamDevice (com.neuronrobotics.sdk.bowlercam.device.BowlerCamDevice)1 BowlerAbstractConnection (com.neuronrobotics.sdk.common.BowlerAbstractConnection)1 DyPIDConfiguration (com.neuronrobotics.sdk.dyio.dypid.DyPIDConfiguration)1 CounterInputChannel (com.neuronrobotics.sdk.dyio.peripherals.CounterInputChannel)1 DCMotorOutputChannel (com.neuronrobotics.sdk.dyio.peripherals.DCMotorOutputChannel)1 DigitalOutputChannel (com.neuronrobotics.sdk.dyio.peripherals.DigitalOutputChannel)1 PWMOutputChannel (com.neuronrobotics.sdk.dyio.peripherals.PWMOutputChannel)1