[Open_electroporator] culture shock ADC and DMA

Nathan McCorkle nmz787 at gmail.com
Tue May 8 08:37:52 UTC 2018


On Mon, Nov 13, 2017 at 4:26 PM, Nathan McCorkle <nmz787 at gmail.com> wrote:

> I will work on reading the ADC without DMA from a C function such that it
> should be faster... this will also probably require binding the IRQ
> handler/callback/function in C code too. Another few nights I guess.
>
>
Ok, so the micropython/ports/stm32/adc.c file has changed a bit, mostly
obvious style changes, but they also added a new method (read_timed_multi)
which reads from multiple ADC channels using a Timer to gate each sample,
and the docs report 210kHz with no dropped samples from 2 ADCs.
https://github.com/micropython/micropython/blob/master/docs/library/pyb.ADC.
rst

So that seems to be about the best we're going to do in a C loop reading
the ADC in an ungated situation (i.e. as fast as we can go, since faster
than this they were not getting the expected number of readings).
With extra code in the loop to adjust the pulse-width or pulse-period to
keep the voltage up or down, this might be slower (or maybe all the
processing time is eclipsed by the time for the ADC to perform sampling). I
may try to keep the ADC sampling into RAM via DMA, and have the loop only
check the latest-written/sampled value to save a bit of time in the loop
and probably gain a bit more resolution on sampling (since we don't waste
CPU on setting the ADC-enable bit, nor transferring the ADC reading into a
local register, which then gets transferred to a storage array).


I think we're needing 2 ADC channels now, since we have the voltage and
current being sensed now, and I have a feeling watching the current might
tell us something about when the cell pores open up (I imagine a current
spike at pore formation, due to less dielectric filling the area of the
electric field).


So I will probably try compiling some versions of adc.c tomorrow, reviewing
and playing with the read_timed function and ADC DMA sampling patch I wrote
before.

Also I'll probably see if someone has used or discussed this library on
MicroPython forums:
http://playground.arduino.cc/Code/PIDLibrary
https://playground.arduino.cc/Code/PIDAutotuneLibrary

though maybe a simple control loop like "voltage is above set-point ->
increase pulse-period" and "voltage is below set-point, decrease
pulse-period" will work fine... so that's what my focus will be, anyway
I've never tuned or implemented PID before so that's a big jump and I think
would be a layered improvement on the aforementioned simple control loop
idea.


-- 
-Nathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cibolo.us/pipermail/open_electroporator/attachments/20180508/8bdbfc0a/attachment.html>


More information about the open_electroporator mailing list