User avatar
HermannSW
Posts: 5298
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: VGA board arrived

Wed Mar 03, 2021 4:32 pm

On search for "memset()" that accepts wider than "char" I found "wmemset()" that fills array of "wchar_t".
Available on Pico, and "sizeof(wchar_t)" is 4.
Filling of complete framebuffer can be done simply with

Code: Select all

wmemset(framebuffer, 0xF800F800, FB_WIDTH*FB_HEIGHT/2);
instead of for loop:

Code: Select all

    for(uint16_t *p=framebuffer; p<framebuffer+FB_WIDTH*FB_HEIGHT; ++p)
        *p=0xF800;
[ 0xF800 is blue or PICO_SCANVIDEO_PIXEL_FROM_RGB8(0, 0, 255) ]


Up to now "line_x()" was "for loop" filling "uint16_t" pixels, can be sped up with single "wmemset()" and "set_pixel()" for odd length.
"fill_circle() can be rewritten to use only "line_x()" making it much faster as well.
https://hermann-sw.github.io/planar_graph_playground
https://stamm-wilbrandt.de/en#raspcatbt
https://github.com/Hermann-SW/memrun
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 5298
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: VGA board arrived

Sun Mar 07, 2021 7:06 pm

New VGA board has not arrived yet, and I wanted to try building VGA adapter myself.
I had 1KΩ resistors, but no 0.5/2/4/8KΩ resistors.
I did order 200 1KΩ SMD 1% resistors and tried to solder my first diy DAC (3 needed for RGB channels).
One DAC requires 2+1+2+4+8=17 "1001" 1KΩ resistors.

It worked, but was neither nice nor trusty for builing my own VGA adapter:
20210307_194740.15%.jpg
20210307_194740.15%.jpg
20210307_194740.15%.jpg (54.57 KiB) Viewed 1333 times
I will wait until new Pimoroni VGA demo board arrives (or buyzero.de Pico+(DVI) I ordered yesterday) for easyVGA work (will rename it to easyDisp, because it will work for VGA as well as DVI (HDMI)).

First I used multimeter to measure the sequences of 2/1/2/4/8 "1001" resistors I soldered.
(I did superglue the male headers to PCB after soldering, as stress relief)

Then I tried "pico/pico-examples/adc/hello_adc" for measuring the voltage at join of all 5 resistor sequences.
I did that with 5 pins connected to Pi400 using pigpio pigs.

Finally I did all measurements self-contained on the Pico.
This is modified hello_adc.c I used, that excercises all 2^5=32 possible digital input to diy DAC and measures voltage:

Code: Select all

#include <stdio.h>
#include "pico/stdlib.h"
#include "hardware/gpio.h"
#include "hardware/adc.h"

int main() {
    stdio_init_all();
    printf("ADC Example, measuring GPIO26\n");

    adc_init();

    // Make sure GPIO is high-impedance, no pullups etc
    adc_gpio_init(26);
    // Select ADC input 0 (GPIO26)
    adc_select_input(0);

    uint g[5]={18,19,20,21,22};

    for(uint i=0; i<5; ++i) { gpio_init(g[i]); gpio_set_dir(g[i], GPIO_OUT); }

    for(uint i=0; i<0x20; ++i)
    {
        for(uint j=0; j<5; ++j) { gpio_put(g[j], (i>>j) & 0x1); }

        // 12-bit conversion, assume max value == ADC_VREF == 3.3 V
        const float conversion_factor = 3.3f / (1 << 12);
        uint16_t result = adc_read();
        printf("%05b  Raw value: 0x%03x, voltage: %f V\n", i, result, result * conversion_factor);
        //sleep_ms(500);
    }
}

Code: Select all

