File tree Expand file tree Collapse file tree 4 files changed +46
-20
lines changed
Expand file tree Collapse file tree 4 files changed +46
-20
lines changed Original file line number Diff line number Diff line change 1717 raise ImportError (
1818 "Failed to import library from parent folder" )
1919
20+ # INPUT VARIABELEN
21+ samples = 1000
22+ sample_rate = 250
23+ gain = 1
24+ mode = 'single'
25+ filename = 'test'
2026
2127###### configureer de ADC
2228
2329ads = ADS .ADS1015 (i2c )
2430
25- ads .mode = ADS .Mode .CONTINUOUS #snel
26- # ads.mode = ADS.Mode.SINGLE #langzaam
31+ if mode == 'cont' :
32+ ads .mode = ADS .Mode .CONTINUOUS #snel
33+ elif mode == 'single' :
34+ ads .mode = ADS .Mode .SINGLE #langzaam
2735
28- ads .gain = 1
36+ ads .gain = gain
2937print (ads .gains ) # voor alle opties
30- ads .rate = 3300
38+ ads .data_rate = sample_rate
3139print (ads .rates ) # voor alle opties
3240
33- chan = AnalogIn (ads , ADS .P0 ) # pin 0 verbonden
41+ chan = AnalogIn (ads , ADS .P0 , ADS . P1 ) # pin 0 verbonden
3442
3543###### Lees meerdere datapunten
36- data = get_data .readADS (chan )
44+ data = get_data .readADS (chan , samples )
3745
3846# maak een (unieke) filenaam aan
39- filename = 'meting_test1_%s.txt' % (int (time .time ()))
40- write_data .saveArray (data , filename )
47+ file_name = filename + '.txt'
48+ #filename = 'meting_test1_%s.txt' %(int(time.time()))
49+ write_data .saveArray (data , file_name )
Original file line number Diff line number Diff line change 1717 raise ImportError (
1818 "Failed to import library from parent folder" )
1919
20+ # INPUT VARIABELEN
21+ samples = 1000
22+ sample_rate = 250
23+ gain = 1
24+ mode = 'single'
25+ filename = 'test'
2026
2127###### configureer de ADC
2228
2329ads = ADS .ADS1115 (i2c )
2430
25- ads .mode = ADS .Mode .CONTINUOUS #snel
26- # ads.mode = ADS.Mode.SINGLE #langzaam
31+ if mode == 'cont' :
32+ ads .mode = ADS .Mode .CONTINUOUS #snel
33+ elif mode == 'single' :
34+ ads .mode = ADS .Mode .SINGLE #langzaam
2735
28- ads .gain = 1
36+ ###### configureer de ADC
37+
38+ ads .gain = gain
2939print (ads .gains ) # voor alle opties
30- ads .rate = 860
40+ ads .data_rate = sample_rate
3141print (ads .rates ) # voor alle opties
3242
33- chan = AnalogIn (ads , ADS .P0 ) # pin 0 verbonden
43+ chan = AnalogIn (ads , ADS .P0 , ADS . P1 ) # pin 0 verbonden
3444
3545###### Lees meerdere datapunten
36- data = get_data .readADS (chan )
46+ data = get_data .readADS (chan , samples )
3747
3848# maak een (unieke) filenaam aan
39- filename = 'meting_test1_%s.txt' % (int (time .time ()))
40- write_data .saveArray (data , filename )
49+ file_name = filename + '.txt'
50+ #filename = 'meting_test1_%s.txt' %(int(time.time()))
51+ write_data .saveArray (data , file_name )
Original file line number Diff line number Diff line change 1515 raise ImportError (
1616 "Failed to import library from parent folder" )
1717
18+ #INPUT VARIABELEN
19+ filename = 'test'
20+ samples = 1000
21+
1822###### configureer de MCP
1923spi = busio .SPI (clock = board .SCK , MISO = board .MISO , MOSI = board .MOSI )
2024cs = digitalio .DigitalInOut (board .D5 )
2125mcp = MCP .MCP3008 (spi , cs )
2226
23- chan = AnalogIn (mcp , MCP .P0 )
27+ chan = AnalogIn (mcp , MCP .P0 , MCP . P1 )
2428
2529###### Lees meerdere datapunten
26- data = get_data .readADS (chan )
30+ data = get_data .readADS (chan , samples )
2731
2832# maak een (unieke) filenaam aan
29- filename = 'meting_test1_%s.txt' % (int (time .time ()))
30- write_data .saveArray (data , filename )
33+ file_name = filename + '.txt'
34+ #filename = 'meting_test1_%s.txt' %(int(time.time()))
35+ write_data .saveArray (data , file_name )
Original file line number Diff line number Diff line change 88 fn = 'meting_test1_1604506938.txt'
99 data = lees_data_numpy .readArray (fn )
1010 time = data [:, 0 ]
11+ print (len (time )/ (time [- 1 ]- time [0 ]))
1112 plt .plot (time , data [:, 1 ])
1213 plt .show ()
1314
You can’t perform that action at this time.
0 commit comments