1

I am trying to use the Arduino MKR Zero in Simulink using the Simulink Support Package for Arduino Hardware. So far I have been successful at get a led to blink using a pulse wave in Simulink and the Digital output of the Arduino. I have also been able to vary a potentiometer connected to the Analog input of the Arduino and see the voltage plotted on a scope.

Now I am trying to output a sine wave from the DAC and then view that sine wave back through the ADC. The image below shows my setup. I know that the DAC takes value between 0 and 1023 and converts it to a voltage with reference 3.3V for the Arduino MKR Zero. So I have set up the sine wave block with Amplitude 307 and bias of 307 to get a 2V pk to pk waveform with offset of 1V. I have also included the Byte pack to convert this value to a Unit16 value for the DAC.

Now for the output I have done a similar setup to what I had for the potentiometer experiment. In this section, K = 3.3/4095. However, when looking at the scopes for the input and output, they are completely different. The input scope shows a sine wave with a 2V pk to pk waveform with offset of 1V while the output doesn't make any sense.

I should point out, for the physical setup, I have simple connected the DAC pin to the A6 pin on the Arduino. Any advice on what I am doing wrong is welcome.

Simulink Setup: Simulink Setup

This is an image of the waveforms on the scopes:

Result

ocrdu
  • 2,172
  • 6
  • 15
  • 22
Baldrick
  • 11
  • 2
  • 1
    Do you have a picture of the not-any-sense-making output? What frequency is the sine wave and what frequency is the ADC sampling rate? BTW I'm not so sure this belongs on SO; Arduino or EE are better places to post this. – ocrdu Nov 05 '20 at 18:33
  • I added an image in the original post above – Baldrick Nov 05 '20 at 19:33
  • And the frequencies? – ocrdu Nov 05 '20 at 19:38
  • The default 1 rad/s and sample time of 0.1s – Baldrick Nov 05 '20 at 19:48
  • So 0.16Hz and 10Hz. Hm. Not what I thought then. It almost looks like the ADC is sampling a floating pin. No, sorry, I don't know what is causing this. BTW if you get no answers here, take it to EE. – ocrdu Nov 05 '20 at 20:10
  • Yeah I believe so because if I remove the connection between the DAC pin and the A6 pin, I still get a waveform on the output scope. – Baldrick Nov 05 '20 at 20:13
  • Have you tried other pins? Pin mappings vary ... – ocrdu Nov 05 '20 at 20:16

0 Answers0