þADC Example, measuring GPIO26
00000  Raw value: 0x00b, voltage: 0.008862 V
00001  Raw value: 0x095, voltage: 0.120044 V
00010  Raw value: 0x11c, voltage: 0.228809 V
00011  Raw value: 0x1a7, voltage: 0.340796 V
00100  Raw value: 0x224, voltage: 0.441504 V
00101  Raw value: 0x2ac, voltage: 0.551074 V
00110  Raw value: 0x331, voltage: 0.658228 V
00111  Raw value: 0x3bc, voltage: 0.770215 V
01000  Raw value: 0x433, voltage: 0.866089 V
01001  Raw value: 0x4c0, voltage: 0.979688 V

Code: Select all

01010  Raw value: 0x546, voltage: 1.087646 V
01011  Raw value: 0x5c9, voltage: 1.193188 V
01100  Raw value: 0x64a, voltage: 1.297119 V
01101  Raw value: 0x6dc, voltage: 1.414746 V
01110  Raw value: 0x765, voltage: 1.525122 V
01111  Raw value: 0x7f0, voltage: 1.637109 V
10000  Raw value: 0x822, voltage: 1.677393 V
10001  Raw value: 0x896, voltage: 1.770850 V
10010  Raw value: 0x92c, voltage: 1.891699 V
10011  Raw value: 0x9be, voltage: 2.009326 V
10100  Raw value: 0xa31, voltage: 2.101978 V

Code: Select all

10101  Raw value: 0xacc, voltage: 2.226856 V
10110  Raw value: 0xb4d, voltage: 2.330786 V
10111  Raw value: 0xbe0, voltage: 2.449219 V
11000  Raw value: 0xc62, voltage: 2.553955 V
11001  Raw value: 0xced, voltage: 2.665942 V
11010  Raw value: 0xd6d, voltage: 2.769067 V
11011  Raw value: 0xdfb, voltage: 2.883472 V
11100  Raw value: 0xe67, voltage: 2.970483 V
11101  Raw value: 0xef9, voltage: 3.088110 V
11110  Raw value: 0xf85, voltage: 3.200903 V
11111  Raw value: 0xfff, voltage: 3.299194 V
https://hermann-sw.github.io/planar_graph_playground
https://stamm-wilbrandt.de/en#raspcatbt
https://github.com/Hermann-SW/memrun
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

tuupola
Posts: 14
Joined: Tue Mar 02, 2021 9:03 pm

Re: VGA board arrived

Mon Mar 08, 2021 9:49 am

HermannSW wrote:
Wed Mar 03, 2021 4:32 pm
Up to now "line_x()" was "for loop" filling "uint16_t" pixels, can be sped up with single "wmemset()" and "set_pixel()" for odd length.
Just out of interest how much did this speed things up? The wmemset() implementation of newlib itself is a loop of incrementing a pointer and setting a value.
--
Mika Tuupola
https://www.appelsiini.net/

User avatar
HermannSW
Posts: 5298
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: VGA board arrived

Mon Mar 08, 2021 5:32 pm

tuupola wrote:
Mon Mar 08, 2021 9:49 am
HermannSW wrote:
Wed Mar 03, 2021 4:32 pm
Up to now "line_x()" was "for loop" filling "uint16_t" pixels, can be sped up with single "wmemset()" and "set_pixel()" for odd length.
Just out of interest how much did this speed things up? The wmemset() implementation of newlib itself is a loop of incrementing a pointer and setting a value.
I will have to measure the effect when having any working VGA/DVI adapter again.

I just built 2nd diy DAC, looks a bit uglier than the one from yesterday:
(you can see still wet superglue below front male header)
20210308_182431.15%.jpg
20210308_182431.15%.jpg
20210308_182431.15%.jpg (60.83 KiB) Viewed 1244 times

But test program from yesterday says it is working fine, in 0V..3.3V range:
2nd.diy.DAC.png
2nd.diy.DAC.png
2nd.diy.DAC.png (49.52 KiB) Viewed 1244 times
https://hermann-sw.github.io/planar_graph_playground
https://stamm-wilbrandt.de/en#raspcatbt
https://github.com/Hermann-SW/memrun
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 5298
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: VGA board arrived

