How to take analog signal sample at one perticular period

Could anybody please tell how to take 50 Hz analog signal 100 sample at one perticular period in one array and again repetition of analog cycle in another array .please write the code so that two cycle of analog signal Data could be collected in two different array with 100 samples.is it possible?I am doing it for removing noise by averaging of these arrays . This analog signal is my sensor output

Post the code you have, using code tags, and forum members can make suggestions.

I'd suggest you start here

The process of removing noise may be more complex than you imagine. Best to make sure your input signal is as noise free as possible FIRST

1 Like

You should link to your prior post on this same subject so that members to not duplicate effort.

As I said in that prior post:

It is unlikely that anyone will write the code for you for free.

You can do the research and try to write the code and if you get stuck, post the code and describe what the code actually does and how that differs from what you want.

Or you can have this thread moved (ask a moderator to move it) to the Jobs and Paid Consultancy category . There you can find someone that will write code for you for payment.

I have just looked at the

prior post

.
We STILL have no information on the "sensor" or how it is connected.

And whether there are any other yet unmentioned elements in the circuit.

So can you post a simple schematic please?

And also: how will you ensure in the presence of noise that the two sets of measurements start at the same phase of the cycle?
This seems a very complicated and unreliable way of reducing noise.

What do you know of the frequency characteristics of your noise signal?

Actually this is my sensor output signal .


I need to take sample after 0.2 milliseconds in 19.8 milliseconds duration only

I want to collect sensor value at perticular period in different array like first cycle of output in one array and second cycle of output in another array after that I want to do averaging so that without Being lost my sensor data ,noise could be removed.

Void setup(){
Serial.begin(9600);
}
Void loop()
{
for(i=0; i<198;i++)
{
Array1[i]= analogRead(A0);
Serial.println(Array1[i]);
}
For(j=0; j<198; j++)
{
Array2[j]= analogRead(A0);
Serial.println(Array2[j]);
}

Please solve my problem.i am unable to save data in array at perticular period and averaging them

I guess that you missed or ignored the message asking you to read the how to get the best from the forum post.

Read the forum guidelines to see how to properly post code and some good information on making a good post.

Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

Please go back and fix your original post

What Arduino board?

Is that pulse train (top trace on the drawing) used to trigger recording for a certain time? Am I correct in assuming that the trigger is the negative edge of the pulse? What sampling rate?

Where is the pulse train coming from? What is the amplitude and duration of the pulses?

1 Like

Thank you so much for reply.sorry for not follow proper guidelines of Arduino forum.i am new on this platform so I missed it.But next time I will take care of it.
I am using Arduino Uno board.I am giving sensor output signal into analog pin of Arduino Uno board.and externally providing pulse train on digital pin of Arduino which is High for 0.2 milliseconds and low for 19.8 milliseconds. I have to collect sensor output data (198 sample) at 19.8 milliseconds period only in arrays . First cycle of analogRead signal during 19.8 milliseconds have to collect in Array1. and second cycle of analogRead signal During 19.8 milliseconds in array2. After that just averaging of both array so that without loss of data, noise could we removed from sensor output and get original signal.could you please write code so that 198 sample of Sensor data could be collected at proper duration( during 19.8 milliseconds ) in array1 in first cycle of signal and after that again 198 sample in array2.
Is it possible?

Why only next time, do it now.
I have moved your post to here. Now you edit your first post so the code is posted correctly.

what voltage are the signals?
initially you could try to detect the trigger pulse and start sampling at 0.1mSec intervals to get the 198 samples (I am assuming the UNO can sample at that rate)
then use the arduino-serial-plotter to view the result
if sucessful start averaging etc

Edit: have a look at Arduino: Analog measurements which explores the usage and performance of the analog to digital converter (ADC) on the Arduino.

If only we knew which sensor and how it's connected to which Arduino, then...

That is a sample every 100 microseconds. An analogRead on an Uno takes 110 microseconds at full resolution. Add time to store the sample and the sample rate that you require is not attainable with an Uno.

In order to be able to average the 2 arrays they must be exactly in sync. So the start of sampling will need to be the same for both arrays. How to sync the sampling?

Probably, but not with an Uno. If you use a faster processor the sample rate could be attained. Do need to figure out how to synchronize the sampling of the arrays. You could us a timer interrupt to generate an accurate sampling frequency.

I would probably use a Microstick II with a DsPIC33FJ128MC802 which has a 10/12-bit ADC with 1.1Msps/500 ksps conversion rate with DMA facilities

Thanks for reply. I just want to ask one thing , is it possible to take analog signal sample at one perticular period in one array and after repetition of signal cycle again take sample in another array?could you please write the code to collect analog signal Data in different array? because I have never seen such a code but I need it in my project

it depends on the sampling rate, ADC converter specification, DMA, etc
given the right microcontroller and ADC you code sample two signals concurrently into two arrays

It is unlikely that anyone will write the code for you for free.

You can do the research and try to write the code and if you get stuck, post the code and describe what the code actually does and how that differs from what you want.

Or you can have this thread moved (ask a moderator to move it) to the Jobs and Paid Consultancy category. There you can find someone that will write code for you for payment.

consider a Ardunio Due which the datasheet states has a 16-channel 12-bit 1 msps ADC - it also enables DMA to be used with the ADC
have a look at Playing With Analog to Digital Converter on Arduino Due

also try a web seach for arduino due adc dma