Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save futureshocked/e6a487e2d98bcb84d8aef667d8cc6f86 to your computer and use it in GitHub Desktop.
Save futureshocked/e6a487e2d98bcb84d8aef667d8cc6f86 to your computer and use it in GitHub Desktop.
This script shows how to control an LED with FIO5 with a Lua script.
--[[
LJ - 09.70 - voltage_follower_verbose.lua
This script shows how to control an LED with FIO5 with a Lua script.
Components
----------
- LabJack T4
- Voltmeter/Multimeter
- Multimeter red probe to DAC0
- Multimeter black probe to GND
- Potentiometer
- Midlle pin to AIN0
- Left pin to VS
- Right pin to GND
- Wires
- Breadboard
Course
------
Data acquisition and automation with LabJack
https://app.techexplorations.com/courses/labjack/
--]]
print("Read AIN0 input voltage and set DAC0 output voltage. Update at 10Hz")
local InputVoltage = 0
LJ.IntervalConfig(0, 100) --set interval to 100 for 100ms
local checkInterval=LJ.CheckInterval
local mbRead = MB.R --local functions for faster processing
local mbWrite = MB.W
while true do
if LJ.CheckInterval(0) then --interval completed
InputVoltage = mbRead(0, 3) --read AIN0. Address is 0, type is 3
print("AIN0: ", InputVoltage, "V")
mbWrite(1000, 3, InputVoltage)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment