Read ADC without reinitializing channel
Posted: Sun Feb 19, 2017 1:34 pm
Hey there!
I've got some issues trying to optimize the performance of my ADC with Micropython on my PyBoard Lite. I need two ADC channels to get the voltage of two hall-effect-sensors, which is then used to calculate the angle of a motor.
Since knowledge about the angle is required to define which of the motors coils are to be switched on, it is important to calculate the angle very fast to be able to spin up the motor to high frequencies.
First I simply used .read() to get the value, but I found that to be relatively slow. So I checked out the source code of the micropython firmware and looked for the adc_read funtion. This is when I found out, that the function adc_config_channel is executed every time I do a adc.read() in my python code.
Now I am looking for a way to execute adc_read_channel without reinitializing the channel everytime I call adc.read() to save some time. To do this, I guess I would have to initialize the channel somehow and save the channel to a variable I can pass to the adc_read_channel function.
Unfortunately I could not find anything about this in the documentation. Does anyone know, if this is possible or I would have to hack the original firmware to save some time?
Or do you know if this would not save time at all? Thank you very much in advance!
Yours Sincerely,
Felix
I've got some issues trying to optimize the performance of my ADC with Micropython on my PyBoard Lite. I need two ADC channels to get the voltage of two hall-effect-sensors, which is then used to calculate the angle of a motor.
Since knowledge about the angle is required to define which of the motors coils are to be switched on, it is important to calculate the angle very fast to be able to spin up the motor to high frequencies.
First I simply used .read() to get the value, but I found that to be relatively slow. So I checked out the source code of the micropython firmware and looked for the adc_read funtion. This is when I found out, that the function adc_config_channel is executed every time I do a adc.read() in my python code.
Now I am looking for a way to execute adc_read_channel without reinitializing the channel everytime I call adc.read() to save some time. To do this, I guess I would have to initialize the channel somehow and save the channel to a variable I can pass to the adc_read_channel function.
Unfortunately I could not find anything about this in the documentation. Does anyone know, if this is possible or I would have to hack the original firmware to save some time?
Or do you know if this would not save time at all? Thank you very much in advance!
Yours Sincerely,
Felix