| optoICC

Loading...
Searching...
No Matches
ECC-1c Examples

Examples for controlling ECC-1c driver using optoICC python library.

## Initialization

    import optoICC
    ecc1c = optoICC.connectEcc() or optoICC.connectEcc(port='COMX')

Define the system you want to interact with

    sig_gen = ecc1c.Lens.SignalGenerator

Start setting values

    sig_gen.SetAmplitude(0.1)

## Setting Up A Channel (Quick-Start Guide - DC output):

Each Channel has a Manager for handling signal flow. This happens mostly behind-the-scenes, However, it is important to keep in mind the following procedure.

### (1) Set Input Stage > (2) Set Input Conditioning > (3) Set Control Mode > (4) Set Output Limiting

For example, to output a static value on Channel_0 in open-loop (current) mode...

    import optoICC
    ecc1c = optoICC.connectEcc()
    lens = ecc1c.Lens

    lens.StaticInput.SetAsInput()                        # (1) here we tell the Manager that we will use a static input
    lens.InputConditioning.SetGain(1.0)                  # (2) here we tell the Manager some input conditioning parameters
    lens.LinearOutput.SetCurrentLimit(0.7)               # (4) here we tell the Manager to limit the current to 700mA (default)

    lens.Manager.CheckSignalFlow()                       # This is a useful method to make sure the signal flow is configured correctly.

The channel is configured. The output of the Static system will now proceed through the signal flow mentioned above.

Therefore, next we will configure the output of the Static System.

    si_0 = lens.StaticInput

    si_0.SetCurrent(0.075)                              # here we set a static output of 75mA.

## Setting Up A Channel (Quick-Start Guide - Sinusoid):

To output a sinusoid in current mode...

    import optoICC
    ecc1c = optoICC.connectEcc()
    lens = ecc1c.Lens

    lens.SignalGenerator.SetAsInput()                    # (1) here we tell the Manager that the sig gen is the desired input
    lens.InputConditioning.SetGain(1.0)                  # (2) here we tell the Manager some input conditioning parameters

The channel is configured. The output of the Signal Generator will now proceed through the signal flow mentioned above.

Therefore, next we will configure the output of the Signal Generator.

    sg_0 = lens.SignalGenerator

    sg_0.SetShape(optoICC.Waveforms.SINUSOIDAL)         # here we set the sig gen output waveform type
    sg_0.SetFrequency(10.0)                             # here we set the frequency in Hz
    sg_0.SetAmplitude(0.100)                            # here we set the amplitude in Amps
    sg_0.Run()                                          # done.

## Setting Up A Channel (Quick-Start Guide - Analog)

    import optoICC
    ecc1c = optoICC.connectEcc()
    lens = ecc1c.Lens

Set the unit type

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

Get Maximum Diopter and Minimum Diopter

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

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

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

Set the input stage system to Analog

    lens.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 = ecc1c.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

    ecc1c.SnapshotManager.SaveSnapshot(1)

Save this snapshot as startup snapshot

    ecc1c.SnapshotManager.SetDefaultSnapShot(1)

To reset the driver back to factory settings

    ecc1c.SnapshotManager.SetDefaultSnapShot(0)

### Check out the link below for an overview of the Board-level utility commands

Utility Commands

### Setting Registers Directly

Additional operations are available directly through the Board object (get/set multiple, reset, etc)
For example, multiple set/get can be done (up to 8 at once).
After the following commands, the Signal Generator system will output a sinusoid on channel 0 (You must still configure the Manager!)

    import optoICC
    ecc1c = optoICC.connectEcc()

    mngr = ecc1c.Lens.Manager
    sig_gen = ecc1c.Lens.SignalGenerator

    systems = [mngr.input,     mngr.control,   sig_gen.shape,                sig_gen.frequency, sig_gen.amplitude, sig_gen.unit,          sig_gen.run]
    values  = [sig_gen.sys_id, sig_gen.sys_id, optoICC.Waveforms.SINUSOIDAL, 10.0,              0.1,               optoICC.Units.CURRENT, True       ]

    ecc1c.set_value(systems, values)
    ecc1c.get_value(systems)

Note: You can find which registers a system has by calling `get_register_names`

    >>> sig_gen.get_register_names()
    ['unit', 'run', 'shape', 'frequency', 'amplitude', 'offset', 'phase', 'cycles', 'duty_cycle']