[Open_electroporator] culture shock ADC and DMA
Nathan McCorkle
nmz787 at gmail.com
Mon Nov 13 08:50:25 UTC 2017
On Tue, Nov 7, 2017 at 12:18 AM, Nathan McCorkle <nmz787 at gmail.com> wrote:
> Well I made some more progress:
> * the ADC is connected to the pin, set into "continuous sample" mode
> * the DMA is setup in Peripheral to Memory mode, then linked to the ADC
> * before pulsing I call my new C function, passing it an array object of
> (2048) 16-bit integers
> * The C function then passes the start (address) of this array, along
> with the number of integers (2048) allocated, to an STM-provided helper
> function "HAL_ADC_Start_DMA"
> * this enables the ADC and the DMA engine
> * pulses happen
> * another new C function is called, to disable the ADC and DMA
> ("HAL_ADC_Stop_DMA", I think this gets the ADC ready again)
> * print the value of the ADC sample buffer (from MicroPython)
> * parse the results from the terminal into a line plot
>
>
Here's instructions on how to update the firmware on the G30TH with the
latest MicroPython (1.9.3) and also patch the ADC.c file:
https://github.com/nmz787/culture_shock/blob/master/DEVELOPER_NOTE.md#g30th
> At this point, I believe the ADC/DMA is starting based on a clock/timer
> edge, after I allow/enable it to start... so it should be synchronized with
> our pulse timers (I think)... but I believe the ADC and DMA are simply
> working at maximum speed, however fast the ADC can pump out values, is how
> quickly the DMA stores them (I think).
>
>
I still need to figure that stuff out... after talking with a friend about
DMA and what I am doing now... I think I still need to try coding a simple
CPU-based read (in C code) based on a timer interrupt that is firing
out-of-phase with the pulses. My friend thinks a simple read, transfer, and
increment should be pretty darn fast. That also keeps the road open for
adding voltage-limiting feedback... which more and more I think I really
want, unless we can calibrate well enough that just measuring a sample's
resistance will allow us to lookup settings based on
interpolation/extrapolation. But limiting voltage sounds a lot more direct
and less drift-prone. I'll beat on this problem some more.
Here's the ADC.c code patch (shows me gutting most of read_timed and also
adding a bunch of setup to adc_init_single, as well as adding a new method
read_timed_stop):
https://github.com/nmz787/culture_shock/blob/master/FOR_ADC_DMA__adc.c.patch
read_timed is called here:
https://github.com/nmz787/culture_shock/blob/master/micropython_pulser_code/tim3_enable_tim1_tim2_tim5__tim1_shuts_down.py#L375
read_timed_stop here:
https://github.com/nmz787/culture_shock/blob/master/micropython_pulser_code/tim3_enable_tim1_tim2_tim5__tim1_shuts_down.py#L382
and the OLED scaling and line-graphing here:
https://github.com/nmz787/culture_shock/blob/master/micropython_pulser_code/tim3_enable_tim1_tim2_tim5__tim1_shuts_down.py#L117
Best,
-Nathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cibolo.us/pipermail/open_electroporator/attachments/20171113/ea6b8878/attachment.html>
More information about the open_electroporator
mailing list