How to capture special patterns with Arduino instead of using Oscilloscope

I want to capture specific patterns via the use of oscilloscope. The problem is that my Oscilloscope (DSO138) does not connect to laptop so that I could take printscreens. So, in order to solve that problem I am thinking of using an Arduino in order to identify special patterns that I am searching. So to map them to numbers like this: "pattern_1" -> "1", "pattern_2" -> "2", "pattern_3" -> "3"...etc. So, in other words, I have a device "A" that gives me an output. I need to connect that device to an Arduino and check in the output of device "A" if the previously mentioned patterns are met. Is this possible?

Maybe. What is the data rate of the pattern?

1 Like

This sounds very difficult - mathematically how would you compare patterns and what difference would be acceptable , noise amplitude differences ? ….unless you are looking at digital patterns which you could just read into an array or buy a cheap logic analyser .

You also have memory , A/D resolution and computing power restrictions with Arduino.
It would fall into my too hard box - I would try and think outside the box and think about what you really need to know

1 Like

1 KHz - 2 KHz.

Does not give any real information - how long do you need to capture for ? What is 1-2khz ? Sampling rate ? Or highest frequency component to capture . What sort of waveform .

1 Like

Using a logic analyzer? An Arduino can be programmed to work like a tiny logic analyzer, but even a cheap logic analyzer outperforms an Arduino in this area.

1 Like

Ok, the T (period) = 20 ms to 25 ms (@ 200 mW average power) ...does this help?

Something like this? USB Logic Analyzer - 24MHz/8-Channel - TOL-18627 - SparkFun Electronics As I see from here: Getting Started with a $10 Logic Analyzer using Sigrok and PulseView - YouTube it depicts digital signal. I am going to read Analog signals....

You could start by streaming the input data to your computer and plot it perhaps?

1 Like

Have you got a camera or a phone with a camera? :wink:

In the old-analog days you could get a 'scope camera which was a Polaroid camera with an attachment and maybe a special close-up lens. They probably had non-Polaroid cameras before that but I never saw one.

1 Like

It looks like someone has created a firmware update here.

Features

  • Two analog channels
  • Two digital logic channels (SWDIO and SWDIO pins (PA13 and PA14) on board)
  • Serial port interface for captured waveform data
  • Trigger source selectable from Analog Channel 1 or Digital Channel
  • Option to use rotary encoder instead of + - and SEL switches
  • 2K sample depth
1 Like

How?

I would start by writing the output of analogRead() to serial using Serial.write(). If you can plot the data on your computer and you can see the patterns you are looking for, then you can do all of the processing there.

If not, then you may need to do the processing on the board, which can be tricky if the patterns you are looking for are complex and/or long as this would require quite some memory.

1 Like

Does logic analyzer depict analog signals?

You can easily make a simple oscilloscope with an Arduino.

With the serial plotter set to a high Baud rate for speed, do the following in loop:

  • Take a 'sample' by using analogRead().
  • Send the value read to the Serial Plotter.
  • Add a delay if necessary.
1 Like

At a very basic level, the Arduino example program "AnalogReadSerial" collects analog signal and streams it to the PC and that can be displayed on the Arduino IDE serial plotter.

Arduino will be limited by the serial port throughput, so you'd want to set the baud rate as high as possible. Analog read is limited by the default conversion rate of the ADC to about 9k samples/second. You can do better by setting ADC parameters at the register level, but serial port bandwidth is then a problem again.

What is the specific signal you want to capture?

An alternative approach might be to use the audio input jack on the PC for signal capture and dispense with the Arduino approach, but audio input is usually AC coupled, so it might not be an appropriate alternative for your signal.

1 Like

Here is a simple oscilloscope sketch, that I wrote since I sent reply #15

int sensorPin = A0;           // select the input pin for the sensor
int sample = 0;               // variable to store the value coming from the sensor

unsigned long previousMillis = 0;
unsigned int interval = 1;    // sampling period

void setup() {
  Serial.begin(115200);
}

void loop() {

  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;         // save the last time you took a sample
    sample = analogRead(sensorPin);         // take the next sample
    Serial.println(sample);                 // Send the sample to the Serial Plotter
  }
}

1 Like

Here is a10Hz sinewave displayed using my simple oscilloscope sketch

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.