Incorrect description in website?

21 次查看(过去 30 天)
Hi,Can you please confirm that the description on resolution of Arduino due DAC pin given in the page is incorrect.In simulink it gives only 8bit resolution, but board has the capability of 12bits. Please provide the solution to change resolution to 12bits DAC. The link for page is: https://in.mathworks.com/help/supportpkg/arduino/ref/analogoutput.html
  4 个评论
Christine
Christine 2023-8-9
编辑:Staff 8 2025-8-26,13:32
The Arduino Due has two 12-bit digital-to-analog converters (DAC) which provide analog output on pins DAC0 and DAC1. Each of these DACs can provide a voltage output with a resolution of 12 bits, allowing for 4096 distinct voltage levels.
In Simulink, you should be able to set up the Arduino Due's DAC pins to output analog signals with 12-bit resolution. General outline of the steps you might need to follow:
  1. Model Configuration:
  • Open your Simulink model.
  • Add the necessary blocks for generating analog output, often using the "Analog Output" or "Arduino Analog Write" block.
  1. Block Configuration:
  • Double-click on the block you added in the previous step to open its configuration dialog.
  • Look for settings related to the resolution or number of bits. Make sure it's set to 12 bits (4096 levels).
  1. Signal Values:
  • When generating analog output, ensure that the values you're sending to the DAC block range from 0 to 4095 (for 12-bit resolution). This corresponds to the full range of the DAC's capability.
  1. Compile and Upload:
  • Once you've configured your Simulink model to output analog signals with 12-bit resolution, compile the model and upload it to your Arduino Due.
Remember that the specific steps might vary slightly depending on the version of Simulink you're using and the exact block names. If you're having trouble finding the settings for 12-bit resolution, you might want to consult the Simulink documentation or contact MathWorks support for assistance.

请先登录,再进行评论。

采纳的回答

Ganapathi Subramanian
Hi Aakash,
It seems like a potential bug. It has been reported to our development team. We will try to fix this in future releases of MATLAB.
  1 个评论
aakash dewangan
aakash dewangan 2023-3-31
Thanks for your response. FInally somebody responded :).
Anyways I have found the solution by using an external IC for 12bits voltage generation.

请先登录,再进行评论。

更多回答(1 个)

Rip
Rip 2025-8-26,4:36
移动:Walter Roberson 2025-8-26,7:13
True Hardware Capability vs. Simulink Defaults
  • Hardware: The Arduino Due includes two Digital-to-Analog Converter (DAC) channels (DAC0 and DAC1), each with 12-bit resolution, i.e. 4096 distinct output levels. MathWorksCliffsNotes.
  • Simulink: The Simulink "Analog Output" block (used via the Simulink Support Package for Arduino Hardware) may by default output at 8-bit resolution, even when connected to the Due. This is a software limitation, not a hardware one.
Confirmed Bug or Limitation
On MATLAB Answers, an acknowledged user reported this mismatch, and the accepted reply indicated that this behavior appears to be a bug in the documentation or support package — the Simulink block should support 12-bit resolution, but currently doesn’t reflect that in its description or perhaps in its implementation. The issue has supposedly been forwarded to MathWorks’ development team for correction in future releases. MathWorks
Workaround: Enabling 12-Bit Resolution in Simulink
Although the Simulink block description may imply 8-bit output only, you can still leverage the full 12-bit DAC capability on the Due — here's how:
  1. Use analogWriteResolution(12) in setup codeIn the Simulink-generated code, ensure you include analogWriteResolution(12); in your setup section. On actual hardware this sets the DAC to use the full 12-bit resolution. Arduino Forum+1
  2. Write values in the full 12-bit rangeWhen calling analogWrite(DAC0, value);, use values ranging from 0 to 4095 (instead of 0–255). This ensures you're tapping into the DAC’s 12-bit range.
  3. Simulink-specific workaround
  • Open the generated Arduino code (often in a .ino file).
  • In setup(), add:analogWriteResolution(12);
  • When you're writing to the DAC, ensure your signal maps correctly to [0, 4095].
  1. Use a custom S-function if neededSome users on the Arduino forums have implemented custom S-functions or low-level code for full control of analog output resolution in Simulink. Arduino Forum
Summary Table
ComponentActual CapacitySimulink DefaultWorkaroundArduino Due DAC12 bits (0–4095)8 bits (0–255) by defaultUse analogWriteResolution(12); and full-range values, or custom S-function
Bottom Line
Yes — the description in the MathWorks Simulink doc is incorrect or incomplete regarding the Due’s DAC resolution. In reality, the board supports 12-bit analog output, and you can achieve that level of detail by setting the resolution explicitly and mapping your output values correctly.
Would you like help adjusting your Simulink model or generated code to ensure the output is truly 12-bit?

类别

Help CenterFile Exchange 中查找有关 Arduino Hardware 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by