static int NRCstart(uint board)
{
    uint safemode = 0;
    int errcode;

    printf("Neuromorphic Robot Control\n");

    redisContext *c = redisConnect("127.0.0.1", 6379);
    if (c == NULL || c->err) {
        if (c) {
            printf("Error: %s\n", c->errstr);
            // handle error
        } else {
            printf("Can't allocate redis context\n");
        }
    }

    X826( S826_SafeWrenWrite(board, 0) );
    X826( S826_SafeWrenWrite(board, 1) );
    X826( S826_SafeWrenWrite(board, 2) );

    X826( S826_DacRangeWrite(board, 0, S826_DAC_SPAN_5_5, safemode) );  // program dac output range: -10V to +10V
    X826( S826_DacRangeWrite(board, 1, S826_DAC_SPAN_5_5, safemode) );
    X826( S826_DacRangeWrite(board, 2, S826_DAC_SPAN_5_5, safemode) );

    while(1) {
      redisReply *y = redisCommand(c, "GET yaw");
      X826( S826_DacDataWrite(board, 2, strtoul(y->str, 0, 0), safemode) );

      redisReply *p = redisCommand(c, "GET pitch");
      X826( S826_DacDataWrite(board, 0, strtoul(p->str, 0, 0), safemode) );

      redisReply *s = redisCommand(c, "GET slider");
      X826( S826_DacDataWrite(board, 1, strtoul(s->str, 0, 0), safemode) );
    }


    return errcode;
}
Ejemplo n.º 2
0
// Write all outputs to 0 and then close 626 board =========================
int cMotorController::close()
{
#ifdef SENSORAY826
    double Vmax; double Vmin;
    // determine range of DAC
    if (VOLTRANGE == 2)
    {
        Vmax = 5;
        Vmin = -5;
    } else {
        Vmax = 10;
        Vmin = -10;
    }
    uint setPoint = (0.0-Vmin)/(Vmax-Vmin) * MAXSETPNT;
    S826_DacDataWrite(PCI_BOARD, channelNum, setPoint, 0);
    S826_CounterStateWrite(PCI_BOARD, channelNum, 0);
#endif
    return 0;
}
Ejemplo n.º 3
0
void cMotorController::SetOutputTorque(double desiredTorque)
{
    double Vmax; //range of DAC
    double Vmin; //range of DAC

    double VoltOut = 0;
    double MaxVolt = MAX_AMPS*AMPS_TO_VOLTS; //0.96 //we need to limit the max voltage output to a corresponding max amperage;

    double desiredAmps = desiredTorque/KT;
    VoltOut = desiredAmps*AMPS_TO_VOLTS;

    // Check to make sure we're not assigning more than we want
    if (VoltOut > MaxVolt)
    {
        VoltOut = MaxVolt;
    }
    else if (VoltOut < (-MaxVolt))
    {
        VoltOut = -MaxVolt;
    }
    // determine range of DAC
    if (VOLTRANGE == 2)
    {
        Vmax = 5;
        Vmin = -5;
    } else {
        Vmax = 10;
        Vmin = -10;
    }
    uint setPoint = (VoltOut-Vmin)/(Vmax-Vmin) * MAXSETPNT;

#ifdef SENSORAY826
    S826_DacDataWrite(PCI_BOARD, channelNum, setPoint, 0);
#endif

    this->voltageOutput = VoltOut; //Store for GUI

}