Public projects 1

Draw Anything on Your Oscilloscope

Project tutorial by Timster and Juan Alvarez

  • 3,163 views
  • 12 comments
  • 19 respects

Toolbox 1


Respected projects 1

Draw Anything on Your Oscilloscope

Project tutorial by Timster and Juan Alvarez

  • 3,163 views
  • 12 comments
  • 19 respects

Comments 3

  • Draw Anything on Your Oscilloscope about 2 months ago

    Thanks Juan. I appreciate that!
    Another thing I tried is increasing the Y DAC to 8 bits by using two of the Port C pins along with the 6 Port B pins. Seems to work well and increases the vertical resolution nicely.
    I used pins A4 and A5 for the upper two bits.

    So setup looks like this:

    void setup(){
    // initialize port D and B, and two pins on Port C for digital output
    DDRD = B11111111;
    DDRB = DDRB | B00111111; // Keep the state of the top two pins
    // It's safer just to change the two pins we need rather than the whole of Port C
    pinMode(A5, OUTPUT);
    pinMode(A4, OUTPUT);
    }

    and the drawing code like this:
    ```
    void loop(){
    for (int t=0; t < NUM_POINTS; t++)// run through points
    {
    byte x = pgm_read_byte_near(x_points + t);
    byte y = pgm_read_byte_near(y_points + t);

    ​PORTD = x;
    ​ // Split the y value across the two ports, without affecting the unused pins.

    ​PORTB = y & B00111111; // lower 6 bits of y
    ​PORTC = (PORTC & B001111) | ((y & B11000000) >> 2); //upper 2 bits of y

    ​delayMicroseconds(FIGURE_DELAY);
    }
    }
    ```
    I realise this means we're now setting the Y value in two separate operations but it doesn't seem to cause a problem visually, at least not on my old analogue scope.
    I've also done an "Etch-a-sketch" project using some pots to control drawing directly to the scope - maybe I'll put that on here as a separate project.

  • Draw Anything on Your Oscilloscope about 2 months ago

    I've found a way to massively increase the number of points supported on an UNO - move them into program storage space. You can do this with the PROGMEM modifier. This way you can store around 15,000 points!

    So declare the arrays like this:

    const int NUM_POINTS = ...
    const byte x_points[NUM_POINTS] PROGMEM = {...
    const byte y_points[NUM_POINTS] PROGMEM = {...

    Don't do the modification to the y_points in the setup function (i.e. remove the for loop there). Instead do a bit shift in loop function.

    You also need a special command to read data from program memory (pgm_read_byte_near). So the for loop in the void loop() looks like:

    for (int t=0; t < NUM_POINTS; t++) // run through points
    {
    PORTD = pgm_read_byte_near(x_points + t);
    PORTB = pgm_read_byte_near(y_points + t) >> 2;
    delayMicroseconds(FIGURE_DELAY);
    }

    Then it's possible to store one high res image or multiple smaller images and cycle between them :-)

  • Draw Anything on Your Oscilloscope about 2 months ago

    Thanks for posting this project Juan. It finally persuaded me to unpack my Arduino!
    Great to finally draw pictures on my oscilloscope.

    A couple of comments:
    - In your Arduino code your iterator over the points, t, is a "byte" type, so only supports up to 255 points. Why not make it an "int"?
    - Your plotter code outputs "const unsigned long" for x_points and y_points - that won't work as you later modify y-points. Also, why not just use "byte" to save memory?

    Thanks!

Add projectSign up / Login