Visual Basic 6.0 facebook page celebrates today 10 thousand real programmers !

# Visual Basic 6.0 - Superior Code awards (2014 - 2024)

## Saturday, December 10, 2016

## Friday, November 18, 2016

### Bezier, data points approximated by a polynomial made in VB6 (B-Spline, C spline, T-Spline)

*Automated translation from Italian*

The coordinates of the points to be interpolated or approximated may be changed to:

1) selecting, with the mouse cursor, the point to move and dragging it to the desired position.

2) Selecting, in the table, the coordinate to edit and write the new value in the Text box. Clicking an 'other box or by pressing the' Enter to confirm the new value; the Escape key restores the previous value.

3) Import a data file, generated by an 'other application with the menu command "Curve / Read to be interpolated" File of points.

The data must be organized as:

Xi (0), Yi (0)

Xi (1), Yi (1)

...., ....

Xi (NPI-1), Yi (NPI-1)

Coordinates, calculated, of the points of the spline curve can be saved to file with the menu command "Curve / Save the curve to File"; the data format will be ':

Xc (0), Yc (0)

Xc (1), Yc (1)

...., ....

Xc (NPC-1), YC (NPC-1)

NPI and NPCs are, respectively, the number of points to be interpolated and the number of points on which the spline is calculated. The default values can be changed by writing in the "Curve Parameters" boxes.

The points, calculated, the spline curve can be highlighted by ticking the 'appropriate

box at the top, to the right on the graph.

The graph can 'scale be changed by changing the values in the "Graph Scale" boxes.

When you import points to be interpolated from a file, the values of NPI and the "Scale the graph will be updated automatically."

**Bezier:**

The data points are approximated with a polynomial of Bernstein.

**B-Spline:**

The NK value determines the number of nodes of the approximating curve:

NK = 2 -> line segments.

NK = 3 -> quadratic curves.

... ..................

NK = NPI -> Bezier splines.

**C spline:**

The data points are interpolated by a cubic spline.

**T-Spline:**

The data points are interpolated by a spline at an exponential voltage.

VZ parameter allows you to choose the tension of the curve: larger values of VZ flatten the curve.

## Wednesday, November 2, 2016

### Advanced Cell Flow in VB6

The main features of CellFlow are:

