Go Down

Topic: Poor man oscilloscope, quasi real-time snap shooter. (Read 24861 times) previous topic - next topic


Jun 06, 2011, 03:20 am Last Edit: Nov 26, 2011, 03:05 am by Magician Reason: 1
Would like to get a feedback on new project. There are a lot of similar ones, that require processing or application running on host computer. My idea is different in a way:
ONLY serial monitor is running on a computer.


Structure of the commands:  DS;
   - where D is a digit 1, 2, 3, or 4
   - and S is a letter "a", "d" or "i".

Digit defines  time per division (10 samples) resolution:
   - 2 - 1111 microsecond;
   - 3 - 158   microsecond;
   - 4 - 57     microsecond;
   - 1 - 10     millisecond,  for low frequencies.

Letter changes format of image:
   - a - analog, more clear representation vertical lines;
   - d - digital,  more clear representation horizontal lines;
   - i  - information, print ADC data array for observation.

Combine command like 2a2d3a3d4a4d and send. It'll provide 6 snapshots    
in analog and digital "format" and in a three time scales.

Input - analog AN0.


That is absolutely beautiful!  I'll give it a whirl when I have a moment and get back to you.  Hopefully later today, but no promises.


Jun 13, 2011, 12:03 am Last Edit: Jun 14, 2011, 05:28 pm by Magician Reason: 1
Thanks.   It's a pity, not many people think like you  ;).
I blame myself on it, not to explain "clear" in the beginning.

So , the question is, what is it all about, one more sloppy oscilloscope?
- No, it is more than that. I have a DSO, that cost me ~ 100$, and I love it. Lack of real devise was not a reason to have fun with this project. Let me explain:

1). If the "problem" you are trying to troubleshoot is related to input signal:
      - missing input,
      - nonlinear reading,
      - noise etc.,
all you need is oscilloscope.
  Buy one, if you need it more than once, or load my sketch to arduino, solve a trouble, and reload your sketch again. You can combine two sketches, in this case you will be able to put a finger on pulse of the system, whenever I'd like to be sure, it's doing just fine.
  Just one more things, for using this project in your design. It's not necessarily, that picture on external device is the same, as picture that coming right after arduino ADC. It's still make sense to load a sketch and get picture from "inside" Atmega chip, in order to figure out wrong DC bias error, interruption conflict, timing  or "stroboscope effect" error (when arduino making analog reading with a frequency close to N x F (input signal)).

2). Let's say input signal is perfect (whatever signal in your design is, it could be
      temperature, light, pot, pressure, vibration, sound etc), but you still have
a problem after processing your data:
- averaging;
- log/sqrt equation;
- math operation with other variable or input;
- FFT .

And oscilloscope (if you have one ) is absolutely useless here...

Right, the correct way is to use serial monitor, and trek data after each stage,
as they say "Divide and Conquer!!!", check if anything wrong in the code.
But what if data fast varying variable? Serial monitor "slow" device, and even after you print data on monitor, you still couldn't get a "pattern" in it?
Use a plotter, office tools (Excel), Processing or something else to visualize a data.
Only it become too complex to debug simple "blinking led" sketch in first place, and in second, it OS dependable, not easy transferable tools.

And here a solution, osscillo-plotter (hey, if you have a better name for this project, please, say it).
You insert in your sketch two print_chart function: in front of "stage" and right after that. (Don't forget, to replace data in array with "processed" data, before calling print_chart second time.)
And here you are, two plots, "original" and "processed" data.
  Changing your math, for example, averaging constant ( two readings, 100, 2000 ???) you can watch how it's affect your data, almost in "real-time".


Version V2 released.

Vertical size of the chart limited only by resolution of the host computer monitor!

    NEW commands with more time settings:
     - where D is a digit from 1 to 7 OR letter "r" (repeat mode).
     - and S is a letter: "a", "z", "d", "b" or "i".

  "Digit defines speed of N measurements, where N equals to INBUF. Each data element would be stored in the table. Every time new chart requested, old data are rewritten, except command "Repeat".
  Digit 1 is the slowest, adjustable for really low frequencies, like 50/60 Hz and even less.
  2 is the same speed as "analogread" arduino command.
  7 is the fastest speed, with 60 usec per division, or 6 microsecond!!! per sample, allow signal above 50/60 kHz to be observed."


Jun 16, 2011, 05:09 am Last Edit: Jun 16, 2011, 05:11 am by CrossRoads Reason: 1
That is pretty neat, using the A/D to capture data and get it out the serial port at a pretty good sample rate.

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


Jun 16, 2011, 05:29 am Last Edit: Jun 16, 2011, 07:09 am by Magician Reason: 1
There are a lot of similar ones, that require processing or application running on host computer. My idea is different in a way:
ONLY serial monitor is running on a computer.

First, no additional software, no portability problem.

Second, you can't get by serial:

  10- bit ADC = 2 byte
  6 microsecond/sample or
  166.000 sample per second
  baud-rate:  333 kBytes/second  :)

This is why samples stored first in the chip, mirroring on Y axes, and turn 90 degree to be print.

And third, I put two names in the subject line.
It is supposed not working continuously, rather in short series or sporadically.
Trigger capture function not only by operator, but events or pin status, to get "burst" samples of rapidly changing signal during transition process.
Let say, to get picture of lighting + thunder strike. 


10- bit ADC = 2 byte
  6 microsecond/sample or
  166.000 sample per second
  baud-rate:  333 kBytes/second

I have used speeds beyond 115200 on an uno and 2009, see - http://arduino.cc/forum/index.php/topic,61498.0.html - The ide could not manage but external apps like putty.exe did very well.

Give it a try
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)


[font=Verdana]putty.exe[/font] is additional / supplementary software. :)
Yes, I agree that limits of serial link could be resolved, except putty we can use a compression algorithm, like in old days on X, Z, modems. Plus office tools/plotter/excell/processing has to running on the compute, to draw a chart.
But this is exactly what I try to avoid at any cost.
When I first make a research on i-net on this topic, I was surprised, that all projects I was able to find, build on the same structure:
  -arduino only measure input, and immediately send it to PC.
A while ago, I create an application bind with MS Excell. And it doesn't function anymore.
I just can't catch up with this monster (like MS, Sun, etc) that release new version of OS's, Office, every half- or two years, And it is never compatible. So I give up. (;


OK, got your point,

then 2 thoughts:
-  you might rethink your output generated by using TAB's iso 4 spaces, there are much |--------| sub strings that could be |TT| where T is a TAB char.
- the other though is to go vertical iso writing the time from left to right do it from top to bottom
   then you can output a line directly after a measurement and have "real time" output.
   something like
Code: [Select]

int x = analogRead(A0);
int i=0;
while (i++ <x/10) Serial.print('*');
while (i++ < 100) Serial.print('-');

100 chars @115200 baud is still 10 millis ...  so it would only work for low freq (<50Hz) signals

just thinking out loud :)

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131