[Open_electroporator] culture shock ADC and DMA

Nathan McCorkle nmz787 at gmail.com
Tue Aug 28 08:22:22 UTC 2018


On Mon, Aug 27, 2018 at 3:48 AM Nathan McCorkle <nmz787 at gmail.com> wrote:
> so I think my next goal is to shove some simple voltage clamp code in
> that loop instead of doing nothing... will need to sync on the timer
> so we make sure we always have a push AND pull pulse before shutting
> off the GPIO/PWM drivers (with quick reg-write). Another challenge
> with the ADC grabbing two channels now is I have to ensure I'm only
> working off of the last Voltage sample, which might be tricky since I
> think we're running the ADC as fast as it can convert samples (rather
> than syncing readings to the pulse timer).

Moved the register writes that start the first "kickoff" timer from
Python to C, when I confirmed that worked I then moved on to adding
some timer synchronization loops based on existing code in the ADC.c.
I just added empty loops to make sure the code didn't break things as
I went.
Then I added a simple attempt at a voltage clamp:
  IF ADC VALUE > 300 : TURN OFF a single timer's output (should cause
pulsing to stop on one of the GPIO that we use to pulse the coil)
  IF ADC VALUE < 285 : TURN that GPIO output back ON

I didn't see any activity on the expected GPIO pin... so I am guessing
the way I attempted to get the last ADC sample is not going to work
since I've configured things with DMA.
I'll have to take a look at the block diagram with the internal
wiring/muxing to see if it looks like the data path is broken.

I guess I should be able to just read the values from the buffer we
already provide, that's what I'll try next, but I will need to look
into the DMA registers to try and find the sample # too, so I can pull
out the last voltage reading.

Here's the commit:
https://github.com/nmz787/culture_shock/commit/424a9317d2ac2467c949097c8abdc665ad803be7

notice I updated the adc.c patch file, but also made a copy of the
version I last compiled... just since reading the patch file is much
uglier than reading the patched-file... we don't have to keep this
file around after we're done debugging, unless we want to.
https://github.com/nmz787/culture_shock/blob/424a9317d2ac2467c949097c8abdc665ad803be7/FOR_ADC_DMA__1_9_3__CUSTOM__adc.c

(I also removed some currently unused functions... still not sure if
we should make our own source code file, or just keep patching in the
future... since adding our own file only means we have to do more work
in other files, so our new file is registered and compiled and linked)

More to come tomorrow night :) Hopefully more progress :)

-- 
-Nathan


More information about the open_electroporator mailing list