Vector graphics using a pic and xy axis on my scope?

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
A project that I would like to embark on in the near future is to draw images on my scope using the xy axis input.

Drawing a straight line a given distance at a given location on a screen using a pic should not be too much of a challenge for me. Even drawing a square of a given size at a given location should not be too much of a challenge. A triangle off the top of my head might be a little more difficult.

What I am trying to wrap my head around is doing more complex images. Say a circle. Or better some text.

What I think would be really cool would be to simulate the old meteor game that was done in vector graphics. That has all kind of odd shapes that can change size.

How were these rendered onto the screen? I suppose the easy way would be to think of the screen as pixels and light up the appropriate pixel. But that does not seem very efficient. Foe example in true vector graphics tp draw a square I would just need 4 points no matter the size of the square. A equivalent raster or pixel image could take dozens, or even hundreds of data points to the same square.

So how is it done? If I had an imagine in mind , say a rock, I suppose I would have a database of all of the lines that make up that rock. So I guess that should not be too hard. But noe the rock has to roll and move.

And then there is text. There are font tools out there that convert characters to bits so that can be displayed on an LED array. How would you do that for vector fonts? Or just pain painstakingly design each character?
 

Sensacell

Joined Jun 19, 2012
3,432
Look at laser vector graphics for inspiration.

The comments below assume an analog CRT:

Images get dimmer the larger and more complex they get.
Ringing and overshoot distort sharp edges.
High bandwidth is required for crisp imaging.

You need 2 fast DAC's and a blanking pulse. A third DAC might let you adjust the beam current (brightness) on the fly.

The images are created by slewing the beam through a series of points, (DAC values) the blanking pulse allows you to move the beam to another spot on the screen without smears.

The key is designing the image content to work well in vector format.
Raster scanning will probably look crappy unless you have very high resolution and high beam current to keep it from getting dim.
 

Ian Rogers

Joined Dec 12, 2012
1,136
The student art of electronics has these very details . Right at the end of the book after you have made the "Motorola" driven computer, they use an oscilloscope as a screen..
 

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
Look at laser vector graphics for inspiration.

The comments below assume an analog CRT:

Images get dimmer the larger and more complex they get.
Ringing and overshoot distort sharp edges.
High bandwidth is required for crisp imaging.

You need 2 fast DAC's and a blanking pulse. A third DAC might let you adjust the beam current (brightness) on the fly.

The images are created by slewing the beam through a series of points, (DAC values) the blanking pulse allows you to move the beam to another spot on the screen without smears.

The key is designing the image content to work well in vector format.
Raster scanning will probably look crappy unless you have very high resolution and high beam current to keep it from getting dim.
Well I thought I had the hardware part covered. :) So how would the brightness be adjusted wuth the DAC on an xy access input?
 

MrChips

Joined Oct 2, 2009
30,707
The classic Lunar Lander game was written in FOCAL (a computer language similar to BASIC) on a DEC PDP-8 minicomputer.
The first video version used a vector graphics display.
 

ebp

Joined Feb 8, 2018
2,332
If you draw the screen as pixels and light them up, then it is raster graphics, not vector.

One of the challenges with true vector graphics is phosphor persistence. Long persistence phosphors ease the refresh requirements. Oscilloscope phosphor persistence is usually short so a high refresh rate is required. This can be quite a challenge with complex images.

Be very careful. It is important to blank the beam if vector generation is stopped. Beam current usually needs to be rather high to get good images and if you quit generating vectors without blanking, the beam can damage the phosphor quite quickly. I've seen the inside of the faceplate glass of large and expensive CRT actually pitted because of this.
 

nsaspook

Joined Aug 27, 2009
13,079
A project that I would like to embark on in the near future is to draw images on my scope using the xy axis input.

Drawing a straight line a given distance at a given location on a screen using a pic should not be too much of a challenge for me. Even drawing a square of a given size at a given location should not be too much of a challenge. A triangle off the top of my head might be a little more difficult.

What I am trying to wrap my head around is doing more complex images. Say a circle. Or better some text.

What I think would be really cool would be to simulate the old meteor game that was done in vector graphics. That has all kind of odd shapes that can change size.

