-
Notifications
You must be signed in to change notification settings - Fork 4
Support synchronized ADC capture #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support synchronized ADC capture #55
Conversation
ready() and start() are just the begin() function split into two pieces so you can setup the DMA and ADC without starting until later.
ready() and start() are just the begin() function split into two pieces. ready() does everything except start the ADC capture. clear() is calling the DMABufferPool routine to flush out anything in the DMA buffers.
Memory usage change @ a76e0e4
Click for full report table
Click for full report CSV
|
Hi @jmdodd95682 , |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd change begin()
to call start()
and then ready()
(if equivalent)
My proposal:
With these changes, you would use @facchinm @iabdalkader Sounds good for you? Thanks |
I can take a look at the issue and PR next week. In the meantime @jmdodd95682 please sign the CLA. |
Signed the CLA. I agree with not having code duplication. I didn't want to just remove So we just have |
I had another thought. Rather than getting rid of the existing To avoid duplicate code, the |
Your proposal sounds good! |
Added bool noStart with default of false to allow backward compatibility with existing code.
Made proposed changes. Tested on my application, works as expected. |
Memory usage change @ 13e9f0e
Click for full report table
Click for full report CSV
|
Co-authored-by: Ibrahim Abdelkader <[email protected]>
Co-authored-by: Ibrahim Abdelkader <[email protected]>
Co-authored-by: Ibrahim Abdelkader <[email protected]>
Co-authored-by: Ibrahim Abdelkader <[email protected]>
Co-authored-by: Ibrahim Abdelkader <[email protected]>
Co-authored-by: Ibrahim Abdelkader <[email protected]>
Co-authored-by: Ibrahim Abdelkader <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jmdodd95682
I removed sample_rate
parameter from start()
to avoid duplication.
Please, apply these changes:
- add the private variable
uint32_t sampling_rate;
here:
Arduino_AdvancedAnalog/src/AdvancedADC.h
Lines 30 to 34 in f7d081c
private: size_t n_channels; adc_descr_t *descr; PinName adc_pins[AN_MAX_ADC_CHANNELS]; - modify this line in:
hal_tim_config(&descr->tim, sampling_rate);
https://github.com/jmdodd95682/Arduino_AdvancedAnalog/blob/0d2b69c152cd8925f64205b94c842d4edde0ae24/src/AdvancedADC.cpp#L224
This change is fine on its own, and it probably wouldn't hurt to merge it (after the issues are fixed) but it doesn't really fix the issue, the 2 ADCs will still be out of sync. I think, if we have time and if this is high priority, we should look into supporting "Dual Mode". In dual mode, one ADC controls the other and sampling is triggered simultaneously. I haven't tested it before but it sounds exactly like what's needed here. |
I agree. This was a quick fix and gets them with about 4us of each other. Not great, but okay as a short-term fix. The applications where it would be useful is things like:
|
This is now tracked at #59 (thanks @jmdodd95682!). |
Superseded by #60. |
The
begin()
function takes about 106us to execute. If you're trying to start two ADCs, this will mean the first ADC will already be capturing for at least 106us when you execute theADC.begin()
on the second one.The changes proposed here allow the following semantics:
This reduces the skew between the two captures to about 4us.