Clear Filters
Clear Filters

Is it possible to control where the ADC samples within a period? MATLAB Simulink C2000 F28379D

18 views (last 30 days)
Hi,
I have a waveform running at 25 kHz. I am currently running this waveform to the ADC on board which is the LAUNCHXL-F28379D. The programming of this is done with MATLAB Simulink using the C2000 addons.
The sampling period of the ADC in this case is set to 4e-6s, or exactly 25 kHz. The idea is to get a single sample within the period. But, I would like to change the location of this single sample and pass the result to the onboard DAC. For instance, given the sample period is 4e-6s, is it possible to get a single sample at 1e-6, 2e-6, 3e-6, and so on to my choosing? I attempted to change the SoC with ePWM3A as the trigger source and timer for the ADC and visually, the waveform going into the ADC seems to be relatively identical to the waveform the DAC outputs, besides the obvious quantization effects.
Is it possible to take a sample at a specific count and hold that value? What settings can I change to achieve that?
What is my best approach to this problem? Any individuals with experience and knowledge with C2000 Matlab Simulink would be greatly preferred and appreciated! Thanks!~
  3 Comments
Fangjun Jiang
Fangjun Jiang on 24 Mar 2023
The interrupt should certainly work, although function-call generator is the same. All you need is a periodic trigger with a time offset.
Make sure your simulation step size is small enough to hit the time offset. For example, if your sample time is 4s, then your simulation step size could be as large as 4s. But if you want a time offset of 1s or 3s, then the step size needs to be 1s or smaller. If the time offset is 2s, then the step size could be 2s or smaller.
Joeny Zhen
Joeny Zhen on 24 Mar 2023
Edited: Joeny Zhen on 24 Mar 2023
I tried this attempt out. The problem with this solution is that the frequency going into the ADC, and the frequency at which this periodic trigger happens is NOT the same. This causes the location of the sample to essentially shift in time due to the time jitter between the two parts. This is exactly why I am looking for a interrupt done specifically by the c2000 hardware on the F28379D launchpad board. I made my attempts, but it did not work out which is why i'm attempting to ask an expert to how to do so. Do you have a possible solution that involves making an interrupt using the C2000 blocks instead of standard simulink blocks that occurs at what i've described at my first post? For instance, if the sampling period is 4e-6, can I send an interrupt out at 1e-6 to obtain what the value is at that sample? If so, how can I go along doing so with c2000 simulink blocks?

Sign in to comment.

Answers (1)

Fangjun Jiang
Fangjun Jiang on 23 Mar 2023
Not too many people noticed this.
In the case of a discrete sample time, the vector is [Ts, To] where Ts is the sampling period and To is the initial time offset.
  6 Comments
Fangjun Jiang
Fangjun Jiang on 24 Mar 2023
Edited: Fangjun Jiang on 24 Mar 2023
Not sure if we are still talking about the same topic. Open this example model, hook a Scope block to the output of the Rate Transition block.
ex_specify_sample_time
Specify the sample time of the Rate Transition block as [0.4] and later [0.4 0.1], observe the timing of the first sample, it is 0.4 and later 0.5.
I think the latter is what you want, right? Everything else in your model is executed at time 0, 0.4, 0.8, 1.2, ... but you want the ADC to happen at 0.1, 0.5, 0.9, 1.3,...
Joeny Zhen
Joeny Zhen on 24 Mar 2023
Sorry but no, we are NOT talking about the same topic. All your solutions involve an idealized simulink environment. It seems that you are not considering how the C2000 hardware works in real time. By hooking a scope block and attempting to monitor a signal in it on c2000 hardware, I lose information simply based on how the hardware is designed due to many factors such as baudrate, and so on.
I am specifically looking for a potential solution that involves using the C2000 Simulink blocks. Hopefully an expert that involves the C2000 Simulink hardware addons can answer this problem. Thanks.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!