Analog Acquisition

hello
I tried to acquire an analog signal (sinusoidal shape with a frequency of 50Hz) using MATLAB/SIMULINK and an analog input pin of ARDUINO MEGA 2560.
The model was run in external mode.
However, the visualised signal does not match the original signal; it has a discontinuous shape
attached is the program that I have used
Thank you for your help
Best regards

Acquistion_test.pdf (5.81 KB)

Hi ArdSim_user

That PDF is a block diagram, not a program.

Please post your Arduino program. Use code tags around it (the </> button on the toolbar above the reply window).

Or are you using the Arduino Support from MATLAB?

What is the amplitude and frequency of the input signal? Is it sinusoidal as indicated in the diagram?

What is the source of the signal? How is it connected to the Arduino?

Regards

Ray

That is no Arduino code, can’t help with that.

Moderator: crosspost merged - please do not do that as it costs everybody time

Hello Hackscribble
This program is in Matlab/simulink
Made with the assistance of Arduino support for Matlab/Simulink
The test signal is from a function generator, it is in this form: A/2 +Asin(wt)
A < 2.5Volts and the frequency is 50Hz
Thank you for your help
Best regards

If A = 2.5V then Asin(wt) will vary between +2.5V and -2.5V, I think.

If you then add offset of A/2 or 1.25V, won't that give a signal between +3.75V and -1.25V? So the bottom part of the waveform will be below 0V and outside the input range of Arduino analog input.

Can you post an image of the output signal you are getting?

sorry Hackscribble, it's A/2 +A/2 sin(wt) sorry the analog input signal is within 0 and 5Volts, I already tested the same sigal using Arduino IDE software, not Matlab Simulink, and it's work without any problems. in my mind, there is a problem in Matlab/Simulink best regards

Cross-post locked or deleted.

DO NOT CROSS-POST