| optoICC

Loading...
Searching...
No Matches
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()

### Analog input

    import optoICC
    icc4c = optoICC.connect()
    channel = icc4c.Channel_0

Set the unit type

    channel.Analog.SetUnitType_LUT(UnitType.FP)    # FP = focal power (dpt), Current = current (A)

Get Maximum Diopter and Minimum Diopter

    max_diopter = channel.LensCompensation.GetMaxDiopter()
    min_diopter = channel.LensCompensation.GetMinDiopter()

Specify the analog lookup table (linear transition of up to 10 values can be specified)

    channel.Analog.SetVoltages_LUT([0, 10])
    channel.Analog.SetValues_LUT([min_diopter, max_diopter])

Set the input stage system to Analog

    channel.Analog.SetAsInput()

### Save/Load snapshot

Using the Snapshot Manage you can save your current settings to on board memory. Then you can set your saved snapshot as a startup snapshot. After powering the driver off driver will start with specified settings. This feature is for example u useful in case of Analog usage. So no other input is required other than Analog input (voltage).

Obtain number of available snapshots.

    capacity = icc4c.SnapshotManager.GetSnapShotCapacity()

Save snapshot to available index. index has to be smaller than "capacity". First snapshot (index = 0) cannot be saved as it is used for factory settings

    icc4c.SnapshotManager.SaveSnapshot(1)

Save this snapshot as startup snapshot

    icc4c.SnapshotManager.SetDefaultSnapShot(1)

To reset the driver back to factory settings

    icc4c.SnapshotManager.SetDefaultSnapShot(0)