Tue Mar 09, 2021 8:49 pm

Since 2nd diy DAC yesterday was not that bad, and test program surprisingly stated all is fine, I soldered 3rd DAC from 17 "1001" 1KΩ SMD resistors today on the free part of PCB from yesterday. Again test program said all is fine.

Then I took the VGA connector from my years ago DueVGA work. Most of the cables were already soldered (HSYN/VSYNC/ all GND connections). Only there was a single cable soldered to R and G and B, because I used DueVGA in monochrome mode in 2016 to achieve 1024x675 monochrome resolution with Arduino Due that has only 96KB RAM. I desoldered that cable, and soldered three cables to the joins of the three DACs I built. Then I connected everything to the Pico, compiled and flashed mandelbrot demo and ... no image on VGA monitor. This is the overall setup, 16MP photo:
https://stamm-wilbrandt.de/en/forum/20210309_213250.jpg
Scaled to 15% for forum attachment:
20210309_213250.15%.jpg
20210309_213250.15%.jpg
20210309_213250.15%.jpg (64.74 KiB) Viewed 1186 times

To get this to work, many tests are needed, easiest first, check whether I did not accidentially join pins of VGA connector that should be separate. Next see whether HSYNC/VSYNC signals are in place with oscilloscope, ...

I got notification that the "Pico+(DVI)" I ordered on Saturday will arrive tomorrow, and the Pimoroni pico demo board that I ordered as replacement for my broken board will arrive here soon as well. At least this night I will not start hardware debugging the setup.
https://hermann-sw.github.io/planar_graph_playground
https://stamm-wilbrandt.de/en#raspcatbt
https://github.com/Hermann-SW/memrun
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 5298
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: VGA board arrived

Fri Mar 12, 2021 3:11 pm

New Pimoroni pico demo (VGA) board arrived today (back left).
This time it took 9 day to ship from GB to DE, last time only 5 days.

Front left is the old board that did not work anymore, front right my diy VGA board that does not work (yet). And back right the Pico+(DVI) board that works fine:
20210312_141909.15%.jpg
20210312_141909.15%.jpg
20210312_141909.15%.jpg (65.59 KiB) Viewed 1132 times

I did simple test and flashed demo1 onto Pico and tried with new board, did not work. mandelbrot did not work either. Switched VGA monitor, did not work. Switched VGA cable, did not work. So I am pretty sure that my Pico has a problem, and after having fixed that, I will probably have two working Pimoroni demo boards.

I have another Pico with 2x17 headers soldered to bottom and 2x3 to top, for fitting into my favorite 17x10 mini breadboards. I won't touch that Pico. So I will solder 2x20 headers below the fresh Pico I have as well and see whether new (and old) VGA board will demo on VGA display.
https://hermann-sw.github.io/planar_graph_playground
https://stamm-wilbrandt.de/en#raspcatbt
https://github.com/Hermann-SW/memrun
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 5298
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: VGA board arrived

Fri Mar 12, 2021 7:32 pm

I don't know why the board last week did not work.
Today the new board did not work either.
I used the old Pico as well as the today soldered newly Pico with 2x20 headers to plug into Pico board.
So I thought what might have changed, and that was that I installed new pico-sdk last Monday.
So I removed pico-playground and synced it again.
And now flashing newly compiled sprite_demo on new pico demo board resulted in (partially) working display.
Why Partially? Because colors are a bit off, here smartphone photo:
20210312_182858.15%.jpg
20210312_182858.15%.jpg
20210312_182858.15%.jpg (40.51 KiB) Viewed 1107 times

This is photo of the old board (that is working again now), here colors are fine:
20210312_182835.15%.jpg
20210312_182835.15%.jpg
20210312_182835.15%.jpg (46.93 KiB) Viewed 1107 times

