How to Work with DACs on C2000 MCUs | Getting Started with C2000 Microcontroller Blockset, Part 11 - MATLAB & Simulink
Video Player is loading.
Current Time 0:00
Duration 5:50
Loaded: 2.83%
Stream Type LIVE
Remaining Time 5:50
 
1x
  • Chapters
  • descriptions off, selected
  • en (Main), selected
    Video length is 5:50

    How to Work with DACs on C2000 MCUs | Getting Started with C2000 Microcontroller Blockset, Part 11

    From the series: Getting Started with C2000 Microcontroller Blockset

    Follow this step-by-step guide on how to design a model in Simulink® using the digital-to-analog converter (DAC) on a TI C2000™ MCU F28379D LaunchPad™. It includes an example of generating analog output voltage on a DAC port of a TI C2000 MCU, as well as reading values using the ADC port and displaying the output in the Simulation Data Inspector.

    Published: 13 Jan 2025

    In this video, let me demonstrate a simple example on using the ADC and DAC block of C2000 microcontroller block set. Before getting started, let me walk you through some specifications of ADC and DAC peripheral on the launch pad I am showcasing. There are four ADC modules available on F28379D board, and each module has 16 input channels. The resolution of the ADC in F28379D is 12-bit. That is, the digital output ranges from 0 to 4096 for single-ended input.

    Coming to the DAC, there are channels, namely A, B, C. The output of the DAC is internally connected to the channel one of the ADC module A. So we are using the alternative pin functionality to simplify our demonstration without connecting any external jumper cables.

    Having said that, let me open a blank Simulink model. Let me add a DAC block under F2837XD and ADC block. Assign block under Scope block.

    Let's now configure each block. Double-clicking on the sine wave open its block parameter. There are parameters like Sine Type, Time, Amplitude, Bias, Frequency Phase, and Sample Time. Let the sine type be time-based, and let's use the simulation time. Let me set the amplitude to 2046 and bias to 2047. Let the Frequency be 1, Phase be 0. I am setting the sampling time to 0.004-- that is, a frequency of 250 hertz. Let me add another scope block.

    To view the generated sine wave, let's do a quick run to see the sine wave. You could see a sine wave is being generated with an offset of 2047. I have given this offset in order to utilize the full ADC resolution. Let me open the block parameters of the DAC block and select DAC channel B. When we go to the ADC block parameters, let me select the ADC module A. Input channel ADCIN1. Sample time of 0.002, and leave other parameters to default.

    Let me navigate to the configuration parameters by pressing Control-E. I'm going to Hardware Implementation tab to choose my microcontroller. In my case, I'm choosing Launchpad F28379D. Let me build the model and flash it to CPU1. So I'm leaving this parameter to default.

    So let me run the model in Monitor and Tune mode. As I have mentioned previously, the DAC output and the ADC's input are connected internally, so there isn't any extra wires that is to be connected on this board. Now you could see the model being built, and the code is being generated.

    Now let's open the scope to see the output of the ADC. Let me open this scope, and you could see the incoming sine wave that is coming from the DAC which is fed back to the ADC. You could see the amplitude of the sine wave varying from 0 to 4095.

    Let me keep the scope screen to my side and open the block parameter of sine wave again. Let me set the amplitude to 1,000 and bias 2,500. When I click on Apply, these parameters are transmitted to the controller board, which is fed as the input to the DAC block, and the same is looped back to the ADC. So the output of the ADC changes, as you could see in the scope here.

    And this is the speciality of the Monitor and Tune mode, where you could change the parameters of any blocks over here and see the changes reflected back in the scope. This concludes my ADC/DAC loopback demo.