In [1]:
from IPython.html.widgets import interactive, DropdownWidget

from nanopb_helpers import dump_message
from serial import Serial
from serial_device import get_serial_ports
import signal_generator as device


def dump_status():
    print dump_message(proxy.config)
    print ''
    print dump_message(proxy.state)

Select device serial port


In [2]:
serial_port = DropdownWidget(values=list(get_serial_ports()),
                             description='Device serial port:')
serial_port

In [3]:
serial_device = Serial(serial_port.value, baudrate=115200)
proxy = device.Proxy(serial_device)

Dump initial status


In [5]:
dump_status()


          ad5206_ss_pin: 3
            spi_sck_pin: 5
 max_waveform_frequency: 10000
                    pot: [170, 19, 39, 169, 163, 117]
   max_waveform_voltage: 7
              baud_rate: 115200
           spi_mosi_pin: 6
         ltc6903_ss_pin: 2
 min_waveform_frequency: 100
          serial_number: 0
            i2c_address: 0
hf_amplitude_correction: 1.24300003052
         freq_range_pin: 4

frequency: 10000.0
  voltage: 2.04999995232

Reset to default device configuration


In [6]:
proxy.reset_config()
proxy.reset_pots()
proxy.reset_state()
dump_status()


          ad5206_ss_pin: 3
            spi_sck_pin: 5
 max_waveform_frequency: 10000
                    pot: [128, 128, 128, 128, 128, 128]
   max_waveform_voltage: 7
              baud_rate: 115200
           spi_mosi_pin: 6
         ltc6903_ss_pin: 2
 min_waveform_frequency: 100
          serial_number: 0
            i2c_address: 0
hf_amplitude_correction: 1.19
         freq_range_pin: 4

frequency: 1000
  voltage: 0

Adjust overall gain correction


In [7]:
def adjust_gain_potentiometer(value=128):
    proxy.set_pot(3, value)
    
proxy.update_state(voltage=1., frequency=1e3)
interactive(adjust_gain_potentiometer, value=(1, 255))

Adjust high-frequency gain correction


In [8]:
def adjust_hf_amplitude_correction(value=1.19):
    proxy.update_config(hf_amplitude_correction=value)
    proxy.update_state(voltage=1., frequency=10e3)
    

interactive(adjust_hf_amplitude_correction, value=(1.1, 1.3, 0.001))

Test configuration


In [11]:
def test_device(voltage=1, frequency=1e3):
    proxy.update_state(voltage=voltage, frequency=frequency)
    

interactive(test_device,
            voltage=(0, proxy.config.max_waveform_voltage, 0.05),
            frequency=(proxy.config.min_waveform_frequency,
                       proxy.config.max_waveform_frequency, 1))

Save configuration to persistent device memory


In [10]:
proxy.save_config()