TVout Oscilloscope

Hi,

I have just finished a simple Oscilloscope using the great TVout (Google Code Archive - Long-term storage for Google Code Project Hosting.) library.

It displays the average, the minimal and the maximal voltage, and the sampling frequency. 100 sample points are displayed. The maximal sampling frequency is about 8kHz (on an Arduino Uno).

The input voltage is taken from analog pin A0. Add a button to digital pin 2 to scale the voltage range, and to digital pin 3 to scale the sampling frequency. Note that scaling the voltage range, the oscilloscope will middle the average voltage.

Let me know what you think.

Juerg

tvoutOscilloscope.jpg

TVoutOscilloscope.pde (6.23 KB)

Hehe.. did a simple version of this myself but you've taken it to the next level!

I think I may dedicate a 328 to a "permanent" build for this.. still can always ICSP flash with upgrades...

This is a pretty neat application of the TVOut library - I like it. Suggestions for future releases:

  1. More speed/bandwidth (may or may not be possible)
  2. Allow for negative voltage readings
  3. How about a second channel (will reduce sampling speed in half, probably)
    3b) Of course, adding things like A+B, triggering and such (just like a real scope)
  4. Can the resolution be increased?
  5. How about a different scope - a digital analyzer scope?
  6. Storage and Recall of sample data?

Anyway - great project!

:slight_smile:

Well, we know it can handle spectrum analysis (I did it as a mere light show, but...) by FFT, my spectrum analyzer with tvout project did it. Add a few labels and it might actually be useful instead of just cute.

The Integer FFT code I lifted from a post and made into a lib for re-use, google Arduino Integer FFT on google code.

@focalist: if you make a box for it, don't forget to add some extra buttons for future releases. :slight_smile:

yes, adding FFT would be nice.

@cr0sh: thanks for the suggestions.

  1. More speed/bandwidth (may or may not be possible)
    i know. but it's not possible.
    "It takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second."

  2. Allow for negative voltage readings
    what do you mean? just draw a scale from -5 (input=0) to 0 (input=1024)?

  3. How about a second channel (will reduce sampling speed in half, probably)
    yes, it would be nice to have. and yes, it will cut speed in half.

3b) Of course, adding things like A+B,
yes, that would be possible. are thing like that important? (i'm not an expert on oscilloscope...)

3c) triggering and such (just like a real scope)
the code already has a (simple kind of) triggering: at the beginning, it waits for a while until the voltage crosses from below the average voltage to above the average voltage. what other kind of triggering would be nice to have?

  1. Can the resolution be increased?
    of the screen? i guess not.

  2. How about a different scope - a digital analyzer scope?
    how would that work? just display 0 or 1 for different inputs? yes, maybe that would be nice to have. it might even be possible to get higher rates (reading digital is much faster than analog)

  3. Storage and Recall of sample data?
    yes, that would be nice, but the RAM on an arduino seems to be pretty limited, especially since TVout already takes its part. (i once added another int array of size 100 and TVout didn't like it as i started to write into its memory!) so i guess that will not be possible.

Storage and Recall of sample data?
yes, that would be nice, but the RAM on an arduino seems to be pretty limited, especially since TVout already takes its part. (i once added another int array of size 100 and TVout didn't like it as i started to write into its memory!) so i guess that will not be possible.

In the storage section there is a amazing discussion about fast storing data on SDcard - http://arduino.cc/forum/index.php/topic,64314.0.html

wullschj:

  1. More speed/bandwidth (may or may not be possible)
    i know. but it's not possible.
    "It takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second."

Maybe not with the Arduino alone - but what about an externally clocked RAM (with separate ADC)? Ok - I'll admit I'm not super-serious on this; its well outside the scope of the project...

:slight_smile:

wullschj:
2) Allow for negative voltage readings
what do you mean? just draw a scale from -5 (input=0) to 0 (input=1024)?

Well, I mean allow for a true AC signal (from -2.5V to +2.5V) to be input (centered around 0 volts) - what you'd have to do then is bias the signal to raise it above the 0 volt threshold to sample it with the ADC - then alter the display output labels, of course.

wullschj:
3) How about a second channel (will reduce sampling speed in half, probably)
yes, it would be nice to have. and yes, it will cut speed in half.

3b) Of course, adding things like A+B,
yes, that would be possible. are thing like that important? (i'm not an expert on oscilloscope...)

It can be useful in some cases - you can use it for filtering (subtracting out noise and such), or other things like have one channel control the vertical component while the other controls the horizontal (you can then draw Lissajous patterns, which can be used to test components with - if you add on an "octopus interface").

wullschj:
3c) triggering and such (just like a real scope)
the code already has a (simple kind of) triggering: at the beginning, it waits for a while until the voltage crosses from below the average voltage to above the average voltage. what other kind of triggering would be nice to have?

Well - allow the user to set the voltage to trigger on, or to set the trigger on positive change vs negative change (or both). Also - if you are doing dual channels, then triggering on one channel while sampling the other could be useful (or trigger on a digital input?).

wullschj:
4) Can the resolution be increased?
of the screen? i guess not.

It just didn't look like you were using the highest res of the TVOut library, but maybe that's just me...

wullschj:
5) How about a different scope - a digital analyzer scope?
how would that work? just display 0 or 1 for different inputs? yes, maybe that would be nice to have. it might even be possible to get higher rates (reading digital is much faster than analog)

Yeah - just look for highs and lows on a digital port (do a port-based sample), and plot each over time as a square wave. Allow for triggering on one or more of the pins (maybe also allow for definable binary pattern triggering)...

