The FM Tube Modulator Jimi Loved

His guitar slung across his back, his dusty boots is his cadillac.

Moderators: VelvetGeorge, BUG

Post Reply
Tek465b
Senior Member
Posts: 207
Joined: Sat Jan 10, 2015 9:43 am
Just the numbers in order: 13492
Contact:

Re: The FM Tube Modulator Jimi Loved

Post by Tek465b » Fri Feb 05, 2016 3:14 pm

For the 3-phase LFO.
What is needed exactly?
Do you need 3 output with each one at the same frequency with 120 degree phase lag? with 33% or 50% or 66% duty cycle?
or 3 output each one at different frequency(2-4-8 hz) and 50% duty cycle?
Or i can do all the 3-4 option together with a press button/mode select :)

and what frequency range you need. going to make speed control of course. :)

edit:
i was thinking about it, and i could get back with a code tonight or tomorrow.
Just a matter of only 1 or 2 dozen lines. (last code i worked on was 2000+ lines loll)

Just let me know what is needed. and i start working on it right now.

User avatar
Eb7+9
Senior Member
Posts: 105
Joined: Wed Mar 09, 2011 1:30 pm
Just the numbers in order: 13492
Contact:

Re: The FM Tube Modulator Jimi Loved

Post by Eb7+9 » Fri Feb 05, 2016 8:53 pm

thx for looking at this Tek ...!



mandatory needs:

(i) Typical 0-5v PWM outputs with SINE and/or TRIANGLE shaped variation in time ...
said variation 120 degrees out of phase from each other // exactly like a 3-phase electric motor driver

