Created
April 26, 2021 02:21
-
-
Save futureshocked/dcf1a7ab4479141031d0c3d96ebb9af3 to your computer and use it in GitHub Desktop.
This script shows how to write voltage to DAC0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| LJ - 10.40 - LJ - 10.40 - DAC0_write.py | |
| This script shows how to write voltage to DAC0. | |
| Components | |
| ---------- | |
| - LabJack T4 | |
| - Voltmeter/Multimeter | |
| - Multimeter red probe to DAC0 | |
| - Multimeter black probe to GND | |
| Course | |
| ------ | |
| Data acquisition and automation with LabJack | |
| https://app.techexplorations.com/courses/labjack/ | |
| ''' | |
| from labjack import ljm | |
| import time | |
| # Open first found LabJack | |
| handle = ljm.openS("ANY", "ANY", "Peter_T4") | |
| info = ljm.getHandleInfo(handle) | |
| print("Opened a LabJack with Device type: %i, Connection type: %i,\n" | |
| "Serial number: %i, IP address: %s, Port: %i,\nMax bytes per MB: %i" % | |
| (info[0], info[1], info[2], ljm.numberToIP(info[3]), info[4], info[5])) | |
| # Setup and call eWriteAddress to write a value to the LabJack. | |
| address = 1000 # DAC0 | |
| dataType = ljm.constants.FLOAT32 | |
| value = 2.0 # 2.5 V | |
| step = 0.5 | |
| while True: | |
| value = value + step | |
| ljm.eWriteAddress(handle, address, dataType, value) | |
| if value > 4 or value < 0: | |
| step = - step | |
| print("\neWriteAddress: ") | |
| print(" Address - %i, data type - %i, value : %f" % (address, dataType, value)) | |
| time.sleep(3) # Sleep for 3 seconds to allow enough time for the voltage to stabilize | |
| # Close handle | |
| ljm.close(handle) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment