require "ad4" adh = ad4.open("usb-ad") if adh == -1 then print("Error") else print("USB-AD opened.") end sd = {rate = 0.01, posthist = 500} ch1 = {cha = 3} ch2 = {cha = 4} ch3 = {cha = 5} ch4 = {cha = 6} print("USB-AD start scan ... ") ret, scan_result, data = ad4.scan(adh, sd, ch1, ch2, ch3, ch4) print("USB-AD scan done. ret="..ret.. " scan_result="..scan_result) file = assert(io.open("bsp4.csv", "w")) for i=1,table.maxn(data[1]) do local s = string.format("%i", i) for j=1,#data do s = s .. string.format("\t%8.3f", data[j][i]) end file:write(s.."\n") end file:close() ret = ad4.close(adh) if ret == 0 then print("USB-AD closed.") else print("Error") end