MU-Electronics / GasRig

Gas rig control program
0 stars 1 forks source link

impliment labjack functions #4

Closed motters closed 7 years ago

motters commented 7 years ago

qDebug() << "Config IO"; m_command.insert("FIO7", "0"); // 1 = Analgue Input; 0 = Digital IO m_command.insert("FIO6", "1"); // 1 = Analgue Input; 0 = Digital IO m_command.insert("FIO5", "0"); // 1 = Analgue Input; 0 = Digital IO m_command.insert("FIO4", "0"); // 1 = Analgue Input; 0 = Digital IO m_command.insert("EIO7", "0"); // 1 = Analgue Input; 0 = Digital IO m_command.insert("EIO6", "0"); // 1 = Analgue Input; 0 = Digital IO m_command.insert("EIO5", "0"); // 1 = Analgue Input; 0 = Digital IO m_command.insert("EIO4", "0"); // 1 = Analgue Input; 0 = Digital IO m_command.insert("EIO3", "0"); // 1 = Analgue Input; 0 = Digital IO m_command.insert("EIO2", "0"); // 1 = Analgue Input; 0 = Digital IO m_command.insert("EIO1", "0"); // 1 = Analgue Input; 0 = Digital IO m_command.insert("EIO0", "0"); // 1 = Analgue Input; 0 = Digital IO configureIO();

    m_command.clear();
    qDebug() << "";qDebug() << "";

    qDebug() << "Setting FIO7 as input";
    m_command.insert("port", "FIO7");
    m_command.insert("value", "-1");
    setDigitalPort();

    m_command.clear();
    qDebug() << "";qDebug() << "";

    qDebug() << "Setting FIO5 LOW";
    m_command.insert("port", "FIO5");
    m_command.insert("value", "0");
    setDigitalPort();

    m_command.clear();
    qDebug() << "";qDebug() << "";

    qDebug() << "Reading FIO7";
    m_command.insert("port", "FIO7");
    readDigitalPort();

    m_command.clear();
    qDebug() << "";qDebug() << "";

    qDebug() << "Setting FIO5 HIGH";
    m_command.insert("port", "FIO5");
    m_command.insert("value", "1");
    setDigitalPort();

    m_command.clear();
    qDebug() << "";qDebug() << "";

    qDebug() << "Reading FIO7";
    m_command.insert("port", "FIO7");
    readDigitalPort();

    m_command.clear();
    qDebug() << "";qDebug() << "";

    qDebug() << "Writing a analogue voltage";
    m_command.insert("port", "DAC1");
    m_command.insert("value", "20020"); //65535
    setAnaloguePort();

    m_command.clear();
    qDebug() << "";qDebug() << "";

    qDebug() << "Reading a analogue value";
   m_command.insert("port", "FIO6");
   readAnaloguePort();
motters commented 7 years ago
    // get voltage bits
    double voltage = data.at(9).toInt() + (data.at(10).toInt()*256);

    // Un calibrated voltage
    double voltageUncal = ( voltage / 65536) * 2.44;

    // Find cal voltage
    double slope =  3.7231E-05;
    double offset = 0.0000E+00;
    double voltageCal = ( slope * voltage ) + offset;

    // Compare the voltages
    qDebug() << voltage << "; rought voltage: " << voltageUncal << " Accurate voltage: " << voltageCal;
motters commented 7 years ago

Created a command constructer to cover the above and other HALs