GEX thesis source code, full text, references

ch.unit.dac.tex 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. \section{DAC Unit}
  2. The digital/analog unit works with the two-channel \gls{DAC} hardware peripheral. It can be used in two modes: \gls{DC} output, and waveform generation.
  3. The waveform mode implements direct digital synthesis (explained in \cref{sec:theory_dac_dds}) of a sine, rectangle, sawtooth or triangle wave. The generated frequency can be set with a sub-hertz precision up to the lower tens of kHz. The two outputs can use a different waveform shape, can be synchronized, and their phase offset and frequency are dynamically adjustable.
  4. \subsection{DAC Configuration}
  5. \begin{inicode}
  6. [DAC:dac@13]
  7. # Enabled channels (1:A4, 2:A5)
  8. ch1_enable=Y
  9. ch2_enable=Y
  10. # Enable output buffer
  11. ch1_buff=Y
  12. ch2_buff=Y
  13. # Superimposed noise type (NONE,WHITE,TRIANGLE) and nbr. of bits (1-12)
  14. ch1_noise=NONE
  15. ch1_noise-level=3
  16. ch2_noise=NONE
  17. ch2_noise-level=3
  18. \end{inicode}
  19. \subsection{DAC Commands}
  20. Channels are specified in all commands as a bit map:
  21. \begin{itemize}[nosep]
  22. \item 0x01 -- channel 1
  23. \item 0x02 -- channel 2
  24. \item 0x03 -- both channels affected at once
  25. \end{itemize}
  26. \begin{cmdlist}
  27. 0 & \cname{WAVE\_DC}
  28. Set a \gls{DC} level, disable \gls{DDS} for the channel
  29. & \begin{cmdreq}
  30. \cfield{u8} channels
  31. \cfield{u16} level (0--4095)
  32. \end{cmdreq} \\
  33. 1 & \cname{WAVE\_SINE}
  34. Start a sine waveform
  35. & \begin{cmdreq}
  36. \cfield{u8} channels
  37. \end{cmdreq} \\
  38. 2 & \cname{WAVE\_TRIANGLE}
  39. Start a symmetrical triangle waveform
  40. & \begin{cmdreq}
  41. \cfield{u8} channels
  42. \end{cmdreq} \\
  43. 3 & \cname{WAVE\_SAWTOOTH\_UP}
  44. Start a rising sawtooth waveform
  45. & \begin{cmdreq}
  46. \cfield{u8} channels
  47. \end{cmdreq} \\
  48. 4 & \cname{WAVE\_SAWTOOTH\_DOWN}
  49. Start a dalling sawtooth waveform
  50. & \begin{cmdreq}
  51. \cfield{u8} channels
  52. \end{cmdreq} \\
  53. 5 & \cname{WAVE\_RECTANGLE}
  54. Start a rectangle waveform
  55. & \begin{cmdreq}
  56. \cfield{u8} channels
  57. \cfield{u16} on-time (0--8191)
  58. \cfield{u16} high level (0--4095)
  59. \cfield{u16} low level (0--4095)
  60. \end{cmdreq} \\
  61. 10 & \cname{SYNC}
  62. Synchronize the two channels. The phase accumulator is reset to zero.
  63. & \\
  64. 20 & \cname{SET\_FREQUENCY}
  65. Set the channel frequency
  66. & \begin{cmdreq}
  67. \cfield{u8} channels
  68. \cfield{float} frequency
  69. \end{cmdreq} \\
  70. 21 & \cname{SET\_PHASE}
  71. Set a channel's phase. It is recommended to only set the phase of one channel, leaving the other at 0°.
  72. & \begin{cmdreq}
  73. \cfield{u8} channels
  74. \cfield{u16} phase (0--8191)
  75. \end{cmdreq} \\
  76. 22 & \cname{SET\_DITHER}
  77. Control the dithering function of the \gls{DAC} block. A high noise amplitude can cause an overflow to the other end of the output range due to a bug in the \gls{DAC} peripheral. Use value 255 to leave the parameter unchanged.
  78. & \begin{cmdreq}
  79. \cfield{u8} channels
  80. \cfield{u8} noise type (0--none, 1--white, 2--triangle)
  81. \cfield{u8} number of noise bits (1--12)
  82. \end{cmdreq} \\
  83. \end{cmdlist}