| optoICC

ICC-4c Advanced Examples

Download a saved vector from the board.

    import optoICC
    icc4c = optoICC.connect()

    start_address, num_elements = 0, 1024
    vector = icc4c.VectorPatternMemory.GetPatternSegment(start_address, num_elements)

Set a DC output.

    import optoICC
    icc4c = optoICC.connect()

    # pick some value for current
    amplitude_A = 0.250

    static = icc4c.Channel_0.StaticInput
    static.SetAsInput()
    static.SetCurrent(amplitude_A)

Output an impulse on one channel.

    import optoICC
    icc4c = optoICC.connect()

    # pick a channel, amplitude, and impulse duration
    channel = 1
    amplitude_A = 0.07
    duration_ms = 1.0

    sig_gen = icc4c.channel[channel].SignalGenerator
    sig_gen.SetAsInput()
    sig_gen.SetShape(optoICC.WaveformShape.PULSE)
    sig_gen.SetFrequency(1 / (2 * duration_ms / 1000))  # /1000 to convert to seconds
    sig_gen.SetAmplitude(amplitude_A)
    sig_gen.SetDutyCycle(0.5)
    sig_gen.SetCycles(1)
    sig_gen.SetUnit(optoICC.UnitType.CURRENT)
    sig_gen.Run()

Upload a trapezoidal vector to the board.

    import numpy as np
    import optoICC

    icc4c = optoICC.connect()

    # The hard part... building a vector.
    # ----------------------------------
    # pick a frequency, trans time, amplitude, and phase
    frequency_Hz = 50
    time_transition_ms = 2
    amplitude_A = 0.1
    phase_deg = 0.0
    # calculate number of samples
    period = 1 / frequency_Hz
    num_samples = period * optoICC.SAMPLING_FREQ
    # we want an even number of samples per period, so it can be divided in two halves
    num_samples = round(num_samples / 2.0) * 2
    half_num_samples = num_samples // 2
    # samples in transition and holding time
    nsamples_tr = round(time_transition_ms / 1000 * optoICC.SAMPLING_FREQ)
    nsamples_hold = half_num_samples - nsamples_tr
    # linspace takes both start and stop points, we need to discard the stop point and add one more sample point,
    # so we use nsamples+1 and discard the last element of the vector [:-1]
    vector = list(np.linspace(start=-amplitude_A, stop=amplitude_A, num=nsamples_tr + 1)[:-1]) \
             + [amplitude_A] * nsamples_hold \
             + list(np.linspace(start=amplitude_A, stop=-amplitude_A, num=nsamples_tr + 1)[:-1]) \
             + [-amplitude_A] * nsamples_hold
    break_idx = round(phase_deg / 360.0 * len(vector))
    vector = vector[break_idx:] + vector[:break_idx]

    # now the easy part, send vector to the board!
    # ----------------------------------
    icc4c.VectorPatternMemory.SetPattern(index=0, vector=vector)

Run a saved vector on one axis/channel.

    vpu = icc4c.Channel_0.VectorPatternUnit
    vpu.SetAsInput()
    vpu.SetStart(0)
    vpu.SetEnd(len(vector) - 1)
    vpu.SetFreqSampleSpeed(optoICC.SAMPLING_FREQ)
    vpu.SetUnit(optoICC.UnitType.CURRENT)
    vpu.Run()