wullschj:
6) Storage and Recall of sample data?
yes, that would be nice, but the RAM on an arduino seems to be pretty limited, especially since TVout already takes its part. (i once added another int array of size 100 and TVout didn't like it as i started to write into its memory!) so i guess that will not be possible.

I was thinking of an SD card (as was mentioned), or perhaps using an external I2C/SPI EEPROM or flash memory for such data. It also sounds like with the TVOut library, you're on the edge of what is possible code-wise anyhow (you'd have to work hard to get all of the extra features I noted put into place on it)...

yes, that SDcard or external RAM sampling sounds really good, but i must say it is a bit outside of the scope of my little project.

from the other suggestions i might at some point implement some.

It just didn't look like you were using the highest res of the TVOut library, but maybe that's just me...

ok, maybe i'm just doing something wrong. i don't really know how to increase the resolution. the few higher resolutions that i tried all resulted in no picture at all on my old TV. maybe it's my TVs fault?

but i must say it is a bit outside of the scope of my little project.

This discussion should inspire you to rise to unknown heigths and a chance on eternal f(l)ame :wink:

Seriously, you have created something people like and is really usefull. Use that energy to let your little project grow, but do it in your pace. Take some time to think in what order to take the next steps.

Succes,
Rob

Quote from: wullschj on June 19, 2011, 04:04:33 PM

  1. More speed/bandwidth (may or may not be possible)
    i know. but it's not possible.
    "It takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second."

Maybe not with the Arduino alone - but what about an externally clocked RAM (with separate ADC)? Ok - I'll admit I'm not super-serious on this; its well outside the scope of the project...

You could increase bandwidth up to 20 times ( 6 usec/sample ) if you replace analogread
( 120 usec/sample ) with direct access to ADC registers. Look at:
http://oscilloscopeexpress.blogspot.com/

Plus it will allow you to change bandwidth ( time per division ) settings.

You could increase bandwidth up to 20 times ( 6 usec/sample ) if you replace analogread
( 120 usec/sample ) with direct access to ADC registers. Look at:
http://oscilloscopeexpress.blogspot.com/

Plus it will allow you to change bandwidth ( time per division ) settings.

Thanks a lot, Magician! that code works great. I realized that it is in fact possible to read even a bit faster by starting the ADC as soon as the last value is read out, so we have to wait a little less before the next value is ready.

Here is an updated version of the Oscilloscope which can sample at a speed up to 140kHz. At higher frequencies the readings are a bit less accurate...

Juerg

TVoutOscilloscope.pde (9.45 KB)

I love this. I got a unused old TV that I will put just for this and some other Arduino TVOut related projects. :wink: Thanks for sharing!

Wk

Quick question. Any updates on this project? I'm really loving it. 8)

I wonder on doing a VGA output to add color to this. (will require tons of changes, I know)

Wk

Sweet!
This is exactly what I was looking for since I just found my old LCD pocket television from the 90's.
Thanks!

Could someone please help me with this sketch? i want to use another pin to measure the negative voltage so it can display whole sinusses etc.

i have been dragging through the code, but it is not easy readible txt.

what i want to do is convert the negative voltage with diodes to a positive voltage on the 2nd pin. then it is just a matter of making the pixels(y) go negative (y becomes -y)

This is a GREAT project, one which I am going to try..

I have a slight improvement (although I havent loaded it up yet)
I have spent months looking at ways of speeding up the TVout library

The following sets a pixel

static void inline sp(uint8_t x, uint8_t y, char c) {
 if (c==1)
 display.screen[(x/8) + (y*display.hres)] |= 0x80 >> (x&7);
 else if (c==0)
 display.screen[(x/8) + (y*display.hres)] &= ~0x80 >> (x&7);
 else
 display.screen[(x/8) + (y*display.hres)] ^= 0x80 >> (x&7);
} // end of sp

if you look at it, each pixel that is set in the screen byte is set by 0x80 (0b10000000) shifted right by 0 to 7 times depending on the pixel x position.. this can be quite variable, and also 7 shifts can be a little slow

so I suggest a possible solution...

uint8_t bitPosn [8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };

static void inline sp(uint8_t x, uint8_t y, char c) {
 if (c==1)
 display.screen[(x/8) + (y*display.hres)] |= 0x80 >> bitPosn[x&7];
 else if (c==0)
 display.screen[(x/8) + (y*display.hres)] &= ~0x80 >> bitPosn[x&7];
 else
 display.screen[(x/8) + (y*display.hres)] ^= 0x80 >> bitPosn[x&7];
} // end of sp

just a simple lookup of the bitposition should speed things up a little

also (for those who have used this) the same could be used in draw_row

I have also written a new section for shift (screen shift) so that certain isolated areas could be shifted regardless of what else is going on. I used it to shift quarters of the screen in and out diagonally, creating a kaleidoscope feature !

I have also been looking at a really fast clearscreen, as I found the 1536 byte clear took around 700us which is far too long if you are in a hurry, there have been suggestions of a clearscreen of just over 200us

:slight_smile:

hello wullschj,
Very nice project Arduino tvout oscilloscope. We built a max 8 MHz frequency counter and measures.
Your project can measure up to 5 MHz? There is a full documentation from your project? About me find information at: www.yo9bxe.ro
Looking forward for your answer. All the best, Nelu

Is anyone willing to answer my questions?

Wullschj made only four posts, the last one was on 2011-06-25, five years ago. Anyway max sample rate was only 140KHz.

Thanks for info. Do you have a detail?