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: Data Logger (basic)

Written by Paul Cracknell

Updated at February 5th, 2021

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 Data Logger (basic)

# pymoku example: Basic Datalogger
# 
# This example demonstrates use of the Datalogger instrument to log time-series
# voltage data to a (Binary or CSV) file.
# 
# (c) 2019 Liquid Instruments Pty. Ltd.
#

from pymoku import Moku, StreamException
from pymoku.instruments import Datalogger
import time

# 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_or_connect(Datalogger)

 # 100 samples per second
 i.set_samplerate(100)

 # Stop an existing log, if any, then start a new one. 10 seconds of both
 # channels to the SD Card (rather than internal storage). Use the Moku's
 # binary file format for better speed and size performance.
 i.stop_data_log()
 i.start_data_log(duration=10, use_sd=True, ch1=True, ch2=True,
 filetype='bin')

 # Track progress percentage of the data logging session
 progress = 0
 while progress < 100:
 # Wait for the logging session to progress by sleeping 0.5sec
 time.sleep(0.5)
 # Get current progress percentage and print it out
 progress = i.progress_data_log()
 print("Progress {}%".format(progress))

 # Upload the log file to the local directory
 i.upload_data_log()
 print("Uploaded log file to local directory.")

 # Denote that we are done with the data logging session so resources may be
 # cleand up
 i.stop_data_log()

except StreamException as e:
 print("Error occured: %s" % e)
finally:
 m.close()
moku:lab datalogger logger python pymoku

Was this article helpful?

Yes
No

Related Articles

  • Python: Arbitrary Waveform Generator
  • Using Python to generate arbitrary waveforms while observing the output signal
  • Python Spectrum analyzer 'Max hold' function
  • Moku:Lab - a capacitance meter

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