Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Knowledge Base Home
  • Contact Us
  • Home
  • Moku:Lab
  • Software integrations
  • Python examples

Python: PID controller

Written by Paul Cracknell

Updated at December 22nd, 2020

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Moku:Go
    Moku:Go Arbitrary Waveform Generator Moku:Go Data Logger Moku:Go Frequency Response Analyzer Moku:Go Logic Analyzer & Pattern Generator Moku:Go Oscilloscope & Voltmeter Moku:Go PID Controller Moku:Go Spectrum Analyzer Moku:Go Waveform Generator Moku:Go Power Supplies Moku:Go Digital Filter Box Moku:Go FIR Filter Builder Moku:Go Lock-in Amplifier
  • Moku:Lab
    Windows Moku:Lab general Moku:Lab Instruments iPad app Software integrations
  • Moku:Pro
    Moku:Pro Instruments
+ More

Example Python script to implement the PID controller

# pymoku example: Basic PID Controller
#
# This script demonstrates how to configure one of the two PID Controllers
# in the PID Controller instrument. Configuration is done by specifying
# frequency response characteristics of the controller.
#
# (c) 2019 Liquid Instruments Pty. Ltd.
#

from pymoku import Moku
from pymoku.instruments import PIDController


def from_dB(dB):
 # Helper function that converts from dB to linear scale
 return 10 ** (dB / 20.0)


# Connect to your Moku by its device name
# Alternatively, use Moku.get_by_serial('#####') or Moku('192.168.###.###')
m = Moku.get_by_name("Moku")

try:
 i = m.deploy_instrument(PIDController)

 # Configure the PID Controller using frequency response characteristics
 # P = -10dB
 # I Crossover = 100Hz
 # D Crossover = 10kHz
 # I Saturation = 10dB
 # D Saturation = 10dB
 # Double-I = OFF
 # Note that gains must be converted from dB first
 i.set_by_frequency(1, kp=from_dB(-10), i_xover=1e2, ii_xover=None,
 d_xover=1e4, si=from_dB(10), sd=from_dB(10))
 i.enable_output(1, True)

finally:
 # Close the connection to the Moku:Lab
 m.close()
moku:lab

Was this article helpful?

Yes
No

Related Articles

  • Python: Frequency Response Analyzer (basic)
  • Python: Lock-In Amplifier (plotting)
  • Python: Laser Lock Box
  • Using Python to generate arbitrary waveforms while observing the output signal

Sitemap

  • Moku:Lab
  • Instruments
  • Software
  • Company
  • Support
  • Store
  • Terms & Conditions
  • Privacy Policy

Offices

United States
+1 (619) 332-6230
740 Lomas Santa Fe Dr
Suite 102
Solana Beach, CA 92075

Australia
+61 2 6171 9730
243 Northbourne Avenue
Suite 2
Lyneham, ACT 2602

Follow us

Youtube LinkedIn

官方微信

Contact us
© 2021 Liquid Instruments. All rights reserved.

Definition by Author

0
0
Expand