![]() |
optoOIS
|
Download a saved vector from the board.
import optoOIS mre3ois = optoOIS.connect() start_address, num_elements = 0, 1024 vector = mre3ois.VectorPatternMemory.GetPatternSegment(start_address, num_elements)
Set a DC output.
import optoOIS mre3ois = optoOIS.connect() # pick some value for current amplitude_A = 0.250 static = mre3ois.Channel_0.StaticInput static.SetAsInput() static.SetCurrent(amplitude_A)
Output an impulse on one axis/channel.
import optoOIS mre3ois = optoOIS.connect() # pick a channel, amplitude, and impulse duration channel = 1 amplitude_A = 0.07 duration_ms = 1.0 sig_gen = mre3ois.channel[channel].SignalGenerator sig_gen.SetAsInput() sig_gen.SetShape(optoOIS.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(optoOIS.UnitType.CURRENT) sig_gen.Run()
Upload a trapezoidal vector to the board.
import numpy as np
import optoOIS
mre3ois = optoOIS.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 * optoOIS.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 * optoOIS.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!
# ----------------------------------
mre3ois.VectorPatternMemory.SetPattern(index=0, vector=vector)
Run a saved vector on one axis/channel.
import optoOIS mre3ois = optoOIS.connect() vpu = mre3ois.Channel_0.VectorPatternUnit vpu.SetAsInput() vpu.SetStart(0) vpu.SetEnd(len(vector) - 1) vpu.SetFreqSampleSpeed(optoOIS.SAMPLING_FREQ) vpu.SetUnit(optoOIS.UnitType.CURRENT) vpu.Run()