Pages: [1] 2 3   Go Down
Author Topic: Serial oscilloscope  (Read 6288 times)
0 Members and 1 Guest are viewing this topic.
Buenos Aires
Offline Offline
Full Member
***
Karma: 0
Posts: 208
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just finished programming 1st version of a software oscilloscope to use with Arduino. It's made in C++/DirectX so it performs pretty good (unlike the Processing dittos I've seen so far).

Here is a screenshot:



A few notes:

* Currently it ONLY accepts single byte values so you'll have to map int values down to 0-255 and send them off as bytes -> Serial.print(value, BYTE);

* The first few readings are weird due to Arduino resetting when the serial connecting is established. We're talking a few microsecs so it's no major problem. After that it's VERY stable.

* The application draws as fast as it receives the values. So you control the speed by sending faster or slower from Arduino. Though if you send TOO fast it messes up and you'll get error messages like "*Buffer overrun" (that means slow down..hehe). However 1000 values per sec don't seem to be a problem.

* Obviosly the COM port and BAUD rate must match that of Arduino.

Here is the application:

http://www.4shared.com/file/138189588/3813eae8/SerialScope.html

All feedback is very welcome smiley
« Last Edit: October 07, 2009, 02:46:00 am by Aniss » Logged

Buenos Aires
Offline Offline
Full Member
***
Karma: 0
Posts: 208
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ah...forgot to add a tiny Arduino sketch for testing:

Code:
byte val;

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

void loop()
{
  Serial.print(val, BYTE);
  val++;
  delay(2);
}
Logged

Chennai, India
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi
Your oscilloscope's really good! Is there some way you can adjust the time axis? And an option to save the waveform will really spice up your application!! smiley

Currently, i can only think of using the 'printscreen' option  

Do try to include the changes..  smiley
Logged

El Salvador, Central America
Offline Offline
Jr. Member
**
Karma: 0
Posts: 96
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is a useful tool.

¿Would you share your Windows source code?
Logged

Montreal
Offline Offline
Full Member
***
Karma: 0
Posts: 185
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks
Nice Tool
Logged

Patgadget
Montreal

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 70
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Great, linux version is possible?  
Logged

Sophia-Antipolis (06)
Offline Offline
God Member
*****
Karma: 4
Posts: 618
Rejoignez le club !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Nice, but as you are comparing with Processing oscilloscopes, did you gave a chance to this 2-bytes per channel, 12 channel, open-source, Win/Mac/Linux Arduinoscope ?

Logged

Buenos Aires
Offline Offline
Full Member
***
Karma: 0
Posts: 208
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm glad others find it usefull too. For my purposes it's perfect smiley

I'm planning to make several improvements (when I get the time):

* Multichannel (atleast 2..probably more)
* 10/16 bit capable
* Recording + rewind/pause + save as file + printscreen
* X axis scaling (aka time axis)
* Start up sync (to avoid the hickups at start up)
* Change analog in FROM the scope (which off course would require some arduino code as well)

Unfortunately I don't have much time these days so it may take a while before I get around to it.

The app is based on DirectX (for graphics) and Win32 (for serial) so it isn't exactly portable to Linux/Mac. Sorry! That was the price of good performance.

I uploaded a new version. Only changes are: it's capable of running much faster and it can display statistic info: FPS (frames per sec), BPF (bytes per frame) and TBR (total bytes received). Press RETURN to toggle info on/off. Here it is:

http://www.4shared.com/file/139947578/d080e5cc/SerialScope_2.html

I also uploaded the source code here:

http://www.4shared.com/file/138412518/630d2562/SerialScope_Source.html

It's not very pretty, but it IS a prototype. If you plan to compile it you'll need the following (I recommend installing in listed order):

