Read multiple ADC channel simultaneously
Posted: Thu Dec 08, 2016 10:12 am
Hi,
I am currently working in a project where a need to collect data.
I managed to collect data from one of the ADC port that the pyboard has thanks to this code:
import array
import os
import pyb
import utime
adc1=pyb.ADC(pyb.Pin.board.Y12)
buf1=array.array('H',bytearray(30000))
tim=pyb.Timer(6, freq=1000)
adc1.read_timed(buf1,tim)
f1=open('data1.dash','w')
for val in buf1:
s=str(val)
f1.write(s+'\n')
f1.close()
This code enables to read the values of the port Y12 and stock them in a file in the SD card.
I am now trying to do the same but with two ports. But if I use the same code, that will first collect the data from the first port and then collect the data from the second port. Is there a way to collect both data at the same time ?
Thanks for your help
Meide
I am currently working in a project where a need to collect data.
I managed to collect data from one of the ADC port that the pyboard has thanks to this code:
import array
import os
import pyb
import utime
adc1=pyb.ADC(pyb.Pin.board.Y12)
buf1=array.array('H',bytearray(30000))
tim=pyb.Timer(6, freq=1000)
adc1.read_timed(buf1,tim)
f1=open('data1.dash','w')
for val in buf1:
s=str(val)
f1.write(s+'\n')
f1.close()
This code enables to read the values of the port Y12 and stock them in a file in the SD card.
I am now trying to do the same but with two ports. But if I use the same code, that will first collect the data from the first port and then collect the data from the second port. Is there a way to collect both data at the same time ?
Thanks for your help
Meide