How were these rendered onto the screen? I suppose the easy way would be to think of the screen as pixels and light up the appropriate pixel. But that does not seem very efficient. Foe example in true vector graphics tp draw a square I would just need 4 points no matter the size of the square. A equivalent raster or pixel image could take dozens, or even hundreds of data points to the same square.

So how is it done? If I had an imagine in mind , say a rock, I suppose I would have a database of all of the lines that make up that rock. So I guess that should not be too hard. But noe the rock has to roll and move.

And then there is text. There are font tools out there that convert characters to bits so that can be displayed on an LED array. How would you do that for vector fonts? Or just pain painstakingly design each character?
Old vector hardware.
https://www.jmargolin.com/vgens/vgens.htm

The classic primitive vector graphics pipeline controller has a scan converter (vector generation) that takes a database ( like a linked list, 4 points for a square) of object geometry points and converts that into a list of line segments (with blanking or other characteristics) to be drawn on the screen continuously by a screen update process thread.

A good background book for theory is:
https://www.amazon.com/Computer-Graphics-Programming-Steven-Harrington/dp/0071004726

Yes, it's outdated but that's what you need here.

From my programming library.

A good but complex chip for this would be the PIC32MK series. They offer three 1 Msps 12-bit DAC's with DMA access to reduce the cpu requirements for screen updates.
http://ww1.microchip.com/downloads/en/DeviceDoc/60001327A.pdf
http://ww1.microchip.com/downloads/...ontrol- (GPMC)-Family-Datasheet-60001402E.pdf
 
Last edited:

jpanhalt

Joined Jan 18, 2008
11,087
Simple graphics like that can be done with an MCU and DAC by adjusting the intensity. Is your scope analog or digital? Basically, the horizontal traces and the turning point in vertical traces show up, but the vertical rise times are to narrow to show. I demo'ed that a few years ago with my new Rigol while I was practicing emulating lightning strikes. I can't find that actual demo, but will post something similar, if I can find it again.

Edit: Here you go:
upload_2018-12-26_17-48-16.png
 
Last edited:

jpanhalt

Joined Jan 18, 2008
11,087
Digital adds a little complexity because of memory/lag. I sent a repetitive signal and probably had persistence at default or low.
 

nsaspook

Joined Aug 27, 2009
13,079
A few vector XY demos to see how well digital scopes update with a RPI-3 (a pic could easily handle this but I already had the RPI running for kernel driver development.) sending the data via SPI output to a MCP4802 using a custom Linux DAQ driver for comedi .
IMG_20190102_125749.jpg
edit: update photo link

RPI with DAQ board mounted on back. The analog XY signal RC Integrator filter is on the perfboard.

A random line segment image with X and Y translations (16-bit position overflows causes the image to change as it moves.)

Code fragments
C:
//line generator
void dds_output(sampl_t *buf, int n)
{
    sampl_t *p = buf;
    static uint16_t poffset = 0, xoffset = 0;

    *p++ = 15 + xoffset;
    *p++ = 0 + poffset;
    *p++ = 15000 + xoffset;
    *p++ = 15000 + poffset;
    *p++ = 5000 + xoffset;
    *p++ = 2000 + poffset;
    *p++ = 1000 + xoffset;
    *p++ = 2500 + poffset;
    *p++ = 25000 + xoffset;
    *p++ = 25000 + poffset;
    *p++ = 0 + xoffset;
    *p++ = 36000 + poffset;
    poffset++;
    xoffset++;
}

// display loop
    while (1) {
        dds_output(data, BUF_LEN);
        n = BUF_LEN * sizeof(sampl_t);
        while (n > 0) {
            m = write(comedi_fileno(dev), (void *) data + (BUF_LEN * sizeof(sampl_t) - n), n);
            if (m < 0) {
                perror("write");
                exit(0);
            }
            if (options.verbose)
                printf("m=%d\n", m);
            n -= m;
        }
        total += BUF_LEN;
        //printf("%d\n",total);
    }
Phase shifting sine using DDS

