cancel
Showing results for 
Search instead for 
Did you mean: 

How to realize synchronization offset between DAC and ADC sampling time? Please recommend solution.

tmtlib
Associate II
Posted on November 02, 2016 at 15:06

My task is to control and acquire information from distance measurement sensor. Sensor is microwave distance measurement sensor based on FSK modulation.

I am using STM32F407 and HAL libraries. I am familiar with DMA operations and half transfer complete.

STM32 DAC provides 40kHz meander signal to sensor Vtune pin (VCO frequency tuning). Sensor provides single output connected to STM32 ADC working at 40kHz.

DAC one sample time is 

T = 1000 / 40000 = 0.025 ms

ADC and DAC sampling frequency is equal, although ADC sampling time must be much shorter than 0.025ms. Actually it must be something between 0.005 to 0.010ms, right before DAC output meander changes it's voltage. It is required to get correct data from the sensor, because it's output need some time to stabilize after new meander voltage is applied.

Here is an example of timings i want to achieve:

1111s 0000s 1111s 0000s 1111s 0000s

each symbol represents 0.005 ms in time

1 - DAC outputs 3.3v for 0.005 ms

0 - DAC outputs 0v for 0.005 ms

s - ADC acquires one sample for 0.005ms, while DAC continues to work for 0.005ms

Each block  ''1111s'' is 0.005 x 5 = 0.025 (40kHz sampling frequency)

I do not know how to achieve such offset, so i thought of running ADC at 5x speed of DAC:

ADC frequency: 5 x 40 kHz = 200 kHz

and using only each 5th sample from ADC.

For example, 10 samples ADC DMA buffer, interrupt on half complete takes sample N5 or sample N10 and adds it to 512 samples buffer.

I would prefer to do it in more optimal way, reducing interrupt overhead.

I am using DAC instead of GPIO because external sensor is capable not only of FSK meander modulation, but also linear FMCW modulation, so triangle signals could be applied too (through DAC output to sensors Vtune input).

Thank for your attention, I would be happy to see any comments and suggestions.
1 REPLY 1
Chris1
Senior III
Posted on November 03, 2016 at 21:42

You could trigger ADC conversions using a timer, similarly the DAC can be triggered using another timer, or a channel of the timer used for pacing the ADC.  Multiple timers can be synchronized.  

For example (using an STM32L476), TIM2 can be a master timer with TIM3 and TIM4 as slaves, TIM3's TRGO can initiate ADC conversions, TIM4's OC1REF can drive a DAC channel, data is transfered from the ADC to RAM using DMA, and conversely from RAM to the DAC, also using a DMA channel.  

TIM3 and TIM4 can operate at different rates, although synchronized / started by TIM2.

To operate this way you would need to pre-populate a region of RAM with the data you want to output to the DAC.