(we're basically emulating a ring-oscillator, but without the imperfections ... ie., w/o random phase jitter)

(ii) Full speed control range: 0.1Hz to 20Hz ...

(users can later set precise limits by simply adding trimmers to the control voltage circuit)

(iii) Full amplitude control: zero DEPTH corresponding to static (50%) PWM, max DEPTH corresponding to max PWM variation (0% to100%) ...

(w canonically "linear" intensity response to DEPTH control)


useful options:

(iv) Making the zero-DEPTH center point variable up/dn (from 50%) and adjusting MAX depth response so there is no clipping in the LFO shape(s) ...

(v) Altering the shape of the LFO to help cancel the exponential response of the LED's in the opto-couplers ...

(the alternative is using three bulbs as in Wayne's 1968 patent, leading again to a complex circuit solution requiring individual bias controls, matched cells, etc, etc ...)

---


I think that covers it for now ... at least for sake of obtaining a first level of quality Chorusing ...
I realize that the later two options may involve heeps more code, but I have no real idea about that

following the implementation of such a PWM 3-phase PWM LFO the entire frequency shifter circuit would only require the use of three fairly well matched opto-couplers to pull off ... and the lattice circuit, of course ... the output left passive thru resistive mixing // yielding best noise specs possible ... and, as discussed w Dave previously, no resonant TANKS for now ... in hindsight, seeing that long hookup cables might get used in real-world situations a switch-able output buffer might not be a bad idea either, making full use of 3 dual op-amp IC's in the process ... the toughest part would be finding three relatively matched opto-couplers, and then (possibly) having to measure lattice capacitors

seemingly, a very doable DIY project ...

~jcm
modern VT circuit analysis and modeling: https://viva-analog.com/product/ifmta-book-pdf/

User avatar
Eb7+9
Senior Member
Posts: 105
Joined: Wed Mar 09, 2011 1:30 pm
Just the numbers in order: 13492
Contact:

Re: The FM Tube Modulator Jimi Loved

Post by Eb7+9 » Sat Feb 06, 2016 5:00 am

as an aside, I wanted to post a link to the following SSB research paper ...

http://www.ce-multiphase.com/audio-shift.pdf

in figure 3 we see a circuit resembling the one Wayne uses in his lattice
and referred to as a Norgaard network ...

one difference, of course, are the parallel R/C loads seen at the output of the lattice in Wayne's case
not in the paper

I feel these are merely acting to shunt the output at high frequencies to prevent radio interference, etc ...
and do not necessarily play a role in setting the overall constant phase-difference function
(in fact it might be impeding it a little)

if there is anyone in school who has access to IRE papers, I'd really like it someone could
upload a copy of this paper:

Norgaard, D.E., "The Phase Shift Method of SSB Signal Generation," Proc. IRE, (Single Sideband Issue), Vol. 44, Dec 1956. pp. 1718-1735.

even though these SSB guys are playing with a 90-degree shift it still would be useful to read ...

thx
~jcm
modern VT circuit analysis and modeling: https://viva-analog.com/product/ifmta-book-pdf/

Tek465b
Senior Member
Posts: 207
Joined: Sat Jan 10, 2015 9:43 am
Just the numbers in order: 13492
Contact:

Re: The FM Tube Modulator Jimi Loved

Post by Tek465b » Sat Feb 06, 2016 8:53 am

Am not sure i understand the sine and/or triangle shaped variation in time.

If i understand correctly you want something like that?
https://images.duckduckgo.com/iu/?u=htt ... 50.gif&f=1
With frequency (0.1 to 20hz) and pwm control(50% to 100% or 50% to 0%). just to make sure?
All 3 channel will run at the same frequency and same PWM %, just 120 phase lag.


What i can do is 3 channel 0v to 5v square wave that are 120degree out of phase.
With a 0-5 volt input for the frequency control. (0v = 0.1hz / 5v = 20hz)
With a steady PWM that is set according to the 0-5v pot signal. (0v = 0% / 5v = 100%)... or 0v = 50% / 5v = 100% or 0v = 50% / 5v = 0%

but for the PWM, if what you need is continuously variable with time PWM
(ie pot at 0 pwm steady at 50%, pot at 50% pwm sweep between 25% and 75% PWM @ 0.1hz to 20hz, pot at 100% pwm sweep between 0 and 100% @ 0.1hz to 20hz),
then i need to work my brain a little harder.(and figure a mathematical way to do it loll)

Those 2 input(frequency and depth/pwm) can use a linear potentiometer for a linear response.

For the min/max frequency trimmer and depth. i could set a calibration mode. Just press button to set your min/max depth and min/max frequency (using both potentiometer) and press calibrate again it will save into memory.
Trimmer is doable too. Depth centerpoint control should be quite easily doable too.
We will include those option later once we get the basic script running.

If you want anything else then a square wave(sine/triangle, or altering the shape) then we need a digital to analog converter and quite alot more code.

The depth control add a bit of complexity but its not soo bad.
I just need to make sure i understand exactly what is needed. dont want to work for hours on a code just to trash it and start all over again because i missunderstood something loll.

User avatar
Eb7+9
Senior Member
Posts: 105
Joined: Wed Mar 09, 2011 1:30 pm
Just the numbers in order: 13492
Contact:

Re: The FM Tube Modulator Jimi Loved

Post by Eb7+9 » Sat Feb 06, 2016 10:08 pm

Tek,

the PWM approach allows both Speed and Intensity control on the PWM duty cycles changing in time
(all the 120-degrees out of phase with other // as divided thirds of a complete modulation cycle)

you may want to check out Tom's work at Electric Druid

I would encourage you to take your own route of course ...
but Tom makes his code available for study

http://electricdruid.net/tap-tempo-lfo-taplfo-v2d/

there is another dude as well here:

http://www.sabrotone.com/?p=3992

worth looking at perhaps ...

---

what we want, to be clear, is a PWM ratio that changes near continuously in time
in small digital steps ...

I think the Electric Druid Tap Tempo uses 10bits (or 1024 steps) spread out over the
period of the modulation cycle ... meaning that the PWM variation has about a 0.1% duty cycle resolution per division over the full 0-100% scale

ie., how the 1024 PWM ratios are cycled thru in time sets the modulation "shape"
that's your design call ...(!)

to explain further ...

a PWM that goes from 0% to 100% proportionately with time (at full Depth)
and immediately reversed it's direction at the same rate, back and forth ...
that would then be called a triangle-wave modulated PWM

if the PWM got modulated the same way between 25% and 75% extremas
then we would have a triangle wave modulation of the PWM, set at half Depth or Intensity ...

at zero Intensity the PWM ratio would remain steady at 50% over time ...

for a sinewave modulation, the rate of PWM variation in time also changes in time between direction reversals ...
I think you need some kind of lookup table or something ... (actually I should check, maybe not ...)

it's very important you understand the goal for sure
don't want to send you in a random direction ...

also, I'd like to be able to make that 50% point variable ...

so for example, if the zero Depth were stuck at 27% PWM instead of 50%
then MAX intensity would give is a PWM modulation variation (either either sine or triangle in time)
that would go between 0% duty cycle and 54% duty cycle, without clipping in the modulation shape

consider that we will be driving LED's thru resistors ...
and that the PWM pulses will be 0-5vdc in height ...
each PWM output can drive 1mA on those PIC things I'm sure (gotta be)

so if I set the resistor for a maximum 1mA of current
a PWM going from 0% to 100% will then result in an "equivalent" DC current ranging proportionately from 0mA to 1mA

we want the brightness of the LED's to go up and down, in a sine or triangle manner
(I won't get into the math aspects too much now, but there's much more going on ...)

let me know if this is still not clear ...

now bear in mind that Tom is looking at this problem also ...

~jcm
modern VT circuit analysis and modeling: https://viva-analog.com/product/ifmta-book-pdf/

Tek465b
Senior Member
Posts: 207
Joined: Sat Jan 10, 2015 9:43 am
Just the numbers in order: 13492
Contact:

Re: The FM Tube Modulator Jimi Loved

Post by Tek465b » Sun Feb 07, 2016 9:39 am

Oh i understand ALOT better now.(sorry, my brain is a bit slow sometime)
Like that but with 3 led instead of 6(without the led staying on for a long time"and a much smaller arduino"):
https://www.youtube.com/watch?v=yJEBdPKUVIo
+ all the options stated above.

Same thing that if we used a low pass filter on the output to simulate an analog voltage, but since we use led we can feed them the PWM directly and have variable brightness ramping up and down.
Each ditigal output can do up to 40mA on the arduino(but the whole chip cannot do more then about 200mA in total need to check spec sheet), that should be enough for a set of 3 led without using a transistor(the video above use 8x 20mA led so).

The AtMega328p/arduino use 10bits A/D converter with 1024 step for the input
and 8 bits for the PWM (ie 0-255) 0.4% resolution.
Just gimme a day or 2 so i can do that. If Tom come back with something before am done then we will have 2 options :D.
Going to start working on it tonight, i can't promise anything but for a triangle shaped PWM it should be EASY to do.

Yes sinewave require somekind of a lookup table.

Tek465b
Senior Member
Posts: 207
Joined: Sat Jan 10, 2015 9:43 am
Just the numbers in order: 13492
Contact:

Re: The FM Tube Modulator Jimi Loved

Post by Tek465b » Sun Feb 07, 2016 6:33 pm

Ok there we go.
Plase note, istill need to go through the code to see if there is no error.(will do that tomorrow, now am taking my day off :P)
And also i don't have an arduino to test on hand but it should be good(on the simulator i have its working :)).

It read the value from the pot about once a second.
Dont want too many instruction running continously otherwise we may get some glitches(stutter) at high frequency,
it take 510 step to do a complete 360degree cycle(0 to 255 and 255 to 0). each cycle is at 100µs for about 20hz,(100µs * 510 = 51mS = 19.6hz)
every read of an analog input take 100µS. so we have a 300µs delay every 1 second(in can increase that 1 second poll delay).
The Analog/Digital converter has its own speed restriction(it use an internal capacitor at the input). its really the best i can do quickly like that. or i could set the routine not to read them all at once but instead to read them one by one between cycle.(it will be the same delay but the resulting waveform will be a bit smoother"i.e. 100µs every 1 second vs 300µs")
OR id have to check into interrupts. maby i can do something that will execute only when there is a voltage change.(thus no need to poll the analog input every seconds)
https://www.arduino.cc/en/Reference/AttachInterrupt

The analogWrite are 8µS Maximum each so its 120.1728 degree MAX @ 20hz and 120.000864 degree MAX @ 0.1hz. i hope thats good enough.

Will work to add the other options in the next days.
This will work on most arduino with the ATMega328P(i personally like the pro mini 16Mhz 5v)
Let me know what your thinking.

100 lines, took me about 2 hours but i had to refresh my memory a little.

Code: Select all

/*3-phase oscillator

   This circuit generate a triangle shaped PWM to digital output 6 10 and 11 with 120° phase delay.
   analog input 1 is frequency control (0.1hz to 20hz)
   Analog input 2 is Depth control(0% to 100%)
   Analog input 3 is OffSet control (min = -100 %, middle = 0% max = 100%)
 By Tek465B
*/
#define Out1   9
#define Out2   10
#define Out3   11
#define FPot   1
#define DPot   2
#define OPot   3

byte ch1 = 0;
byte ch1O = 0;
byte ch2 = 170;
byte ch2O = 0;
byte ch3 = 170;
byte ch3O = 0;
int d1 = 1;
int d2 = 1;
int d3 = -1;
byte PWM = 0;
byte Min = 0;
byte Max = 255;

unsigned long currentMicros;
unsigned long previousMicros = 0;
unsigned long previousMicros2 = 0;

int Freq = 0;
int Depth = 0;
int Offset = 0;
int Offsetv = 0;
int ch11 = 0;
int ch22 = 0;
int ch33 = 0;

long interval2 = 1000000;
long interval = 100;

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:
  currentMicros = micros();
  if (currentMicros - previousMicros > interval) {
    previousMicros = currentMicros;
    analogWrite(Out1, ch1O);
    analogWrite(Out2, ch2O);
    analogWrite(Out3, ch3O);
    if ((ch1 == 255) && (d1 == 1)) {
      d1 = -1;
    }
    if ((ch1 == 0) && (d1 == -1)) {
      d1 = 1;
    }
    if ((ch2 == 255) && (d2 == 1)) {
      d2 = -1;
    }
    if ((ch2 == 0) && (d2 == -1)) {
      d2 = 1;
    }
    if ((ch3 == 255) && (d3 == 1)) {
      d3 = -1;
    }
    if ((ch3 == 0) && (d3 == -1)) {
      d3 = 1;
    }
    ch1 += d1;
    ch11 = ch1 + Offsetv;
    ch11 = constrain(ch11, 0, 255);
    ch1O = map(ch11, 0, 255, (0 + PWM), (255 - PWM));
    ch2 += d2;
    ch22 = ch2 + Offsetv;
    ch22 = constrain(ch22, 0, 255);
    ch2O = map(ch22, 0, 255, (0 + PWM), (255 - PWM));
    ch3 += d3;
    ch33 = ch3 + Offsetv;
    ch33 = constrain(ch33, 0, 255);
    ch3O = map(ch33, 0, 255, (0 + PWM), (255 - PWM));

    if (currentMicros - previousMicros2 > interval2) {
      previousMicros2 = currentMicros;
      Freq = analogRead(FPot);
      interval = map(Freq, 0, 1023, 19608, 100);
      Depth = analogRead(DPot);
      PWM = map(Depth, 0, 1023, 127, 0);
      Offset = analogRead(OPot);
      Offsetv = map(Offset, 0, 1023, -127, 127);
    }

  }


}

User avatar
Eb7+9
Senior Member
Posts: 105
Joined: Wed Mar 09, 2011 1:30 pm
Just the numbers in order: 13492
Contact:

Re: The FM Tube Modulator Jimi Loved

Post by Eb7+9 » Mon Feb 08, 2016 6:50 am

awesome Tek, ...!!

ok, let's keep with "reading the pot once a second" ...
it won't allow continuous (instantaneous) speed control //
but that's fine ...

adding mystique to the design,

;)

and, yes ... we can drive the opto-coupler LED's directly from the PWM outputs through
enough resistance to limit the current(s) to 1mA during the high parts of the PWM outputs

so, we're good there ...

a convenient aspect of opto-couplers is that the driving pulses result in averaged-out resistance
via the timing of the photo-cell part ... ie., the combination acts like a smoothing capacitor ...
with a fast enough time constant to easily "follow" a 20hz tri-or-sine modulation waveform

when comes time to test, you can have a resistor and LED combo to get a visual ...
or use a resistor and small cap (0.001uF) and "see" this modulated average on the cap itself using a scope

this is great, I get to learn some code ... // I'll do my best to keep up
~jcm
modern VT circuit analysis and modeling: https://viva-analog.com/product/ifmta-book-pdf/

Tek465b
Senior Member
Posts: 207
Joined: Sat Jan 10, 2015 9:43 am
Just the numbers in order: 13492
Contact:

Re: The FM Tube Modulator Jimi Loved

Post by Tek465b » Mon Feb 08, 2016 8:47 am

Eb7+9 wrote:awesome Tek, ...!!

ok, let's keep with "reading the pot once a second" ...
it won't allow continuous (instantaneous) speed control //
but that's fine ...

adding mystique to the design,

;)

