# how to program arduino to deal with analog signal pattern in real time?

kindly, i have an analog signal with 4 patterns i want from Arduino to recognize each analog signal pattern ...with some error rate....the signal pattern is shown below What frequency are these waveforms?

Will these waveforms be one-shot or will they be continuous ? If continuous then 3 and 4 are the same, of course.
What sort of timescale will the signals occur over ?
Is the Arduino just to recognise each waveform and output an identifier or is it expected to measure something ?

You will need to shift the signals so that all of the waveforms are between 0 and 5 volts so that they can be read by the Arduino. What experience do you have with the Arduino ?

What frequency are these waveforms?

the signal frequency is different in each read..so i can not depend on the frequency ..

Let's try again - What frequency are these waveforms?

Will these waveforms be one-shot or will they be continuous ?

they are one shot, but for1 and 2 can take longer time like this photo but for 3 and 4 are not

but for1 and 2 can take longer time like this photo

Longer?
Femtoseconds or fortnights?

Let's try again - What frequency are these waveforms?

they are bio signals....the subject can control when the signal can occur and her pattern ...just need to classify the signal pattern

Femtoseconds or fortnights?

some seconds

Is the Arduino just to recognise each waveform and output an identifier or is it expected to measure something ?

just to recognise each waveform and output an identifier

You will need to shift the signals

the signal was shifted...and it it is between 0 - 5 volt

Draw out your waveforms again but this time do two things,

1. First put in the axis for both time and voltage

2. When to draw the waveforms do it so we can see what happens as waveform 2 follows 1. eg How do you get from the high of waveform 1 to the low of waveform 2?

Mark

In principle this sounds simple

``````read the analogue input
if the voltage rises above resting value  //cases 1 and 3
keep reading until voltage peaks and returns to the resting value
if voltage stays at resting value for test time  //how long should this be ?
type 1 detected
end of if
else
type 3 detected
end of else
end of if

//repeat with similar logic for a falling voltage for cases 2 and 4
``````

Determining the test time will be the biggest problem I suspect. What sort of time gap will there be between these waveforms ?

The best technics for such application is cross-correlation. Action you should take:

1. Sample input with precise timing, store samples to an array ( the bigger, the better, depends on available memory size)
2. Perform high pass filtering (HPF) over input data.
3. Run cross-correlation itself, sum up multiplication results between samples and templates
4. The bigger value with specific template confirm "a match".

The question only, how to define start point, one way based on absolute magnitude of the input, if it reach pre-defined threshold. Other way, as your signal quite slow, run all steps in real time