Author Topic: Can QBasic (MS Quick Basic) do Log operations?  (Read 2661 times)

0 Members and 1 Guest are viewing this topic.

Offline CaptDonTopic starter

  • Super Contributor
  • ***
  • Posts: 2356
  • Country: is
Can QBasic (MS Quick Basic) do Log operations?
« on: March 04, 2025, 07:03:59 pm »
I should know how to write this and I am dinking around with it. I want to add pairs of numbers expressed as dBm. For instance -5.19 + -1.55 = ?
I want to write a loop such as

Enter A in dBm
Enter B in dBm
Answer =
Hit Enter to do more.

The math needs to accept numbers both above and below 0 dBm.
I am not sure how to do Log in Qbasic or if it even can.

I do have a licensed copy of MatLab, perhaps that is the way to go?

Thanks for any insight!!!

« Last Edit: March 04, 2025, 07:06:12 pm by CaptDon »
Collector and repairer of vintage and not so vintage electronic gadgets and test equipment. What's the difference between a pizza and a musician? A pizza can feed a family of four!! Classically trained guitarist. Sound engineer.
 

Offline BrianHG

  • Super Contributor
  • ***
  • Posts: 8385
  • Country: ca
    • LinkedIn
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #1 on: March 04, 2025, 07:22:43 pm »
See here for 'freebasic' compiler commands.  They are usually compatible with QBasic:

https://www.freebasic.net/wiki/KeyPgLog
__________
Follow me for 3 Classic Fitness Playlist Songs from the '70s to 2010s, Delivered Every Other Day!
www.linkedin.com/in/brianhg-ocean-fitness www.facebook.com/profile.php?id=61573174078303
 
The following users thanked this post: CaptDon

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4997
  • Country: dk
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #2 on: March 04, 2025, 07:23:56 pm »
are you trying to make a joke?
 

Offline CaptDonTopic starter

  • Super Contributor
  • ***
  • Posts: 2356
  • Country: is
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #3 on: March 04, 2025, 07:48:36 pm »
No joke on my part. I have been supplied a hand written list of audio output levels from an active electronic crossover. The list looks like this,

Hz       Lo           Mid        Result
39       -0.14      -16.25
42.9    -0.34      -13.14
47.16  -0.67      -10.16
51.9    -1.23      -7.42
57.0    -2.07      -5.03
62.77  -3.40      -3.00
69       -5.19      -1.55
76       -7.52      -0.55
83.55  -10.23     0.0

In this example the crossover is set at 50Hz. The ideal design target is 0dBm plus or minus perhaps 1/2 to 1 dB. I have a full list and could convert to .csv or even .xls to perform the math. Or with a simple QBasic program I can finish his hand written list. What is going on of interest here is comparing two electronic crossovers, one of which seems to have a depression in output level from the total system occurring around the crossover points. We are trying to see it as represented by the combination of Lo + Mid expressed as dBm. The numbers I gave are from the relatively 'smooth' crossover. The numbers from the other unit don't look good. We are trying to see 'how bad is bad?'

Thanks all!!! Hope this explains it in more detail.

Collector and repairer of vintage and not so vintage electronic gadgets and test equipment. What's the difference between a pizza and a musician? A pizza can feed a family of four!! Classically trained guitarist. Sound engineer.
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 7570
  • Country: pl
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #4 on: March 04, 2025, 07:53:24 pm »
Doesn't F1 open built-in help?

A quick search says: log(x) and exp(x). Not sure if there are decimal versions, but you can do the math manually.
 
The following users thanked this post: CaptDon

Offline CaptDonTopic starter

  • Super Contributor
  • ***
  • Posts: 2356
  • Country: is
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #5 on: March 04, 2025, 07:59:07 pm »
It also occurred to me, since both physical crossovers are sitting on his bench I could build a resistor combiner (outputs are XLR with low impedance output stages) and sweep the unit which would also show any additional bumps or dips caused by unequal phase shift through the electronic filters. Hmmm??? Food for thought??
Collector and repairer of vintage and not so vintage electronic gadgets and test equipment. What's the difference between a pizza and a musician? A pizza can feed a family of four!! Classically trained guitarist. Sound engineer.
 

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4997
  • Country: dk
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #6 on: March 04, 2025, 07:59:47 pm »
Doesn't F1 open built-in help?

