Pages: [1]   Go Down
Author Topic: Poor man oscilloscope, quasi real-time snap shooter.  (Read 8729 times)
0 Members and 1 Guest are viewing this topic.
Montreal
Offline Offline
Faraday Member
**
Karma: 27
Posts: 2573
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

http://oscilloscopeexpress.blogspot.com/

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.


* SineWave.jpeg (66.48 KB, 858x282 - viewed 42 times.)

* SineWaveD.jpeg (106.88 KB, 881x468 - viewed 49 times.)

* SineWave_d_a.jpeg (135.1 KB, 855x575 - viewed 32 times.)

* Music.jpeg (71.04 KB, 860x311 - viewed 35 times.)
« Last Edit: November 25, 2011, 09:05:35 pm by Magician » Logged

Humboldt, CA
Offline Offline
Full Member
***
Karma: 2
Posts: 223
Arduino BBB
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Montreal
Offline Offline
Faraday Member
**
Karma: 27
Posts: 2573
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks.   It's a pity, not many people think like you  smiley-wink.
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".

 
« Last Edit: June 14, 2011, 10:28:37 am by Magician » Logged

Montreal
Offline Offline
Faraday Member
**
Karma: 27
Posts: 2573
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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."


* Screenshot-rb.png (39.85 KB, 1280x800 - viewed 30 times.)

* Screenshot-rd.png (37.38 KB, 1280x800 - viewed 29 times.)
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 525
Posts: 26570
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That is pretty neat, using the A/D to capture data and get it out the serial port at a pretty good sample rate.

« Last Edit: June 15, 2011, 10:11:54 pm by CrossRoads » Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Montreal
Offline Offline
Faraday Member
**
Karma: 27
Posts: 2573
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Exactly,
Quote
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  smiley

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. 


« Last Edit: June 16, 2011, 12:09:35 am by Magician » Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
  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
Logged

Rob Tillaart

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

Montreal
Offline Offline
Faraday Member
**
Karma: 27
Posts: 2573
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

putty.exe is additional / supplementary software. smiley
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. (;

Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

 int x = analogRead(A0);
 int i=0;
 while (i++ <x/10) Serial.print('*');
 while (i++ < 100) Serial.print('-');
 Serial.println();
100 chars @115200 baud is still 10 millis ...  so it would only work for low freq (<50Hz) signals

just thinking out loud smiley



Logged

Rob Tillaart

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

Pages: [1]   Go Up
Jump to: