<jupyter_start><jupyter_text>Analog I/OHere's a simple loopback test where we generate 1 V on channel DAC0 and measure it on ADC0:<jupyter_code>labjack.analog.AOut(0, 1)
labjack.analog.AIn(0)<jupyter_output><empty_output><jupyter_text>The LJTick-DAC (TDAC) adapter board can generate voltages from -10 to 10 V. Here's another loopback test where we generate -6 V on TDAC0 and measure it on ADC1:<jupyter_code>labjack.analog.TDAC(0, -6)
labjack.analog.AIn(1)<jupyter_output><empty_output><jupyter_text>Digital I/OHere's a loopback test where we output a series of bits on FIO2 and read them on FIO3:<jupyter_code>write_bits = [0, 1, 1, 0, 1]
read_bits = []

for bit in write_bits:
    labjack.digital.DOut(2, bit)
    read_bits.append(labjack.digital.DIn(3))
    
print(read_bits)<jupyter_output>[1, 1, 1, 1, 1]<jupyter_text>Temperature sensingThe LabJack can be used with type J or K thermocouples to measure temperatures. Here's an example using channels AIN2 and AIN3 for the positive and negative leads of a type J thermocouple:<jupyter_code>labjack.temperature.configure(pos_ch=2, neg_ch=3, kind='J')
labjack.temperature.TIn(2)<jupyter_output><empty_output><jupyter_text>Waveform generationNow we'll demonstrate generation of arbitrary waveforms with the LabJack. Connect DAC1 to an oscilloscope and run the following:<jupyter_code>import numpy as np
f = 5e3                                       # frequency of waveform
t = np.linspace(0, 1/f, 3000)                 # time axis of waveform
# V = 2.5*(1+np.sin(2*np.pi*f*t))               # sine wave
# V = 5*( t > t.max()/2 )                       # square wave
V = 5 * (t / t.max())                         # triangle wave

labjack.waveform.start(t, V, channels = [1])  # start generation<jupyter_output><empty_output><jupyter_text>Pattern generationWe can also use the LabJack as a digital pattern generator. Let's create a timing sequence where FIO3 goes high for 1 ms, low for 500 us, high for 2 ms, then low for 1 ms:<jupyter_code>period=4.5e-3
sequence = {3: [(0, 1),         # start high
                (1e-3, 0),    
                (1.5e-3, 1),
                (3.5e-3, 0)]}

labjack.pattern.start(sequence, period)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10361990950226245, 'fraction_numerical': 0.034389140271493215, 'mean_word_length': 3.5030549898167007, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '416426', 'license': 'MIT', 'n_tokens_mistral': 820, 'n_tokens_neox': 752, 'n_words': 230, 'path': 'Examples.ipynb', 'repo_name': 'robertfasano/labyak', 'size': '2210'}