-Freeware open source (

-It can do any number of dimensions: 1, 2 and 3 dimensions, but also (just for fun) 4 and higher.

-It does an animation as it calculates.

-It works as a dynamical direct numerical simulation: With compressible flow, in explicit time dependence.

-Input files generated by a spreadsheet.

-Models pressures, flows, temperatures, and chemical species.

-Also suitable for acoustic simulation, and for simulation of aero acoustics (eg whistles)

To be fair, I can think of a few drawbacks:

-Only (topologically) rectangular grids. But cells need not be equal in size.

-No implicit turbulence model is implemented. But if you use a fine enough grid, you get turbulence explicitly.

Both of these drawbacks can of course be addressed. Maybe I will work on it if I have time.

Here are some pictures I generated for a ball in a channel, in 2D, 3D, and 4D.

2D, 3D and 4D velocity plots for an n-dimensional ball in a channel.

For 2D, this gives the well known "von Karman vortex street".

The 3D and 4D pictures are of course cross sections.

Source:

http://westy31.home.xs4all.nl/CellFlow/CellFlow.html

-Freeware open source (

**Download VB6 source code**)-It can do any number of dimensions: 1, 2 and 3 dimensions, but also (just for fun) 4 and higher.

-It does an animation as it calculates.

-It works as a dynamical direct numerical simulation: With compressible flow, in explicit time dependence.

-Input files generated by a spreadsheet.

-Models pressures, flows, temperatures, and chemical species.

-Also suitable for acoustic simulation, and for simulation of aero acoustics (eg whistles)

To be fair, I can think of a few drawbacks:

-Only (topologically) rectangular grids. But cells need not be equal in size.

-No implicit turbulence model is implemented. But if you use a fine enough grid, you get turbulence explicitly.

Both of these drawbacks can of course be addressed. Maybe I will work on it if I have time.

Here are some pictures I generated for a ball in a channel, in 2D, 3D, and 4D.

2D, 3D and 4D velocity plots for an n-dimensional ball in a channel.

For 2D, this gives the well known "von Karman vortex street".

The 3D and 4D pictures are of course cross sections.

Source:

http://westy31.home.xs4all.nl/CellFlow/CellFlow.html

## Wednesday, October 19, 2016

## Thursday, October 6, 2016

## Thursday, September 8, 2016

### SigGen Ver. 3.1 (Visual Basic 6)

Digital Signal Generator for Sound Cards. Sine, squared (variable duty cycle), triangular (variable symmetry), ramp, white and pink noise wave forms are included with continuous, burst, linear and logarithmic sweep generation modes. It is also possible to generate complex wave forms by synthesizing them on the screen with the mouse pointer or by reading an arbitrary function Y = F(X) from an external .txt file. Generatore di segnali, a due canali indipendenti, per la scheda audio. Genera forme d' onda sinusoidali, quadre, triangolari, a rampa, rumore bianco e rosa nei modi continuo, ad impulsi ed a spazzolamento di frequenza lineare e logaritmico. E' anche possibile generare complesse forme d' onda, disegnandole direttamente sullo schermo con il puntatore del mouse.

Siggen Ver. 3.1

**Multiplexer compensation**

MUX clearing procedure:

• Generating, on both channels, a sinusoidal signal of 1 kHz and of amplitude equal to 1 Neck, p by carrying out, on the generator, the settings:

Wave form Ch1 = Ch2 = Sine Wave form

Generator mode Ch1 = Ch2 Jan. mode = Run

Start Freq. Ch1 = Start Freq. Ch2 = 1000

Start Amp. Ch1 = Start Amp. Ch2 = 1

• With the 'help of an oscilloscope to measure the phase difference between the two channels and adjust the coefficient of MUX compensation so that this difference is annulled.

Press the [Apply] button, after each change of values, in order to assess the 'effect of the change.

If the 'oscilloscope allows measures used in X-Y, adjust the coefficient of MUX compensation so that the screen is drawn only one segment; the design of an ellipse indicates a residual phase error.

I can not exclude that for some sound card models the coefficient is unnecessary (e.g., for the Realtek HD Audio output should be Cm = 0 s) or should even be negative.

The [Apply] button using the coefficient calculated only in the current measurement session; [OK] button, use the coefficient in the current session and saves it in the INI file to be used in future sessions.

**The calibration coefficient KCal**

calibration procedure KCal:

• Generate a sinusoidal signal of 1 kHz and amplitude equal to 1 Neck, p performing on the generator settings:

Sine wave form =

Generator mode = Run

Start Freq. = 1000

Start Amp. = 1

• Adjust the calibration coefficient to obtain, in output from the sound card, an AC voltage of 0707 V measured with true rms voltmeter.

Using an oscilloscope, you should measure 2 V peak-peak.

Press the [Apply] button, after each change of values, in order to assess the 'effect of the change.

If the selected sound card were to reverse the sign of the output voltage (like 'my Sound Blaster Live!) Use a negative calibration coefficient.

The [Apply] button using the coefficients set only in the current measurement session; [OK] button using the coefficients set in the current session and saves them in the INI file to be used in future sessions.

##
**General notes**

• In many of the instrument boxes setting values can be written / edited directly: in this case, if the box were to take yellow, confirm the new value with the Enter button.

• Many of the controls are, like help text (ToolTip), which correlates to the primary or 'indication of the possibilities: e.g. the boxes of the [Frequency range] have framework, such as help text, the value of the period corresponding to the selected frequency and number of samples generated for each period (resolution of the d 'waveform); buttons [Square] and [Triang.] have the values of "Duty cycle", the symmetry and the 'indication of how to change them.

• If the buffers filling time exceeds the allowed maximum of 400 ms, the signal generation hangs with box [Buffer filling time: colored] in red. In this case the stop signal generation and try again with a lower sampling frequency.

• Under [Amplitude range] in the [Start Amp:] and [Stop Amp:] have the values written in red if the product KCal (see Technical information) for the currently set value is greater than 32767 or less than -32767 (the allowed limits the resolution to 16 bits) with consequent damages "clipping" of the d 'generated waveform.

• There are two ways of generating the signals, with and without the 'use of "callback", selected with the menu item [Settings], [the generator parameters].

The "callback" technique, although more efficient in terms of use of the CPU (and preferable, if possible resources), can be a source of problems on some PCs (generator that does not start, that quits unexpectedly, etc .. .) in this case, uncheck the [Generation via Callback] in the form of [siggen Settings].

Note to users of sources in VB6: if the "callback" should never be used would become possible to compile the program in "Native Code" instead of "P-Code" (see document q198607.pdf) decreasing, thus, the time required the filling of the buffers.

###
**Notes on "Graphical wave form constructor**

• To modify and use the form d 'wave summarized graphically must select the button [graphical wave form] of the [Wave form] framework.

• The nodes for the 'setting of the d' wave (red squares form) can be moved with the mouse cursor, hold down the left button.

The curve drawn in yellow is the one corresponding to the sampling instants and is derived, by interpolation, from that set (red curve).

• The true period of d 'generated waveform is equal to the integer multiple of' sampling interval of Ts (Ts = 1 / Fs Fs = sampling frequency) closer to the required value for the period; the true values of the period, frequency and number of samples used are shown, such as help text, the [Wave Period] box.

For reasons of resolution and speed of calculation, the value of settable period is between 10 and 16000 times the sampling time Ts e.g., if Fs is 8000 Hz the 'permissible interval will be 1.25 ms to 2 s; If Fs is 48000 Hz l 'operational range will be from 0.2083 ms to 0333 s.

The [1 / F1] sets, in the [Wave Period], the value of the period corresponding to the frequency value present in the [Start Freq. F1].

• The box [Norm], when selected, requires the absolute maximum value of the interpolated curve to take on the value 1.

L 'amplitude of the curve drawn by the yellow signal, before being sent to' generator output, is multiplied by the value in the [Start Amp] box.

• The interpolated signals # 1 (left channel) and channel # 2 (right) are designed taking into account the request phase.

• The interpolated # 1 (left channel) signal is already corrected drawn from the multiplexer delay time (see technical note).

• From version 2.3 you can save / read, in .txt format, the position of the graph nodes for further processing by external applications (e.g., Excel, NotePad, etc ...). To access the menu Save / Read of 'graphical wave use the button with the' disk icon, right below the graph.

The file format is:

X0, Y0

......

Xi, Yi

......

Xn, Yn

and it describes the graph of a period of d 'waveform as Y = F (X).

X must be distinct and in ascending order.

Xn is the 'x-coordinate of the first node of the next period and will, therefore, Y0 = Yn.

The period Xn - X0 of 'wave described in the file is, during reading, made to coincide with the period currently set in the [Wave Period], allowing it to use for the X, in the phase of construction of the graph, an arbitrary scale any .

It may be convenient, in the phase of construction of the graph, define more nodes in the sections where the curve F (X) has strong variations or discontinuities and less nodes in the sections where the curve is sufficiently straight (see example file Cardiac_R.txt) . The X values will not be, therefore, equally spaced, and will therefore be necessary to use interpolation modes [P.W. Linear] or [Cubic Spline]; with l 'interpolation type [Fourier] the values of X will, however, be redistributed so monospaced on' interval X0 -> Xn.

**Technical information**

• The values sent to output channels are calibrated (using the multiplication coefficient KCal) to have a voltage output from the sound card (connector -> speakers) of 0.7071 Vrms in correspondence to the generation of a sinusoidal signal of 1 Vu, eg of 1 kHz; the cursor of the Wave out volume, on the Playback Panel, should be to the maximum and to balance the center.

Other sound card models, different from my Sound Blaster Live !, may require different calibration coefficients.

The calibration coefficient was found experimentally with the 'help of a Tektronix oscilloscope 468 and a multimeter Tektronix TX1 True RMS. The effective value of 0.7071 (1 / Sqr (2)) corresponds to a sinusoidal signal, the 1 V peak value; if read with an oscilloscope, this signal should have a peak-to-peak value of 2 V.

If your sound card used should reverse the sign of the output voltage (how does my Sound Blaster Live!), Use a negative calibration coefficient (check with an oscilloscope).

The calibration coefficient KCal can be changed through the menu [Settings / generator parameters].

Read the help files Calibrazione_KCal.rtf.

• With sound card SB Live! the passband (of the output channel to the speakers) at -3 dB goes from 1 Hz to 21.5 kHz; the output voltage, in the linear zone, is 6 Vpp.

I have, however, allowed the generation of much lower frequencies of 1 Hz because, if you read through the wave channel in the Recording panel, can start from 0 Hz (see AudioCardDSP project).

• With sound card SB Live !, the output signal from the channel # 2 (right) is delayed by about 1/48000 s compared to the channel # 1: evidently it is used only one D / A converter, alternately switched on the two channels.

This phenomenon, from version 2.1 onwards, it is offset by the 'use of CompMUX coefficient, editable in the recalled table from the [Settings / generator parameters]; I can not exclude that other sound card models the coefficient should be negative (or is even useless as, e.g., for the Realtek HD Audio output).

Read the help files Compensazione_MUX.rtf.

The compensation is made by adding a correction phase to the generated signals, except when it is used in the form d 'wave summarized graphically: in this case CompMux corrects the signal during the interpolation operations. The delay, however, does not appear on the signals sent to the Wave channel: in this case, set to zero the coefficient CompMUX.

Warnings.

• This project was developed using the "." as the decimal separator; although he tried to prevent possible problems due to 'use of "," I can not exclude that it remained some inconsistency.

In particular, could be a source of trouble reading, from SigGen.ini files (especially with Windows XP!), The calibration parameters (see the values assigned in LeggiParametri routine and subsequently observed with the [Settings / generator parameters] menu).

In case of malfunction due to this problem, try changing the regional settings on your PC and give me news of the "bugs" found.

• This version can not work in "Run" mode for more than (about) 13 hours continuous.

Instrumentation used for development and calibration.

• Digital Storage Oscilloscope, Tektronix 468.

• True RMS Multimeter, Tektronix TX1.

• DSP for Audio Card, AudioCardDSP 3.0 F. Languasco.

Bibliography.

• Theory and Application of Digital Signal Processing - L. Rabiner, B. Gold - Prentice-Hall Inc.

• Digital Signal Processing - W. Stanley - Reston Publishing Company Inc.

• Digital Time Series Analysis - R. Otnes, L. Enochson - John Wiley & Sons.

• Numerical Recipes in FORTRAN 77 - William H. Press.

• Electronic Measurements - Notes from the Turin Polytechnic courses.

Subscribe to:
Posts (Atom)