* Visual Studio or Visual C++ express (I'm using the latter)
* DirectX SDK
* Dark GDK
* The following Win32 serial wrapper (add Serial.h and Serial.cpp to the project)

http://www.codeproject.com/KB/system/serial.aspx

PS: I did try the processing based Arduinoscope. It looks nice but it barely moves on my PC (which isn't the fastest one around I admit). Processing is WAY too slow. I used DirectX to get HARDWARE ACCELERATION, thus the performance is really good smiley
« Last Edit: October 17, 2009, 10:23:25 pm by Aniss » Logged

Chennai, India
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Apart from the usual V-t figures, do try to include an X-Y mode to display V vs V graph which'll help display characteristic curves and lissajous patterns. It'll increase the number of applications involving the serial scope  smiley
Logged

Buenos Aires
Offline Offline
Full Member
***
Karma: 0
Posts: 208
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Ashwin,

Sounds interesting..but I really don't know what you mean by that? Probably cause I never saw a real LIVE oscilloscope smiley-grin

Could you elaborate and I'll check it out?
Logged

Chennai, India
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi
 smiley
Generally, oscilloscopes are used to display Voltage-Time curves. However, when two channels are involved, it is possible to plot a graph with the voltage of the second channel on the Y-Axis and the voltage on the first channel on the X-Axis using the 'X-Y' mode. This way, the output becomes a voltage vs voltage graph. This is generally used to determine phase differences between two voltages(given to the two channels). This usually takes the form of a circle, ellipse or a slanted line(depending on the phase difference). This plot is called the 'Lissajous pattern' or 'Lissajous curve'. So, if you can plot the 'channel 2 voltage' vs 'channel 1 voltage' it'll make it look more like a real oscilloscope!!  8-)
Logged

Buenos Aires
Offline Offline
Full Member
***
Karma: 0
Posts: 208
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks smiley And like I said it sounds interesting...but complicated and not something I need right now so it wont be the first thing on my todo list...but perhaps some day...
Logged

Buenos Aires
Offline Offline
Full Member
***
Karma: 0
Posts: 208
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi again,

Added a few changes:

* Button animations. I know..no big deal but I hate buttons that dont react.

* Start up syncronization to avoid the hickups at start up. You now have to write: Serial.print("START"); in your setup(), otherwise the scope wont start drawing.

* X/time axis scaling. This was rather problematic as I suspected. And it messes up a bit for a sec when you change scale WHILE the scope is running. Besides the frame rate dropped significantly when I was downscaling...well it has to draw respectively 2,3 or 4 times as many lines each update. And like I said my PC isn't the fastest one around. Perhaps you guys wont notice the difference. Anyway I'll try to improve it later.

Here is the new version:

http://www.4shared.com/file/141877259/25284f56/SerialScope_3.html

I'm very interested in getting feedback regarding the performance. Like I said RETURN toggles info on/off. How fast/slow are you able to send from Arduino and still get usefull readings? What is you frame rate etc?

Here is a small sketch for speed testing:

Code:
#define PERIOD_LENGTH 1
#define BYTES_PER_PERIOD 2

byte val=0;

void setup()
{  
  Serial.begin(115200);
  Serial.print("START");
}

void loop()
{
  for(int i=0; i<BYTES_PER_PERIOD; i++) Serial.print(val++, BYTE);
  delay(PERIOD_LENGTH);
}

I'm able to send up to ~8 bytes per millisec, but more than that and I get "*buffer overrun" errors and the likes. Please let me know how your setups perform?!


Aniss smiley
« Last Edit: October 19, 2009, 02:27:17 am by Aniss » Logged

France
Offline Offline
Sr. Member
****
Karma: 0
Posts: 266
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Nice, but as you are comparing with Processing oscilloscopes, did you gave a chance to this 2-bytes per channel, 12 channel, open-source, Win/Mac/Linux Arduinoscope ?
I'm totally lost in trying to use, compile,... http://code.google.com/p/arduinoscope

The only thing that works is the dowloaded application-osx.zip java file where I've a nice 6 channels scope display. But when I try to understand, compile the arduino sketch examples downloaded from processing-arduinscope.zip, it is totally esoteric to me.

Has anyone with a Mac succesfully used the open source of arduinoscope server and if yes, would you be ok to provide clear step instructions ?

Thank you
« Last Edit: November 15, 2009, 04:32:39 am by selfonlypath » Logged

Sophia-Antipolis (06)
Offline Offline
God Member
*****
Karma: 4
Posts: 618
Rejoignez le club !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you check the issues ? There is a library incompatibility with some Macs.
Logged

Pages: [1] 2 3   Go Up
Jump to: