HKJ,

There is a bug in the logarithmic frequency sweep script or with the expression evaluator. There is an integer truncation in the expression:

pow(endFrequency/startFrequency,1.0/steps)

Specifically, in the "endFrequency/startFrequency" division.

To narrow down the issue I took the auto generated logarithmic frequency sweep script, removed commands to the generator, and added print statements. Here is the reduced test script I ran in TC Ver 1.19:

`#logcmds 0`

; Sweep the output of a waveform generator, both up and down will work

=var amplitude=2

=var startFrequency=2000

=var endFrequency=15000

=var stepTime=0.1

=var steps=40

; --------------------------------------------------------------

="Sweep from "+startFrequency+"Hz to "+endFrequency+"Hz in "+steps+" steps, estimated time: "+formatDouble((stepTime*steps)/60.0,1,6,0,1)+" minutes";

#delay (stepTime)

#log (stepTime)

=var n=1;

="Steps = "+steps+"; endFrequency ="+endFrequency+"; startFrequency = "+startFrequency+"; ratio = "+(pow(endFrequency/startFrequency,1.0/steps))

#while (n<=steps);

#delay (stepTime)

=freq=startFrequency*pow(pow(endFrequency/startFrequency,1.0/steps),n)

="n = "+n+"; freq = "+freq+" Hz"

=n=n+1;

#endwhile

#log 0

="Done"

(endFrequency/startFrequency)^(1/steps) = (15000/2000)^(1.0/40) = 1.05166 via calculator.

The script gives 1.0498504796816786 for this expression.

That ratio raised to the power number of steps = (1.0498504796816786)^40 = 7.00 and not 15000/2000 = 7.5 as expected.

endFrequency = 15000 but end of script only gets to 14000

So, it looks like endFrequency/startFrequency in this expression is being truncated to integer. If you change the expression to:

pow(1.0*endFrequency/startFrequency,1.0/steps)

the logarithmic frequency sweep then works because the added 1.0* forces the division result to be float and not truncated to integer.

Is there a better way to fix this or is there a bug in the expression evaluator that causes the endFrequency/startFrequency to be truncated to an integer instead of being float?