A quick search says: log(x) and exp(x). Not sure if there are decimal versions, but you can do the math manually.

adding dBs with dBs where it the log/exp needed? ;)
 

Online themadhippy

  • Super Contributor
  • ***
  • Posts: 3542
  • Country: gb
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #7 on: March 04, 2025, 08:37:50 pm »
Quote
I could build a resistor combiner (outputs are XLR with low impedance output stages) and sweep the unit which would also show any additional bumps or dips caused by unequal phase shift through the electronic filters
or feed it into something like  arta  and let that do the donkey work
 

Online BeBuLamar

  • Super Contributor
  • ***
  • Posts: 1585
  • Country: us
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #8 on: March 04, 2025, 08:49:58 pm »
If you're talking about QuickBasic 4.5 for DOS it does. Only Ln but that is enough
LOG function
■ Action

    Returns the natural logarithm of a numeric expression

■ Syntax

    LOG(n)

■ Remarks

    The numeric expression, n, must be greater than zero. The natural
    logarithm is the logarithm to the base e. The constant e is approximately
    equal to 2.718282.

    The LOG function calculates the natural logarithm with single-precision
    accuracy, unless the argument n is a double-precision value. In this case
    LOG is calculated with double-precision accuracy.

    You may calculate base-10 logarithms by dividing the natural logarithm of
    the number by the logarithm of 10. The following FUNCTION calculates
    base-10 logarithms:

    FUNCTION Log10(X) STATIC
        Log10=LOG(X)/LOG(10.#)
    END FUNCTION

■ Example

    The following example first prints the value of e and then prints the
    natural logarithms of e taken to the first, second, and third powers:

    PRINT EXP(1),
    FOR I = 1 TO 3
        PRINT LOG(EXP(1)^I),
    NEXT

■ Output

    2.718282       1       2       3
 
The following users thanked this post: CaptDon

Online BeBuLamar

  • Super Contributor
  • ***
  • Posts: 1585
  • Country: us
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #9 on: March 04, 2025, 11:16:32 pm »
I should know how to write this and I am dinking around with it. I want to add pairs of numbers expressed as dBm. For instance -5.19 + -1.55 = ?
I want to write a loop such as

Enter A in dBm
Enter B in dBm
Answer =
Hit Enter to do more.

The math needs to accept numbers both above and below 0 dBm.
I am not sure how to do Log in Qbasic or if it even can.

I do have a licensed copy of MatLab, perhaps that is the way to go?

Thanks for any insight!!!

-5.19 + -1.55 = ?
So what the answer should be?
 
The following users thanked this post: CaptDon

Offline CaptDonTopic starter

  • Super Contributor
  • ***
  • Posts: 2356
  • Country: is
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #10 on: March 05, 2025, 12:28:09 am »
-3.0dBm + -3.0dBm = 0.0dBm  The power adds, similarly +3.0dBm + +3.0dBm = +6.0dBm. So the example -5.19 + -1.55 would probably be an estimated -1.0 or in that ballpark, again the power adds and pushes the sum toward 0dBm or 1 milliwatt at a standardized reference impedance which doesn't have to be 600 ohms or even 50 ohms, it only matters that all data was taken at the same impedance. I'll be up nights now crunching numbers!!!! This is crazy. The crossover with the numbers which appear on paper to make more sense gave the largest deviation when measured using a resistor combiner to combine the balanced outputs of the Lo and Mid sections. It gave a variation that rose 2.8dBm above the reference slightly above the crossover setpoint. The crossover that had a bigger spread at each individual test frequency produced an impressive response through the resistor combiner rising a maximum of only 0.6dBm from reference right at the crossover point!!! Although the numbers showed a higher spread I guess it all makes sense. For instance the unit with the close set of numbers -5.19dBm and -1.55dBm showed a bigger combined deviation from reference than the other unit which showed -12.3dBm and -3.0dBm at the same test frequency. The crossover with the greatest resistor combined deviation was 18dB per octave, The 'better' unit was 24dB per octave and about 1.6X higher purchase price.
Collector and repairer of vintage and not so vintage electronic gadgets and test equipment. What's the difference between a pizza and a musician? A pizza can feed a family of four!! Classically trained guitarist. Sound engineer.
 

Online BeBuLamar

  • Super Contributor
  • ***
  • Posts: 1585
  • Country: us
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #11 on: March 05, 2025, 01:09:20 am »
So why do you need the log function?
 

Offline CaptDonTopic starter

  • Super Contributor
  • ***
  • Posts: 2356
  • Country: is
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #12 on: March 05, 2025, 02:19:18 am »
Because you must first convert both dBm numbers to a real power in milliwatts which I think uses antilog, then you can add the milliwatts together in a normal linear fashion, then you convert the milliwatts back to dBm using the log function. You can not simply add dBm to dBm in linear fashion because the numbers are logarithmic. dB or dBm is a more realistic way to relate to SPL Sound Pressure Level.
Collector and repairer of vintage and not so vintage electronic gadgets and test equipment. What's the difference between a pizza and a musician? A pizza can feed a family of four!! Classically trained guitarist. Sound engineer.
 

Online BeBuLamar

  • Super Contributor
  • ***
  • Posts: 1585
  • Country: us
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #13 on: March 05, 2025, 02:44:37 am »
So when you talked about Quick Basic you mean the Quick Basic that runs under DOS? If not which version sof Quick Basic do you talked about?
 

Online BeBuLamar

  • Super Contributor
  • ***
  • Posts: 1585
  • Country: us
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #14 on: March 05, 2025, 03:04:01 am »
I think this is it

I converted the 2 dBm values to voltage, added them then covert back to dBm.
I think you want to add the power and not voltage I can do it too. I just used Excel.
« Last Edit: March 05, 2025, 11:24:35 am by BeBuLamar »
 

Online BeBuLamar

  • Super Contributor
  • ***
  • Posts: 1585
  • Country: us
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #15 on: March 05, 2025, 02:02:17 pm »
I do a new one and the dBm is converted to mW. Add them then convert back to dBm
 

Offline CaptDonTopic starter

  • Super Contributor
  • ***
  • Posts: 2356
  • Country: is
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #16 on: March 05, 2025, 02:04:51 pm »
The online text I found said "Add the two powers together", however your numbers look very close to what I got when I did the sweep with the resistor combiner. Probably within .1dB so I guess the formula works with voltage or power? The final outcome of the system went like this, my friend took out the 18dB/octave crossover and installed a 24dB/octave crossover which included multiband limiters for safety when D.J.'s go nuts on his house system. I suggested the make and model since I had also installed one in my system about two years ago and was very pleased. He said his system didn't seem as punchy with the new crossover (all other processing settings remaining un-touched) I thought the new crossover perhaps had a sag at the crossover point. Turns out his old crossover had a 2.8dB rise in the 63 to 69Hz area. I know that sounds almost undetectable but trained ears listening to familiar music can easily detect that amount of change. A slight diddle on the 31 band EQ should give him what he is used to but we didn't want to start changing things until we understood what change had occurred. Thanks to everyone who offered assistance!!!
Collector and repairer of vintage and not so vintage electronic gadgets and test equipment. What's the difference between a pizza and a musician? A pizza can feed a family of four!! Classically trained guitarist. Sound engineer.
 

Offline CaptDonTopic starter

  • Super Contributor
  • ***
  • Posts: 2356
  • Country: is
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #17 on: March 05, 2025, 02:15:59 pm »
Interesting, the spread of the numbers appears much smaller and the -10.23 added to 0.0 should have produced a negative number as opposed to the positive .39   Your first set of numbers using voltage seemed to be in very close alignment with what my dBm meter produced using a resistor combiner to incorporate the Lo+Hi into a single measurable signal which should represent the overall system performance (plus or minus the actual deviation in individual speaker response curves). All of the numbers were taken with a Tektronix DM502 3.5 digit meter set to measure dBm as opposed to dBV with an internal jumper. My assumption was measuring in dBm would more accurately represent the 'system power output' which would be closely related to sound pressure level. I thought measuring in dBV would not be an accurate approach?

Collector and repairer of vintage and not so vintage electronic gadgets and test equipment. What's the difference between a pizza and a musician? A pizza can feed a family of four!! Classically trained guitarist. Sound engineer.
 

Online BeBuLamar

  • Super Contributor
  • ***
  • Posts: 1585
  • Country: us
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #18 on: March 05, 2025, 02:20:33 pm »
If you add anything to 0dB would make it greater than 0dB. You don't take anything away from it.
 

Online themadhippy

  • Super Contributor
  • ***
  • Posts: 3542
  • Country: gb
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #19 on: March 05, 2025, 03:11:08 pm »
Quote
Turns out his old crossover had a 2.8dB rise in the 63 to 69Hz area. I know that sounds almost undetectable but trained ears listening to familiar music can easily detect that amount of change.
undetectable? Thats bucket loads.
 

Offline CaptDonTopic starter

  • Super Contributor
  • ***
  • Posts: 2356
  • Country: is
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #20 on: March 05, 2025, 06:50:15 pm »
Bebu, you are correct, don't know how I missed that!
Collector and repairer of vintage and not so vintage electronic gadgets and test equipment. What's the difference between a pizza and a musician? A pizza can feed a family of four!! Classically trained guitarist. Sound engineer.
 

Online BeBuLamar

  • Super Contributor
  • ***
  • Posts: 1585
  • Country: us
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #21 on: March 05, 2025, 07:17:30 pm »
But Don I am curious about Qbasic? do you really want to use Qbasic? Do you have it? How do you run it?
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 20840
  • Country: gb
  • 0999
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #22 on: March 05, 2025, 08:41:36 pm »
Why use such an antiquated piece of software such as QBasic or Quick Basic?

And which is it? Quick Basic is a compiler and QBasic is just an interpreter which was shipped with MS-DOS and Windows 95/98.

https://en.wikipedia.org/w/index.php?title=QBasic&useskin=vector
https://en.wikipedia.org/wiki/QuickBASIC?useskin=vector

 

Offline BrianHG

  • Super Contributor
  • ***
  • Posts: 8385
  • Country: ca
    • LinkedIn
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #23 on: March 05, 2025, 10:04:31 pm »
I would have done it in MS-Excel or LibreOffice spreadsheets.
__________
Follow me for 3 Classic Fitness Playlist Songs from the '70s to 2010s, Delivered Every Other Day!
www.linkedin.com/in/brianhg-ocean-fitness www.facebook.com/profile.php?id=61573174078303
 

Offline CaptDonTopic starter

  • Super Contributor
  • ***
  • Posts: 2356
  • Country: is
Re: Can QBasic (MS Quick Basic) do Log operations?
« Reply #24 on: March 06, 2025, 01:59:10 am »
It was the QBasic which shipped with W95 DOS6.0 or possibly newer. I wrote tons of NEMA0182(3) diagnostic software for testing chartplotters and other devices needing particular data strings so I was familiar with the client. I do own a registered legal copy of MatLab so I ended up playing with the numbers in that client. I am still baffled by the fact that when Bebu did the number crunching having converted to voltage mid-step his numbers closely matched my metered results. All of the formulas say convert to power and add and when Bebu did that the numbers were not anywhere close to my real time measurements. My measurements were taken using the dBm mode as opposed to the dBV mode.
Collector and repairer of vintage and not so vintage electronic gadgets and test equipment. What's the difference between a pizza and a musician? A pizza can feed a family of four!! Classically trained guitarist. Sound engineer.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf