potentiostat-mcp4725

antoniorrg/program-potentiostat/potentiostat-mcp4725

No description
potentiostat-mcp4725
@/potentiostat-mcp4725
IN@/potentiostat-mcp4725-device
PORTport
Set the port where the current measurements will be taken.
Vmaxnumber
Set the maximum voltage (in Volts) for the cyclic voltammetry experiment, up to a maximum of 5 V.
Vlownumber
Set the minimum voltage (in Volts) for the cyclic voltammetry experiment, up to a minimum of 0 V.
NCyclesnumber
Indicate the number of Cycles that the program will run
Ratenumber
Indicate the rate at which the experiment will be performed (in mV/s).
UPDpulse
potentiostat-mcp4725
IN
PORT
Vmax
Vlow
NCycles
Rate
UPD
Current
Currentnumber
To use the node in your project you should have the antoniorrg/program-potentiostat library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_UPD


node {
    // Internal state variables defined at this level persists across evaluations
    Number foo;
    uint8_t bar = 5;

    void evaluate(Context ctx) {
        bar += 42;

        if (isSettingUp()) {
            // This run once
            foo = (Number)(bar + 1);
        }


        int x;
        uint16_t counter;

        
        
        static_assert(isValidAnalogPort(constant_input_PORT), "must be a valid analog port");

        if (!isInputDirty<input_UPD>(ctx))
        return;
        Number y;
        ::pinMode(constant_input_PORT, INPUT);

    int rate2;
    float rate;
    float Vmax;
    float Vlow;
    int cycle;
    int NCycles;

    auto dac = getValue<input_IN>(ctx);
    NCycles = getValue<input_NCycles>(ctx);
    rate = getValue<input_Rate>(ctx);
    Vlow = getValue<input_Vlow>(ctx);
    Vmax = getValue<input_Vmax>(ctx);
        
    rate2 = (rate/1.22) * 1000;
    Vlow = Vlow/0.00122;
    Vmax = Vmax/0.00122;
    
    
        
    for (cycle=0; cycle<NCycles; cycle++){
       
    for (counter = Vlow; counter < Vmax; counter++)
    {
    
    dac->setVoltage(counter, false);

    x = analogRead(constant_input_PORT);
    emitValue<output_Current>(ctx, x);
    delay (rate2);
    }
   
    for (counter = Vmax; counter > Vlow; counter--)
    {
    
   dac->setVoltage(counter, false);
        
    x = analogRead(constant_input_PORT);
    emitValue<output_Current>(ctx, x);
    delay (rate2);
    
    }

    }


    }
}