- Open the Segmented DAC block by double clicking it.
- Under Segment Settings, click on the ‘New Segment’ option. This allows you to add a new segment.
- Change the number of bits to 4 in the newly added Segment.
- Click on ‘Apply’.
- Then you can see that the total number of bits are changed to 12. Now you can generate the 12-bit resolution voltage from DAC pins in Simulink using Arduino Due board.
how to generate 12bits resolution voltage from DAC pin of arduino due board in simulink
27 次查看(过去 30 天)
显示 更早的评论
Hi, I am using Arduino due board DAC pin to generate voltage. I want resolution to be 12bits. But when i use in simulink, it generates 8bit resolution voltage from 0.56v to 2.76v. Please let me know how to generate the 12bit resolution voltage from DAC pins in simulink using Arduino due board. Block says it accepts 0-4095 values, but it does not react accordingly. It does Not react for each increament, it reacts only for multiple of 16 (example: 0, 16, 32, 48, 64 ........etc..).
Can you please let me know how to solve this problem.
Can we do this in PYTHON? :)
is there any solution using creating s-block??
Thanks
0 个评论
回答(1 个)
Manikanta Aditya
2023-3-20
Hi Aakash,
As per my understanding, you would like to know how to generate 12-bit resolution voltage from DAC pin of Arduino Due boards in Simulink.
To change the output total number of bits to 12, Please follow the steps mentioned below:
For further reference, please check this link to know about Design and Evaluate Segmented DAC:
I hope this resolves the issue you are facing.
12 个评论
Arun Kumar
2023-4-14
编辑:Arun Kumar
2023-4-14
Hi Aakash,
Please modify the MW_analogWriteDAC.cpp file by running the following command:
edit(fullfile(fileparts(codertarget.arduinobase.internal.getSpPkgRootDir),'arduinobase','src','MW_analogWriteDAC.cpp'))
This will opoen the MW_analogWriteDAC.cpp file in the MATLAB editor.
Replace the existing MW_DACWrite function with the following function:
extern "C" void MW_DACWrite(uint8_T channelFlag, uint32_T value)
{
#if defined(_ROTH_DUE_)
static int init_12bitDac = 0;
if(init_12bitDac==0){
analogWriteResolution(12); /* set the resolution of the Arduino analogWrite() function to 12 bits */
init_12bitDac = 1;
}
analogWrite(((channelFlag == 0)? DAC0 : DAC1), value);
#elif defined(_ROTH_MKR1000_) || defined(_ROTH_NANO33_IOT_)
/* dividing the data by 4 to adjust for upscaling by 4 in Arduino analogWrite API */
analogWrite(DAC0, (value>>2));
#elif defined(_ROTH_MKRZERO_) || defined(_ROTH_MKRWIFI1010_)
/* dividing the data by 4 to adjust for upscaling by 4 in Arduino analogWrite API */
analogWrite(15u, (value>>2));
#elif defined(_ROTH_ESP32_)
dacWrite(((channelFlag == 1)? DAC1 : DAC2), value);
#endif
}
This will change the resolution of DAC to 12 bit on Arduino due board. Please note that this change will only work for Arduino due. Other arduino boards are not affected by this change.
Hope this helps!
Thanks,
Arun
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Modeling 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!