and, yes ... we can drive the opto-coupler LED's directly from the PWM outputs through
enough resistance to limit the current(s) to 1mA during the high parts of the PWM outputs

so, we're good there ...

a convenient aspect of opto-couplers is that the driving pulses result in averaged-out resistance
via the timing of the photo-cell part ... ie., the combination acts like a smoothing capacitor ...
with a fast enough time constant to easily "follow" a 20hz tri-or-sine modulation waveform

when comes time to test, you can have a resistor and LED combo to get a visual ...
or use a resistor and small cap (0.001uF) and "see" this modulated average on the cap itself using a scope

this is great, I get to learn some code ... // I'll do my best to keep up
~jcm
Cool am glad you like it. :thumbsup:
I could remove the offset pot and move the offset programming into the calibration routine(when i add it later).
It will be 1 less input to monitor, 1 less pot, if you want to reduce cost.
I/you can also decrease the poll delay for reading the pot but you know the draw back.(100µS delay every analog read)
Just change the interval2 value, its in microseconds(keep it multiple of 4).
ex: long interval2 = 100000; (0.1 sec for 10 time per second)
Or like i said above i can move it to the interrupts it will have no delay and catch every change, but i try to avoid that(script will hang while the interrupts is running, and if we get false trigger its going to be annoying).

