DAC Output on Arduino MKR Zero in Simulink - matlab

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:
This is an image of the waveforms on the scopes:

Related

GSM noise on lm35

i use lm35 temperature sensor and stm32 f030k6 for reading sensor output
when i call sim800 , lm35 output is noisy and incorrect value and When I open the antenna, the noise disappears.
How can I remove this noise?
thanks

How to pulse generator block generate a pulse 40khz?

I tried to generate a 40khz pulse to the GPIO pin of my ultrasonic sensor in raspberry pi. I used the pulse generator instrumentation, but the pulse is not accurate: the oscilloscope displays only 10khz.
I modified configuration parameters:
fixed-step
sample time is auto/1e-08
solver is auto/discrete
I also have tried various ways to create a square pulse: function sign(sin(2*pi*40000t)), PLL block, repeating sequence, signal generator combined with sum, compare to zero, etc.
All of these display correctly on the scope, but do not deploy accurately.
I doubted the raspberry pulse generatior, so I used python to drive the GPIO pin; results are very accurate. I worry that the Simulink complier doesn't properly support raspberry or the sample time.
Any suggestions?
This is the model I used to generate 40khz pulse.
with period is 0.000025s,pulse width 50%, Solver type is fixed-step.
The oscilloscope display as the following figure:

Connect models in Matlab Simulink

Good day everyone!
I tried to make a circuit in matlab simulink, with an AC voltage, Resistor and Voltage measurement. AV voltage and Resistor connect quite well but voltage measurement can't connect the resistor connection.
how may I connect the voltage measurement to the resistor? Please help me thanks!
this is the circuit i want to simulate
I used different types of resistor, and Ac voltage but same results
In my opinion, your diode is from a different library (Simscape\Foundation Library\Electrical) than the voltage source, the resistance and the voltage measurement block (Power Systems...). Try to use blocks from the same Library.
See following picture for when I only use blocks from Simscape\Foundation Library\Electrical

Frequency issues in simulink interface with arduino

I'm trying to generate 6 PWM signals by comparing sine and triangular waves on simulink.In the scope I'm getting the frequency of PWM signals as 50 HZ. But when I deploy the model onto arduino, the frequency of the PWM signal is getting reduced to around 15 HZ .How to fix this ?
whether you've downloaded arduino library for matlab simulink? PWM output later on arduino digital pins are connected to the scope matlab

How can i get Audio Stream input as binary number for AES encryption in verilog?

I am doing a project in which I have written the code for AES-128 encryption algorithm in Verilog with a fixed input (128-bit), Now I want to take audio stream as binary number and use it for input to AES encryption algorithm.
What would be the best way to do that?
As shown in figure, Connect your source of Audio to ADC, Make sampling frequency as described in below,
F_sample >= 2 x Fmax_audio (According to Nyquist Criteria)
That will be fed to ADC.
Give 90 degree shifted clock to FPGA for latching that Digital data from ADC.
Now you have your data on Board, use it in AES algorithm.
You can do reverse process to speaker.
180 degree phase shift also can be used, according to setup and hold time.
Edit:
There is one reason why 90 degree phase shifted clock to FPGA board, if we use 90 degree phase shifted clock then it is sampling the data at half of positive level, so we can avoid the mis-sample. See image, at 90 degree it is stable as well, we also can use 180 degree.