The problem is to synthesize a triangle or sawtooth waveform of constant amplitude from a variable-pitch incoming square wave. The ramp can be generated by incrementing or decrementing a register, resetting it at transitions. The pitch can be measured by counting the number of processor clocks between transitions, but to calculate the register increment value needs a division.
Is there a simple way to achieve this with the FV-1? The log and exp functions look frightening!
Any ideas gratefully appreciated
Division with FV-1
Moderator: frank
Re: Division with FV-1
To evaluate
y = A / B
on the FV-1 you evaluate this
y = exp( log(A) - log(B) )
The problem is that the FV-1 log() only works on values in the range 0 to 1, and the exp() function only produces values in the range 0 to 1. This means that you need to make sure that the final answer lies in the range 0 to 1.
Example:
Lets say you want to evaluate
y = 1 / (1 + 9 * x) where x is between 0 and 1
This has an answer in the range 0 to 1, but to evaluate it on the FV-1 you need to scale the
numerator and denominator so that they are both in the range 0 to 1 so that log() works OK.
So you evaluate this instead...
y = 0.1 / (0.1 + 0.9*x)
which in terms of exp() and log() is
y = exp( log(0.1) - log(0.1 + 0.9x) )
The two quantites that log() operates on are both between 0 and 1 so the log() functions will work OK,
and since the final answer for y is known to be in the range 0 to 1, the exp() should work OK too.
EDIT: If you are calculating the duration of the "high" period of the square wave then you could increment a register "T" by some very small fractional value "D" with each clock tick (and choose "D" to try to keep the value in "T" below 1).
So T will be between D and 1
Therefore 1/T can be larger than 1.
Therefore evaluate (D/T) since this will be <= 1.
y = A / B
on the FV-1 you evaluate this
y = exp( log(A) - log(B) )
The problem is that the FV-1 log() only works on values in the range 0 to 1, and the exp() function only produces values in the range 0 to 1. This means that you need to make sure that the final answer lies in the range 0 to 1.
Example:
Lets say you want to evaluate
y = 1 / (1 + 9 * x) where x is between 0 and 1
This has an answer in the range 0 to 1, but to evaluate it on the FV-1 you need to scale the
numerator and denominator so that they are both in the range 0 to 1 so that log() works OK.
So you evaluate this instead...
y = 0.1 / (0.1 + 0.9*x)
which in terms of exp() and log() is
y = exp( log(0.1) - log(0.1 + 0.9x) )
The two quantites that log() operates on are both between 0 and 1 so the log() functions will work OK,
and since the final answer for y is known to be in the range 0 to 1, the exp() should work OK too.
EDIT: If you are calculating the duration of the "high" period of the square wave then you could increment a register "T" by some very small fractional value "D" with each clock tick (and choose "D" to try to keep the value in "T" below 1).
So T will be between D and 1
Therefore 1/T can be larger than 1.
Therefore evaluate (D/T) since this will be <= 1.