Introduction: OFFscope - Offline Oscilloscope (Arduino + SD Card Fast Logging)
This is not real time oscilloscope!
First you acquire signal by saving/logging it to SD card. Then you review the acquired signal on your PC.
This oFFline oscilloscope is intended for automotive sensor diagnostic. 99% of automotive sensors work in range from 0v to 5v. Ideal for Arduino. Of course, you can use it wherever you like as long you obey 0v to 5v input range.
There are many Arduino oscilloscope modifications. If you by some external hardware + arduino you will get usable real time oscilloscope. If you use only arduino as oscilloscope sampling rate will be very small, almost unusable for anything. After searching the web I found that arduino can fast log of his analog pins to SD card. Combining that with some “Processing 2” code you can have some sort of offline oscilloscope.
It is accurate and you can have up to 50000 samples per second. All, that for under 15$ ...
I will show you in 2 examples how this combination is performing against real oscilloscope.
Step 1: Stuff You Need
You have to be familiar with car oscilloscope sensor diagnostic. Probably the best tool for that is Picotech .
Price is high. Luckily here is an alternative.
You will need 3 things
(any Chinese arduino clone will be ok, e.g.: Uno R3 ch340, under 5$) Drivers for CH340
Arduino SD shield
(any Chinese clone will be ok, e.g.: “Arduino Logger Module Shield V1.0”, under 6$)
SD card (any class 10, full size 2 or 4 GB card will be ok, under 5$)
Total: arduino + SD shield + SD card = under 15$
Please note that max sampling rate will be determined by how fast is your SD card. Every SD card is unique and only by testing the card inside arduino you can see how it is performing. It is trial and error process until you find maximum sampling rate. There is NO other way!
Also there is no point in using more than 4 GB card because you have to format it in FAT16 mode.
Step 2: Hardware + Software Upload to Arduino
If you are a beginner with arduino please find some arduino tutorials on instructables
Format the SD card on your PC to fat16.
a) Connect SD shield to Arduino R3, just snap on the SD shield to arduino.
Connect + from sensor to A0 and - from sensor to GND pin on arduino
b) Download the arduino “oFFscope_v2.zip” code on the PC and extract the ZIP
and place the folders inside your Arduino 1.6.3 developer folders. You have to copy
folder “SDfat” from ZIP to your arduino install folder: Arduino-1.6.3 -> Libraries
c) Start Arduino-1.6.3 go to: File -> Examples -> Sdfat -> oFFline_scope_v2 and load the program.
Inside code you have to change this line to get the maximum logging speed from your SD card:
// Sample rate in samples per second.
const float SAMPLE_RATE = 10000;
In the example above you have set 10000 samples per one second. If you divide 1/ 10000 you will get:
100 microsecond per interval. That means arduino will read voltage on A0 (analog pin 0) every 100 microsecond
and write that value to SD card.
To achieve that speed arduino writes to binary file. After acquiring the signal and you finish logging to SD card you have to convert that binary file to CSV file (comma separated txt file) so you can work with the file.
oFFscope_v2.ino is modified work of one and only the great “fat16lib”(William Greiman). He is the master mind behind fast logging to SD card and be sure to visit his official site about fast SD logging.
On my SD card I can log up to 50000 samples per second without losing any data.
Set you sampling interval to 10000 then acquire some data and if you don’t have overruns (skipped samples) increase the sampling interval to 20000 and try logging again. After that try 30000 and so on...
When you start getting overruns that means you have hit your SD logging speed limit.
Only modification I have made is to remove file header from CSV file, log only pin 0, and change the name of the file. Everything else is the same as “fat16lib” -> “AnalogBinlogger”.
Step 3: Acquiring/logging the Data...
Upload your modified oFFscope program to your arduino and open serial monitor
from Arduino-1.6.3 (PIC1) .
You will get this small menu:
c - convert file to csv
d - dump data to Serial
e - overrun error details
r - record ADC data
To start logging press “r” on the keyboard and press enter. Arduino will show something like this (PIC2)
Press “s” key to stop logging. You will get something like this (PIC3) . Check for dropped samples!
Now press “c” to convert binary file to CSV file. You will get something like this (PIC4) .
Now you have CSV file that you can load in “processing” and review the acquired data.
Remove SD card from arduino insert SD card in some card reader and transfer CSV files to your PC.
Step 4: Review Data in Processsing 2 and Sigscope
If you are a beginner with processing check this link .
Download "Processing 2".
Extrac ZIP file and load "oFFscope_v2_processing.pde" inside “Processing 2”.
Change this line to load your CSV file :
String filename = "offSco03.csv"; // name of the file to load
Note: csv file must be in the same folder as pde file.
“RUN” the program and observe the wave form you have captured with arduino.
Inside program there are hotkeys. Feel free to explore them.
They are used to pause, move back and forward inside file, zoom in, zoom out and so on…
This great processing code is taken from other instructables. I have only
changed the part to load CSV file inside as table and browse through data.
Please read this instructables for original code.
You can also use this great tool “Sigscope” for CSV to review data. I will use this program in examples.
Step 5: Example 1 - Seconday HT Pickup From Spark Plug
If you are new to oscilloscope car sensor checking please download
from Picosope webpage their software. Install it on you PC. Inside you
will find all the explanation and examples you need to get you started.
Software is totally free.
After you install the program you can browse through help and find how
to hook up oscilloscope and get usable data from the sensors. The best
part is large waveform database.
We will use that waveforms and compare them to our oFFscope logging files.
I have captured secondary HT spark ignition waveform. That signal is fast
and you need high sampling rate to capture it. I have setup my arduino at
SAMPLE_RATE = 50000; and collected the signal.
You can download this exapmle "offSco04.csv"
Here is the piscosope example vaweform (PIC1)
Here is oFFscope_processing vaweform (PIC2)
Here is Sigscope review of the acquired data (PIC3)
Pretty solid, you can see all the crucial parts of the waveform. Not bad for 15$ :)
Step 6: Example 2 - Relative Compression - Petrol
This CSV was acquired combining oFFscope and UT-203 .
You can download this example "offSco05.csv"
Picosope example waveform (PIC1)
oFFscope waveform opened in Sigscope (PIC2)
Not bad at all :)
You can see that one cylinder has lower compression than other 3.
This is not an easy tool to work with. You have to be familiar how real
oscilloscope works and how it can help you in diagnostic. It is better to
capture multiple times same signal so you can rule out problems in
capture itself. Some signals don’t need high amount of sampling.
You can lower amount of sampling and get descent waveforms.
Compare them to Picosope waveforms.
When you got the hang of it, it can help you in diagnosing faulty
sensors in minutes.
P.S. I am not a programmer. I have modified files the best I could. If you
have some ideas to make this even better please contact me.
We have a be nice policy.
Please be positive and constructive.