Malheureusement c'est encore lent, seulement 1.6mS entre deux mesures
This commit is contained in:
@@ -1,33 +1,31 @@
|
|||||||
-- Lit le le petit convertisseur ADC ADS1115
|
-- Lit le le petit convertisseur ADC ADS1115
|
||||||
|
|
||||||
|
-- Malheureusement cette méthode est très lente,
|
||||||
|
-- on ne peut pas lire plus vite que 1.6mS !
|
||||||
|
-- et encore sur le même canal
|
||||||
|
|
||||||
function readADS1115()
|
function readADS1115()
|
||||||
if verbose then print("\n 0_ads1115.lua zf200126.1741 \n") end
|
if verbose then print("\n 0_ads1115.lua zf200126.1803 \n") end
|
||||||
|
|
||||||
id = 0 sda = 5 scl = 6 addr = 0x48
|
id = 0 sda = 5 scl = 6 addr = 0x48
|
||||||
|
|
||||||
i2c.setup(id, sda, scl, i2c.SLOW) sda = nil scl = nil
|
i2c.setup(id, sda, scl, i2c.FAST) sda = nil scl = nil
|
||||||
ads1115.reset()
|
ads1115.reset()
|
||||||
adc0 = ads1115.ads1115(id, addr)
|
adc = ads1115.ads1115(id, addr)
|
||||||
adc1 = ads1115.ads1115(id, addr)
|
|
||||||
adc2 = ads1115.ads1115(id, addr)
|
|
||||||
adc3 = ads1115.ads1115(id, addr)
|
|
||||||
|
|
||||||
adc0:setting(ads1115.GAIN_6_144V, ads1115.DR_128SPS, ads1115.SINGLE_0, ads1115.CONTINUOUS)
|
t1=tmr.now()
|
||||||
adc1:setting(ads1115.GAIN_6_144V, ads1115.DR_128SPS, ads1115.SINGLE_1, ads1115.CONTINUOUS)
|
adc:setting(ads1115.GAIN_6_144V, ads1115.DR_860SPS, ads1115.SINGLE_0, ads1115.CONTINUOUS)
|
||||||
adc2:setting(ads1115.GAIN_6_144V, ads1115.DR_128SPS, ads1115.SINGLE_2, ads1115.CONTINUOUS)
|
t2=tmr.now()
|
||||||
adc3:setting(ads1115.GAIN_6_144V, ads1115.DR_128SPS, ads1115.SINGLE_3, ads1115.CONTINUOUS)
|
print("setup, t2-t1: ",(t2-t1)/1000)
|
||||||
|
|
||||||
tmr.delay(10*1000)
|
tmr.delay(10*1000)
|
||||||
|
|
||||||
function read_ADS1115()
|
function read_ADS1115()
|
||||||
t1=tmr.now()
|
t1=tmr.now()
|
||||||
volt0 = adc0:read()
|
volt = adc:read()
|
||||||
volt1 = adc1:read()
|
|
||||||
volt2 = adc2:read()
|
|
||||||
volt3 = adc3:read()
|
|
||||||
t2=tmr.now()
|
t2=tmr.now()
|
||||||
print("read, t2-t1: ",(t2-t1)/1000)
|
print("read, t2-t1: ",(t2-t1)/1000)
|
||||||
print(volt0, volt1, volt2, volt3)
|
print(volt)
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
@@ -41,6 +39,7 @@ if verbose then print("ADC0: "..read_ADS1115(0).." V") end
|
|||||||
if verbose then print(node.heap()) end
|
if verbose then print(node.heap()) end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
verbose=true
|
||||||
readADS1115()
|
readADS1115()
|
||||||
read_ADS1115()
|
read_ADS1115()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user