I will keep working on it to add the extra options in the next few day.
I can change the frequency of the PWM(they run at 490hz now), if its too slow for the led/resistor filtering i can increase it(to 3.9khz or 31khz), just let me know.
Or just add that to the setup routine
TCCR1B = TCCR1B & B11111000 | 0x01;
TCCR2B = TCCR2B & B11111000 | 0x01;
replace 0x01(31khz) by 0x02 for 3.9khz

If you want to learn some code you can look at some exemples and also look at the arduino reference pages.(thats how i got started about.. 6 month ago :P)

User avatar
Eb7+9
Senior Member
Posts: 105
Joined: Wed Mar 09, 2011 1:30 pm
Just the numbers in order: 13492
Contact:

Re: The FM Tube Modulator Jimi Loved

Post by Eb7+9 » Mon Feb 08, 2016 2:56 pm

ok, so you're saying I'm only six months behind ...

;)

I'll have a look at the Arduino reference

please leave the Offset control in there for now,
good chance it will be very useful later, even as an on-board trimmer
(btw, this will have a similar effect as my Univibe "bulb offset" mod ... very useful)

something that was missing in Tom's Tap-Tempo IC
which became apparent when I used it in my PWM stereo-phasor ...
(he's since included it in a recent revision)

let's try with 490hz PWM and see what happens ...
should be ok

~jcm
modern VT circuit analysis and modeling: https://viva-analog.com/product/ifmta-book-pdf/

Tek465b
Senior Member
Posts: 207
Joined: Sat Jan 10, 2015 9:43 am
Just the numbers in order: 13492
Contact:

Re: The FM Tube Modulator Jimi Loved

Post by Tek465b » Mon Feb 08, 2016 6:41 pm

I made a github page to show the changes in code(so i dont have to re-post the complete code over here every time)
https://github.com/Tek465B/3-phaseLFO.git
Click MainSketch.ino

I just fixed a bug in the offset control ;)

