Close
0%
0%

HariFun#134 Oscilloscope Abuse

Arduino byte-banging text and bitmap onto an oscilloscope

Similar projects worth following
From what I've seen, oscilloscope drawings have always been done by using the X-Y capability of a dual channel scope. My method could be used even on a single channel oscilloscope.

Sawtooth Demo

void setup() {
  DDRD = B11111111; // Set all bits of PORTD as output
}

void loop() {
  for (uint8_t y=0; y<=255; y++) // Loop through all possible y values of a byte
  {
    PORTD = y; // Slap the bits to Arduino pins D0..D7
    delayMicroseconds(50); // Let it linger
  }
}

Dashed Line Demo

void setup() {
  DDRD = B11111111; // Set all bits of PORTD as output
}

void loop() {
  for (uint8_t y=0; y<=255; y++) // Loop through all possible y values of a byte
  {
    // Only "plot" when y is divisible by 25
    if ((y%25)==0)
        PORTD = y;
    delayMicroseconds(50); // Let it linger
  }
}

  • Thumbs Up Bitmap Demo

    Hari Wiguna05/01/2016 at 08:02 0 comments

    // Drawing a bitmap on scope by Hari Wiguna, 2016
    // Playing with R-2R Ladder to convert Digital to Analog
    // We'll use PORTD because it gives us contiguous 8 bits
    // Thanks to digole.com for the bitmap to array converter: http://www.digole.com/tools/PicturetoC_Hex_converter.php
    
    const uint8_t xMax = 219; // # of columns
    const uint8_t yMax = 230; // # of rows
    const uint8_t bandMax = 28;  // 219/8 rounded up
    
    // This is only some of the bytes of the bitmap.
    // See github for full listing.
    

    const unsigned char image[] PROGMEM = {

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f }; void setup() { DDRD = B11111111; // Set all bits of PORTD as output } void loop() { DrawBitmap(); } void DrawBitmap() { int horizUnit = 40; // how spaced out horizontally between x pixels? PORTD = 255; // Set to high so we could trigger consistently at this level for (uint8_t band = 0; band < bandMax; band++) // each band is a column of eight pixels { for (uint8_t x = 0; x < 8; x++) // draw 8 horizontal pixels per band { for (uint8_t y = 0; y < yMax; y++) // draw 230 rows of vertical pixels { uint8_t bitAnalogValue = 10+ y; // Offset from 0V so image would be vertically above the almost solid 0V line unsigned char vertByte = pgm_read_byte_near(image + ( (yMax-y) * bandMax + band)); // get the byte representing that row and band if ( ((band*8+x)<xMax) && bitRead(vertByte, 7-x)) PORTD = bitAnalogValue; else PORTD = 0; // if it's within bound and it's ON, move beam to that Y position delayMicroseconds(horizUnit); // Wait a little to allow scope to draw a short horizontal line. } } } PORTD = 0; delay(1000); // Set to 0V and wait before drawing again }

  • Hello YouTube Demo

    Hari Wiguna05/01/2016 at 04:39 0 comments

    // Drawing letters on scope by Hari Wiguna, 2016
    // Playing with R-2R Ladder to convert Digital to Analog
    // We'll use PORTD because it gives us contiguous 8 bits
    // Font courtesy of: http://jared.geek.nz/2014/jan/custom-fonts-for-microcontrollers
    
    const uint8_t fontWidth = 8;
    const PROGMEM uint8_t font[]  = {
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //  
      0x00,0x5f,0x00,0x00,0x00,0x00,0x00,0x00, // !
      0x00,0x03,0x00,0x03,0x00,0x00,0x00,0x00, // "
      0x0a,0x1f,0x0a,0x1f,0x0a,0x00,0x00,0x00, // #
      0x24,0x2a,0x2a,0x7f,0x2a,0x2a,0x12,0x00, // $
      0x00,0x47,0x25,0x17,0x08,0x74,0x52,0x71, // %
      0x00,0x36,0x49,0x49,0x49,0x41,0x41,0x38, // &
      0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00, // '
      0x00,0x3e,0x41,0x00,0x00,0x00,0x00,0x00, // (
      0x41,0x3e,0x00,0x00,0x00,0x00,0x00,0x00, // )
      0x04,0x15,0x0e,0x15,0x04,0x00,0x00,0x00, // *
      0x08,0x08,0x3e,0x08,0x08,0x00,0x00,0x00, // +
      0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00, // ,
      0x08,0x08,0x08,0x08,0x08,0x00,0x00,0x00, // -
      0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // .
      0x40,0x20,0x10,0x08,0x04,0x02,0x01,0x00, // /
      0x00,0x3e,0x61,0x51,0x49,0x45,0x43,0x3e, // 0
      0x01,0x01,0x7e,0x00,0x00,0x00,0x00,0x00, // 1
      0x00,0x71,0x49,0x49,0x49,0x49,0x49,0x46, // 2
      0x41,0x49,0x49,0x49,0x49,0x49,0x36,0x00, // 3
      0x00,0x0f,0x10,0x10,0x10,0x10,0x10,0x7f, // 4
      0x00,0x4f,0x49,0x49,0x49,0x49,0x49,0x31, // 5
      0x00,0x3e,0x49,0x49,0x49,0x49,0x49,0x30, // 6
      0x01,0x01,0x01,0x01,0x01,0x01,0x7e,0x00, // 7
      0x00,0x36,0x49,0x49,0x49,0x49,0x49,0x36, // 8
      0x00,0x06,0x49,0x49,0x49,0x49,0x49,0x3e, // 9
      0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // :
      0x40,0x34,0x00,0x00,0x00,0x00,0x00,0x00, // ;
      0x08,0x14,0x22,0x00,0x00,0x00,0x00,0x00, // <
      0x14,0x14,0x14,0x14,0x14,0x00,0x00,0x00, // =
      0x22,0x14,0x08,0x00,0x00,0x00,0x00,0x00, // >
      0x00,0x06,0x01,0x01,0x59,0x09,0x09,0x06, // ?
      0x00,0x3e,0x41,0x5d,0x55,0x5d,0x51,0x5e, // @
      0x00,0x7e,0x01,0x09,0x09,0x09,0x09,0x7e, // A
      0x00,0x7f,0x41,0x49,0x49,0x49,0x49,0x36, // B
      0x00,0x3e,0x41,0x41,0x41,0x41,0x41,0x22, // C
      0x00,0x7f,0x41,0x41,0x41,0x41,0x41,0x3e, // D
      0x00,0x3e,0x49,0x49,0x49,0x49,0x49,0x41, // E
      0x00,0x7e,0x09,0x09,0x09,0x09,0x09,0x01, // F
      0x00,0x3e,0x41,0x49,0x49,0x49,0x49,0x79, // G
      0x00,0x7f,0x08,0x08,0x08,0x08,0x08,0x7f, // H
      0x00,0x7f,0x00,0x00,0x00,0x00,0x00,0x00, // I
      0x00,0x38,0x40,0x40,0x41,0x41,0x41,0x3f, // J
      0x00,0x7f,0x08,0x08,0x08,0x0c,0x0a,0x71, // K
      0x00,0x3f,0x40,0x40,0x40,0x40,0x40,0x40, // L
      0x00,0x7e,0x01,0x01,0x7e,0x01,0x01,0x7e, // M
      0x00,0x7e,0x01,0x01,0x3e,0x40,0x40,0x3f, // N
      0x00,0x3e,0x41,0x41,0x41,0x41,0x41,0x3e, // O
      0x00,0x7e,0x09,0x09,0x09,0x09,0x09,0x06, // P
      0x00,0x3e,0x41,0x41,0x71,0x51,0x51,0x7e, // Q
      0x00,0x7e,0x01,0x31,0x49,0x49,0x49,0x46, // R
      0x00,0x46,0x49,0x49,0x49,0x49,0x49,0x31, // S
      0x01,0x01,0x01,0x7f,0x01,0x01,0x01,0x00, // T
      0x00,0x3f,0x40,0x40,0x40,0x40,0x40,0x3f, // U
      0x00,0x0f,0x10,0x20,0x40,0x20,0x10,0x0f, // V
      0x00,0x3f,0x40,0x40,0x3f,0x40,0x40,0x3f, // W
      0x00,0x63,0x14,0x08,0x08,0x08,0x14,0x63, // X
      0x00,0x07,0x08,0x08,0x78,0x08,0x08,0x07, // Y
      0x00,0x71,0x49,0x49,0x49,0x49,0x49,0x47, // Z
      0x00,0x7f,0x41,0x00,0x00,0x00,0x00,0x00, // [
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // "\"
      0x41,0x7f,0x00,0x00,0x00,0x00,0x00,0x00, // ]
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ^
      0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00, // _
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // `
      0x00,0x7e,0x01,0x09,0x09,0x09,0x09,0x7e, // A
      0x00,0x7f,0x41,0x49,0x49,0x49,0x49,0x36, // B
      0x00,0x3e,0x41,0x41,0x41,0x41,0x41,0x22, // C
      0x00,0x7f,0x41,0x41,0x41,0x41,0x41,0x3e, // D
      0x00,0x3e,0x49,0x49,0x49,0x49,0x49,0x41, // E
      0x00,0x7e,0x09,0x09,0x09,0x09,0x09,0x01, // F
      0x00,0x3e,0x41,0x49,0x49,0x49,0x49,0x79, // G
      0x00,0x7f,0x08,0x08,0x08,0x08,0x08,0x7f, // H
      0x00,0x7f,0x00,0x00,0x00,0x00,0x00,0x00, // I
      0x00,0x38,0x40,0x40,0x41,0x41,0x41,0x3f, // J
      0x00,0x7f,0x08,0x08,0x08,0x0c,0x0a,0x71, // K
      0x00,0x3f,0x40,0x40,0x40,0x40,0x40,0x40, // L
      0x00,0x7e,0x01,0x01,0x7e,0x01,0x01,0x7e, // M
      0x00,0x7e,0x01,0x01,0x3e...
    Read more »

View all 2 project logs

Enjoy this project?

Share

Discussions

Eric Hertz wrote 02/11/2017 at 07:10 point

I've had that same line-of-thought for some time... Trying to figure out how to do drawings in normal Y-T 'scoping. 

Nice and easy to comprehend solution!

And cool video showing/explaining it!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates