Tutorial on Adding a New Profile - IanSB/RGBtoHDMI GitHub Wiki

Home

:warning: Under Construction

Using the Create Custom Profile Menu

Unlike many general purpose converters, RGBtoHDMI needs to know some details about the video source in order to produce the very high quality results with integer scaling so you first need to do some research about the computer you intend to use with it.

You will need to know at least some of the following:

  1. The pixel resolution of the computer video output. (If it has multiple resolutions you need the highest one.
    If the computer has a graphics resolution such as 320x200 or 640x480 then use that. If the computer is text only then you need to know the text resolution such as 80x25 plus the font resolution such as 7x8 so the pixel resolution will be 80x7 = 560 and 25x8 = 200.
  2. The pixel clock frequency. This will usually be the frequency of one of the crystals on the motherboard/video card or a half or quarter of that value.
  3. The number of clock cycles per line (Line Length).
    This is more difficult to determine but may be documented somewhere. If you already know the pixel clock frequency then you don't need to know this.

It is possible to create a profile without knowing the pixel clock frequency or line length values as the correct settings can be determined visually but knowing at least one makes the process much easier.

First select one of the Base Profiles or an existing profile for another computer that is similar to your computer.
e.g. if your computer has a non-standard CGA implementation then use the CGA profile as your base.
Then fill the screen of the computer with alternate vertical lines of black and white pixels or the letter 'M' or 'W' or similar fine detail.

Then select the "Create Custom Profile" Menu.
images/reference/custom.png

You may be prompted to anayse the sync pulses and you should press menu to confirm that.
Note that you won't be able to enter the menu unless valid sync pulses are detected.
If you are setting up an analog source you must first set the DAC levels for the sync pulses and video to ensure they are detected.

Upon entering the menu for the first time, select "Analyse Timing" which should make an initial attempt at setting some parameters and then enter the Pixel Width and Pixel Height of your Computer. When you set the Pixel Width, the Line Length setting will be clipped to be between 110% and 175% of that value as that is a sensible range and that will subsequently affect the pixel clock as well based on the measured Hsync timing.

If you know either the pixel clock frequency or the number of Clock Cycles per line (Line Length) enter one of those values. When you alter one of these settings the other one will automatically be adjusted based on the Hsync timing.

If the settings are correct you should get a clean image but there is some chance you will get noise all across the screen which indicates that the sampling phase is incorrect so run an Auto Calibration to try to fix that. If you have a completely noise free display then it is likely that all settings are correct. If you have one or two columns of noise across the screen then the Line Length setting will need to be adjusted plus or minus by a very small amount.

If you don't know the clock frequency or line length then adjust the line length until all columns of noise have disappeared or noise appears across the width of the screen. (Confirm that such noise cleans up when selecting Auto Calibration). You will get a warning at the top of the screen if you adjust the line length outside of the sensible range mentioned above which is is determined by the pixel resolution and measured sync timing. You should be looking for a transition from one column of noise to no noise (an adjustment of one either side of the correct value will result in one column of noise). If the transition is from one column of noise to all noise then run the auto calibration to clean that up.

This shows typical results using a screen full of the letter M:

Line length value set incorrectly showing many columns of noise:

images/reference/M-1057.png

Line length value 'off by one' showing one column of noise:

images/reference/M-1025.png

Line length value set correctly but sampling phase calibration set incorrectly:

images/reference/M-1024-cal.png

Line length value and sampling phase calibration set correctly:

images/reference/M-1024.png

Finally use the H and V Offset to centre the image and run a final Auto Calibration.

After this you should have a usable starting point for a profile but it may require some fine tuning in the geometry and sampling menus to further optimise the profile.
You can save up to 10 custom profiles by selecting the custom profile number 0-9 and using the "Save Custom Profile" option. This will save your profile under /Profiles/[CPLD FOLDER]/_Custom/ If you made any further tweaks to your new profile and saved them using the "Save Configuration" option then the profile will be in:
/Saved_Profiles/[CPLD FOLDER]/_Custom/ instead with the unmodified version in the folder above.

Please submit any new profiles you have created for inclusion in future releases by using the Issues tab

Optimising settings in the Geometry menu

Most values are given sensible defaults by the above Create Custom Profile Menu but you can further optimise them if required.

The approximate pixel aspect ratio should be entered in H and V pixel aspect as this is used with integer scaling (it has no effect in the 'Fill' scaling modes). If you don't know the aspect or are unsure put 0 for both values which will ignore the setting and fill the screen as much as possible with the source. Note this value is an approximation, not necessarily the exact pixel aspect. If the pixels look roughly square, use 1:1, if they look roughly twice as high as wide use 1:2 etc.
e.g. The real aspect ratio of BBC micro pixels is approx 59:128 but this value could not be used for sensible integer scaling so 1:2 is a close approximation.
Note that many aspect ratio settings will be impossible to display e.g. 8:1 and such invalid combinations will be ignored and it will default to filling the screen.
When you adjust the aspect ratio values some helper info is displayed at the top of the screen which shows the actual aspect ratio in use at the moment. If that differs from the manual setting it means that the setting is invalid or set to 0.
Also the values are relative, not absolute so 1:1, 2:2, 3:3, 4:4 etc are all treated as 1:1. If you have set the H & V values to 0 and the display looks correct you can adjust the settings to match the helper values.

Max V Height should be set to the maximum number of lines for the video standard. e.g. 288 for PAL, 240 for NTSC
Max H Width should be set to the Max V Height multiplied by the screen aspect ratio and then divided by the pixel aspect ratio

e.g. for a BBC micro the screen aspect ratio is 4:3 (4/3) and the pixel aspect ratio is 1:2 (1/2) so that would be (288 * 4/3) / (1/2) = 768

Note the Max H & V values can be adjusted to suit as they control the maximum amount of border captured around the computer's pixel display area but the above gives a suitable starting point.

Similarly, the Min H & V values can be adjusted. e.g if the computer has a coloured border you can increase the Min H & V values by a few pixels to ensure that at least some border is always captured as part of the image.

Once these initial values have been setup, go to the "Setup Mode" at the top of the Geometry Menu and select "Set Min/Offset". The border will change colour to indicate the minimum area and you should adjust the H offset and V offset until the video source in centred in the border area.
Note: The horizontal adjustment is only to the nearest 4 pixels so you may not get a perfectly aligned result but you can make the final fine adjustment later in the Sampling menu.

If you want to visually adjust the Min H and V settings, first change the Setup Mode line at the top to "Set Min/Offset" which will show a coloured border around the min area.
If you want to visually adjust the Max H and V settings, first change the Setup Mode line at the top to "Set Maximum" which will show a coloured border around the max area.

The FB size setting can be adjusted according to the following:

If the horizontal resolution is less than 400 then use Double Width
If the vertical resolution is less than 288 the use Double Height

This setting causes captured pixels to be written twice horizontally, vertically or both into a double sized buffer. This setting reduces the softness of non-integer scaled frame buffers as there is less difference between the frame buffer size and the screen size so less interpolation is needed.
Also if you want to use scanlines then double height must be enabled.

Other geometry settings:
FB Bits/Pixel should be left on 8
Clock Tolerance should be left on 5000
V Sync Type should generally be left on "Auto"
Video Type should be left on "Progressive"

If all the values mentioned above are correct, that should be all that is required in the geometry menu.

Setting up the Sampling Menu

The sampling menu will vary depending on which CPLD is running and whether you have the analog interface installed.

The analog and TTL RGB sampling menu have the following:

Setup Mode: - should be changed when manually setting the delay (see below)

Sampling Phase - This can be manually adjusted to set the sampling point which eliminates noise in the image.
Half - Also part of the noise elimination setup
Phase A-F - Extra offsets for teletext mode only (will not be present in other modes)
All of the above are normally set automatically when using the "Auto Calibrate Video Sampling" option on the main menu.
The Clock Multiplier setting determines the ratio between the internal clock and the pixel clock and should normally be set to x8

The Pixel H Offset setting can be used to fine tune the horizontal pixel position to get the screen centred exactly. This is automatically set when using "Auto Calibrate Video Sampling" with the BBC micro but will have to be set manually for all other micros. Note this setting is important for the In Band Signalling option. When manually adjusting this setting, you can change the "Setup Mode" to "Set Delay" which reduces the screen capture area to the minimum to make adjustment easier.

Sync Edge specifies which edge of the hsync pulse is used for timing. After changing this setting you will need to adjust the H Offset in geomrtry to compensate for the video shift

Sync on G/V function when "On" uses the Vsync input as the sync source instead of the main sync input so will lose sync if there is no signal present on that input

The Sample mode should be set at the appropriate bit depth for the computer.

The above is the entire menu when in RGB TTL mode

When The Analog Interface is added, the following additional options are available:

75R Termination: Sets whether all 3 RGB inputs are high impedance or 75 Ohm terminated. G-coupling: Selects whether the G input is DC coupled or AC coupled with clamping. Generally speaking, the AC coupling is only useful in YUV mode so you should always use DC coupling for RGB. The termination setting depends on the connection. If you are using a normal 1V Scart type signal you should enable termination. If you are using a 5V TTL type source or are picking up signals internally from the computer then you should use high impedance.

The remaining settings are the DACs A-G which set the reference voltages for detecting the appropriate RGB and sync levels. These levels vary from 0-255 and a value of 0 = 0V and a value of 255 = 3.3V so if you have a rough idea of the signal levels being fed into the converter you can setup their initial values.

The first one to setup would be DAC-F: Sync which should be adjusted until you have a locked picture. Then setup G Hi and RB Hi with the highest level then G Lo and RB lo with the lower level. G/V Sync should normally be left on 255 and G Clamp should normally be left on 0

In YUV mode, the sampling menu is as follows:
Setup mode - same as above to help setting the delay
Offset - same as above to set the sampling point - normally set automatically when using the "Auto Calibrate Video Sampling" option
Filter Y - Enables simple noise reduction on the Y input
Filter UV - Enables simple noise reduction on the U & V inputs
Subsample UV - should be enabled when capturing 6847 based video sources only.
PAL Switch - Inverts the V signal on alternate lines and currently only needed for the Spectrum 48K YUV source.
Sync Edge - Determines whether timing is taken from the leading or trailing edge of the sync pulse. The default is trailing edge and you should only try leading edge if you get pixel noise which can't be eliminated.
Clamp Type - Sets the type of clamp to sync tip or back porch. Back porch is the best option but sometimes can't be used if there is the back porch isn't at black level, in which case sync tip should be used. Examples of computers where back porch can't be used are ZX80/81, UK101 and Ohio superboard. If using back porch, usually select the Back Porch Auto option.
Delay - sets the fine pixel position same as RGB above
Sync on G/V - When "On" enables the Vsync input as an additional analog level for the Y Input.
75R Termination - Same as RGB above Y Coupling - Same as RGB above except that AC mode with clamp is more likely to be used.
DACs A-G set the thresholds for Sync, Y and UV as above. Also sets the clamp level.

AC mode (with clamp) generally only needs to be used if the Y source is already AC coupled or if it has a lot of mains hum. It may be useful to setup in DC mode first and then select AC mode, adjusting the Y Clamp level until you get the same picture as DC mode.

Once you have created a working profile, use the save configuration option to save it. If you want it to appear as a correctly named profile in the default profiles, remove the SD card from the Pi, put it in a computer and browse to the /Saved_Profiles folder and then into the appropriate sub-folder which will vary depending on the hardware/interface configuration. Rename your saved profile to an appropriate name and then move it to the identical sub-folder in the /Profiles folder instead. After rebooting the Pi, your named profile should appear in the profiles list.

If you have multiple profiles for a particular computer you can use a sub-folder instead of individual files in the main folder and put the multiple profiles in that sub-folder. The software should automatically select the correct profile corresponding to the source timing. (see examples in the profiles folder on the SD card). This is used to switch between PC profiles and also to select 50Hz/60Hz profiles.