Also i tryed a simulation with a 0.1sec input/pot poll delay (about 10 time per second) and it is working without apparent glitches. That will allow for apparent continuous/instantaneous speed/depth/offset control.

User avatar
Eb7+9
Senior Member
Posts: 105
Joined: Wed Mar 09, 2011 1:30 pm
Just the numbers in order: 13492
Contact:

Re: The FM Tube Modulator Jimi Loved

Post by Eb7+9 » Tue Feb 09, 2016 3:32 am

... nice going Tek !!
modern VT circuit analysis and modeling: https://viva-analog.com/product/ifmta-book-pdf/

Tek465b
Senior Member
Posts: 207
Joined: Sat Jan 10, 2015 9:43 am
Just the numbers in order: 13492
Contact:

Re: The FM Tube Modulator Jimi Loved

Post by Tek465b » Tue Feb 09, 2016 8:42 am

Ok i did play alot with the code in the simulator. Try it here -> https://123d.circuits.io/circuits/1573985-3-phase-lfo
Everything work good except one last bug(hopefully)

The map function for the Depth is taking too much time an it slow down the script.
Cant reach full 20hz with depth control.

So we have 2 options so far

First(and most preffered reason), i can reduce the resolution by 3 to 1.18%(i dont know if that is still acceptable for you or not)
That will allow full 20hz operation with Depth control and also allow polling of the input controls"speed/depth/offset" every 100mili seconds, wich is virtually direct/continuously speed/depth/offset control

Second options, I remove the Depth control(and/or find another way to implement it, help from other codester will be welcome)

User avatar
Eb7+9
Senior Member
Posts: 105
Joined: Wed Mar 09, 2011 1:30 pm
Just the numbers in order: 13492
Contact:

Re: The FM Tube Modulator Jimi Loved

Post by Eb7+9 » Tue Feb 09, 2016 1:50 pm

Tek,

we don't actually need to reach 20hz ...
16hz would be fine, does this help ?
modern VT circuit analysis and modeling: https://viva-analog.com/product/ifmta-book-pdf/

Tek465b
Senior Member
Posts: 207
Joined: Sat Jan 10, 2015 9:43 am
Just the numbers in order: 13492
Contact:

Re: The FM Tube Modulator Jimi Loved

Post by Tek465b » Tue Feb 09, 2016 3:26 pm

Eb7+9 wrote:Tek,

we don't actually need to reach 20hz ...
16hz would be fine, does this help ?
The best i can do at full res is 6.66hz right now.
I will look into re-writing the map function to be a bit quicker(it use long 32 bit arithmetic math, that make it slow).

Edit
I changed the map function.
from this:

Code: Select all

long map(long x, long in_min, long in_max, long out_min, long out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
to this:

Code: Select all

int FMap(int in, int sel)
{
  return ((in * (sel >> 3)) >> 5) + ((255 - sel) >> 1);
}
it use 16 bit integer now and get rid of the slow division math.
Now can do 15.5hz at full resolution like that. i just tested it, I will try to increase that some more tomorrow.
I keep you guy updated.

Post Reply