Code fragments
C:
const uint8_t sine_wave[256] = {
    0x80, 0x83, 0x86, 0x89, 0x8C, 0x90, 0x93, 0x96,
    0x99, 0x9C, 0x9F, 0xA2, 0xA5, 0xA8, 0xAB, 0xAE,
    0xB1, 0xB3, 0xB6, 0xB9, 0xBC, 0xBF, 0xC1, 0xC4,
    0xC7, 0xC9, 0xCC, 0xCE, 0xD1, 0xD3, 0xD5, 0xD8,
    0xDA, 0xDC, 0xDE, 0xE0, 0xE2, 0xE4, 0xE6, 0xE8,
    0xEA, 0xEB, 0xED, 0xEF, 0xF0, 0xF1, 0xF3, 0xF4,
    0xF5, 0xF6, 0xF8, 0xF9, 0xFA, 0xFA, 0xFB, 0xFC,
    0xFD, 0xFD, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF,
    0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0xFD,
    0xFD, 0xFC, 0xFB, 0xFA, 0xFA, 0xF9, 0xF8, 0xF6,
    0xF5, 0xF4, 0xF3, 0xF1, 0xF0, 0xEF, 0xED, 0xEB,
    0xEA, 0xE8, 0xE6, 0xE4, 0xE2, 0xE0, 0xDE, 0xDC,
    0xDA, 0xD8, 0xD5, 0xD3, 0xD1, 0xCE, 0xCC, 0xC9,
    0xC7, 0xC4, 0xC1, 0xBF, 0xBC, 0xB9, 0xB6, 0xB3,
    0xB1, 0xAE, 0xAB, 0xA8, 0xA5, 0xA2, 0x9F, 0x9C,
    0x99, 0x96, 0x93, 0x90, 0x8C, 0x89, 0x86, 0x83,
    0x80, 0x7D, 0x7A, 0x77, 0x74, 0x70, 0x6D, 0x6A,
    0x67, 0x64, 0x61, 0x5E, 0x5B, 0x58, 0x55, 0x52,
    0x4F, 0x4D, 0x4A, 0x47, 0x44, 0x41, 0x3F, 0x3C,
    0x39, 0x37, 0x34, 0x32, 0x2F, 0x2D, 0x2B, 0x28,
    0x26, 0x24, 0x22, 0x20, 0x1E, 0x1C, 0x1A, 0x18,
    0x16, 0x15, 0x13, 0x11, 0x10, 0x0F, 0x0D, 0x0C,
    0x0B, 0x0A, 0x08, 0x07, 0x06, 0x06, 0x05, 0x04,
    0x03, 0x03, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01,
    0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03,
    0x03, 0x04, 0x05, 0x06, 0x06, 0x07, 0x08, 0x0A,
    0x0B, 0x0C, 0x0D, 0x0F, 0x10, 0x11, 0x13, 0x15,
    0x16, 0x18, 0x1A, 0x1C, 0x1E, 0x20, 0x22, 0x24,
    0x26, 0x28, 0x2B, 0x2D, 0x2F, 0x32, 0x34, 0x37,
    0x39, 0x3C, 0x3F, 0x41, 0x44, 0x47, 0x4A, 0x4D,
    0x4F, 0x52, 0x55, 0x58, 0x5B, 0x5E, 0x61, 0x64,
    0x67, 0x6A, 0x6D, 0x70, 0x74, 0x77, 0x7A, 0x7D
};

int main(int argc, char *argv[])
{
    int blink[3], flip[2] = {0, 0}, z = 0;
    int do_ao_only = TRUE;
    uint8_t i = 0, j = 75;

    if (do_ao_only) {
        if (init_dac(0.0, 25.0, FALSE) < 0) {
            printf("Missing Analog AO subdevice\n");
            return -1;
        }
        if (init_dio() < 0) {
            printf("Missing Digital subdevice(s)\n");
            return -1;
        }
        set_dio_output(0); // gpio 17

        while (TRUE) {
            set_dac_raw(0, sine_wave[255 - i++] << 4);
            set_dac_raw(1, sine_wave[255 - j++] << 4);
            if (j == 0)
                j++;
//            usleep(1);
        }
    }
}
 
Last edited:

402DF855

Joined Feb 9, 2013
271
I did something similar a couple of years ago, using an AVR and two PWM outputs with RC filters on each. Totally impressed the managers at the office, I drew the company logo on the scope and left it on display for people to see walking by. Initially I started the project just to test the XY capabilities of my old $200 scope.
 
Top