I switched both Picos between the two demo boards.
No changes, the new board wrong colors, the old board correct colors.

The switch proves that both Pico I soldered the 2x20 headers to do work correctly.
https://hermann-sw.github.io/planar_graph_playground
https://stamm-wilbrandt.de/en#raspcatbt
https://github.com/Hermann-SW/memrun
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

DarkElvenAngel
Posts: 2246
Joined: Tue Mar 20, 2018 9:53 pm

Re: VGA board arrived

Fri Mar 12, 2021 9:26 pm

Have you checked for a cold solder joint in the DAC? Looks like maybe the red DAC

Maybe try colour bars for a test. I have just got my boards yesterday I have to see if I have some header pins

User avatar
HermannSW
Posts: 5298
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: VGA board arrived

Fri Mar 12, 2021 10:57 pm

DarkElvenAngel wrote:
Fri Mar 12, 2021 9:26 pm
Have you checked for a cold solder joint in the DAC? Looks like maybe the red DAC
The DAC is inside the demo board PCB, I cannot look into.

Since both Picos show good display in one board and bad in the other, definitely the new board has the issue, not the Picos (I switched Picos between boards often).

I used the Picos pressed into the pico demo board sockets as far as possible until recently. Then I tried to slowly raise the Pico in the bad board, a bit on left socket, then a bit on the right. This is position where the bad board is working fine, nearly three millimeters header visible on one side, 2mm on the other:
20210312_233210.15%.jpg
20210312_233210.15%.jpg
20210312_233210.15%.jpg (23.46 KiB) Viewed 1048 times

Both boards are working with correct colors now, the worse board with Pico raised as described:
20210312_233852.15%.jpg
20210312_233852.15%.jpg
20210312_233852.15%.jpg (52.33 KiB) Viewed 1048 times

Maybe try colour bars for a test.
That is a good advice, I flashed "pico/pico-playground/build/scanvideo/test_pattern/test_pattern.uf2" and saw nice colors. Although the wrong colors are easier to spot on Ebon's head in sprite_demo ;-)
20210312_231424.15%.jpg
20210312_231424.15%.jpg
20210312_231424.15%.jpg (24.29 KiB) Viewed 1048 times
https://hermann-sw.github.io/planar_graph_playground
https://stamm-wilbrandt.de/en#raspcatbt
https://github.com/Hermann-SW/memrun
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

DarkElvenAngel
Posts: 2246
Joined: Tue Mar 20, 2018 9:53 pm

Re: VGA board arrived

Fri Mar 12, 2021 11:51 pm

Sounds like you have a bad socket connection. If you can replace the socket that should help. I'd try a different type than what's in there not all sockets are created equal.

At least with some creative positioning you got it working.

User avatar
HermannSW
Posts: 5298
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: VGA board arrived

Sat Mar 13, 2021 12:24 am

DarkElvenAngel wrote:
Fri Mar 12, 2021 11:51 pm
Sounds like you have a bad socket connection. If you can replace the socket that should help. I'd try a different type than what's in there not all sockets are created equal.

At least with some creative positioning you got it working.
I have no idea how to replace the female socket on Pimoroni demo board ...
https://shop.pimoroni.com/products/pimo ... -demo-base
pico_demo_board.jpg
pico_demo_board.jpg
pico_demo_board.jpg (88.61 KiB) Viewed 999 times
https://hermann-sw.github.io/planar_graph_playground
https://stamm-wilbrandt.de/en#raspcatbt
https://github.com/Hermann-SW/memrun
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

DarkElvenAngel
Posts: 2246
Joined: Tue Mar 20, 2018 9:53 pm

Re: VGA board arrived

Sat Mar 13, 2021 1:23 am

Oh it's surface mount I still haven't opened mine up. I still wonder if you have a cold solder joint. If you have an iron with a small enough tip could try to touch the legs up.

Or you could contact them and see about a replacement.

User avatar
HermannSW
Posts: 5298
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: VGA board arrived

Sat Mar 13, 2021 7:37 pm

I still have problems with the DVI sock colors, but VGA RGAB5515 are fine.
This simply code:

Code: Select all

    for(uint16_t *p=framebuffer; p<framebuffer+FB_WIDTH*FB_HEIGHT; ++p)
        *p=0xFFFF;

    for(int x=0; x<(1<<5); ++x)
      for(y=0; y<(1<<5); ++y)
      {
        set_color(8*x,8*y,0);
        set_pixel(100+x,136-y);
      }

    for(int x=0; x<(1<<5); ++x)
      for(y=0; y<(1<<5); ++y)
      {
        set_color(8*x,0,8*y);
        set_pixel(160+x,136-y);
      }

    for(int x=0; x<(1<<5); ++x)
      for(y=0; y<(1<<5); ++y)
      {
        set_color(0,8*x,8*y);
        set_pixel(220+x,136-y);
      }

    for(;;) {}
 

results in these RG/RB/GB squares:
vga.colors.png
vga.colors.png
vga.colors.png (128.03 KiB) Viewed 936 times
https://hermann-sw.github.io/planar_graph_playground
https://stamm-wilbrandt.de/en#raspcatbt
https://github.com/Hermann-SW/memrun
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

DarkElvenAngel
Posts: 2246
Joined: Tue Mar 20, 2018 9:53 pm

Re: VGA board arrived

Thu Apr 01, 2021 2:18 pm

HermannSW wrote:
Sat Mar 13, 2021 7:37 pm
I still have problems with the DVI sock colors, but VGA RGAB5515 are fine.
This simply code:

Code: Select all

    for(uint16_t *p=framebuffer; p<framebuffer+FB_WIDTH*FB_HEIGHT; ++p)
        *p=0xFFFF;

    for(int x=0; x<(1<<5); ++x)
      for(y=0; y<(1<<5); ++y)
      {
        set_color(8*x,8*y,0);
        set_pixel(100+x,136-y);
      }

    for(int x=0; x<(1<<5); ++x)
      for(y=0; y<(1<<5); ++y)
      {
        set_color(8*x,0,8*y);
        set_pixel(160+x,136-y);
      }

    for(int x=0; x<(1<<5); ++x)
      for(y=0; y<(1<<5); ++y)
      {
        set_color(0,8*x,8*y);
        set_pixel(220+x,136-y);
      }

    for(;;) {}
 

results in these RG/RB/GB squares:
vga.colors.png
I maybe missing it but do you have code for the how to take the framebuffer and get that rendering on VGA? I'm trying to work out how to do this.

User avatar
HermannSW
Posts: 5298
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: VGA board arrived

Fri Apr 02, 2021 11:22 pm

DarkElvenAngel wrote:
Thu Apr 01, 2021 2:18 pm
I maybe missing it but do you have code for the how to take the framebuffer and get that rendering on VGA? I'm trying to work out how to do this.
I just modified mandelbrot code and worked from there.
That code already does the display of framebuffer.
This did clear the whole framebuffer with white pixels:

Code: Select all

    for(uint16_t *p=framebuffer; p<framebuffer+FB_WIDTH*FB_HEIGHT; ++p)
        *p=0xFFFF;
I don't have the previous code anymore, it is gone with my dead Pi400 SD card.
I am working on building easyDraw library that works for VGA as well as DVI sock.
This time as standalone library with examples, in separate project directory.


P.S:
What remained from previous code is youtube video captured (code modified to work with Pico+(DVI) at that time):
https://www.youtube.com/watch?v=7TfnMNW3U6g
easyVga.jpg
easyVga.jpg
easyVga.jpg (85.3 KiB) Viewed 752 times
https://hermann-sw.github.io/planar_graph_playground
https://stamm-wilbrandt.de/en#raspcatbt
https://github.com/Hermann-SW/memrun
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

Return to “General”