#garfield Logs
Jan 09 2021
#garfield Calendar
12:08 AM rue_mohr: my tek 754c
12:22 AM rue_mohr: ok I need to focus
12:23 AM rue_mohr: so, when I realized the scope is ill, I was watching the output of my new bench power supply
12:23 AM rue_mohr: it oscillates, at 75khz
12:23 AM rue_mohr: big capacitors dont help
12:23 AM rue_mohr: so,
12:24 AM rue_mohr: my understanding is to put a low pass somewhere
12:24 AM rue_mohr: right back to filters
12:48 AM rue_shop1: Error 242
12:51 AM rue_shop1: DSP86kD1MemTest, no memory detected
12:52 AM rue_shop1: ^ 'daignostic test failure'
01:02 AM rue_shop2: so
01:02 AM rue_shop2: what is the response of a plain old digital differentiator
01:03 AM rue_shop2: I think it should just be a slope
01:03 AM rue_shop2: you could just use that test code
01:04 AM rue_shop2: oh and just simulate it
01:04 AM rue_shop2: but we want a knee
01:04 AM rue_shop2: thats a proper filter
01:04 AM rue_shop2: so PID
01:04 AM rue_shop2: yea its a hack
01:05 AM rue_shop2: so, what would simulate an RC highpass better?
01:05 AM rue_shop2: I dont think FIR is the answer
01:05 AM rue_shop2: ok, we simulated an RC filter before
01:06 AM rue_shop2: the regulator
01:06 AM rue_shop2: yea
01:06 AM rue_shop2: uh
01:06 AM rue_shop2: yea, why wasn't that a differentiator?
01:06 AM rue_shop2: ok, lets move on...
01:07 AM rue_shop2: so, the virtual cap adds 1 unit of charge each pulse
01:08 AM rue_shop2: and the loop does a timed discharge
01:14 AM rue_shop2: if we worked that out, we must be able to work out RC
01:14 AM rue_shop2: ok, ponder this
01:14 AM rue_shop2: we have an analog signal comming in
01:14 AM rue_shop2: this is for a high pass
01:14 AM rue_shop2: yea so (in)----||-----(out)------\/\/\/----("zero")
01:14 AM rue_shop2: ok
01:14 AM rue_shop2: what charges the capacitor
01:14 AM rue_shop2: uh current
01:14 AM rue_shop2: and the current is
01:14 AM rue_shop2: is this the right path?
01:16 AM rue_shop2: then nobody would be coding
01:16 AM rue_shop2: erm
01:17 AM rue_shop2: K is 0 - 1
01:17 AM rue_shop2: not zero
01:17 AM rue_shop2: I suppose not, so how about Vc -= Vout * K; where k is 0 - 1
01:17 AM rue_shop2: ok
01:17 AM rue_shop2: I dont have the code here
01:31 AM rue_shop2: ok, that works
01:32 AM rue_shop2: attenuation isn't right
01:34 AM rue_shop2: 48db/decade
01:34 AM rue_shop2: and what should it be?
01:37 AM rue_shop1: it should be -20db/decade
01:37 AM rue_shop2: well wtf
01:37 AM rue_shop2: I suggest you did something wrong?
01:37 AM rue_shop2: but what
01:38 AM rue_shop2: not sure, but your RC high pass has gain
01:41 AM rue_shop2: where is your capacitor constant
01:41 AM rue_shop2: op = a - Vc;
01:41 AM rue_shop2: Vc += op * 0.0005;
01:41 AM rue_shop2: I suppose its in the 0.0005
01:41 AM rue_shop2: so its both
01:42 AM rue_shop2: the capacitor voltage changes with the resistance of the filter, divided by the amount of capacitance
01:42 AM rue_shop2: no 1/RC
01:43 AM rue_shop2: ok, so RC is 0.0005
01:43 AM rue_shop2: yea, what is that?
01:43 AM rue_shop2: I suppose the impedence doesn't matter as is a virtual circuit
01:44 AM rue_shop2: question
01:44 AM rue_shop2: yes?
01:44 AM rue_shop2: lets just say 1k and 1uF
01:44 AM rue_shop2: ok, 1000*(1/1000000000)
01:44 AM rue_shop2: yea what is that
01:45 AM rue_shop2: wrong number of zeros
01:45 AM rue_shop2: its 0.001
01:45 AM rue_shop2: ok
01:48 AM rue_shop2: how does this not work?
01:57 AM rue_shop2: your Vc is wrong
01:58 AM rue_shop2: the voltage will decrease by the current caused by the resistor
01:58 AM rue_shop2: the voltage difference will decrease
01:58 AM rue_shop2: how do I write that
01:58 AM rue_shop2: I cant do this all for you
01:59 AM rue_shop2: ok
01:59 AM rue_shop2: yea so (in)----||-----(out)------\/\/\/----("zero")
01:59 AM rue_shop2: Vc =
01:59 AM rue_shop2: -=
01:59 AM rue_shop2: how about scaled by
02:00 AM rue_shop2: V = C*i
02:00 AM rue_shop2: i = V/R
02:00 AM rue_shop2: where v is op
02:01 AM rue_shop2: but time wise
02:01 AM rue_shop2: V =
02:01 AM rue_shop2: Vc =
02:01 AM rue_shop2: i can have a sign
02:02 AM rue_shop2: V += C * (Vo / R);
02:02 AM rue_shop2: no
02:02 AM rue_shop2: yes?
02:02 AM rue_shop2: Vc = i/C
02:03 AM rue_shop2: t
02:03 AM rue_shop2: t doesn't matter here, its constant
02:03 AM rue_shop2: V goes up with i
02:03 AM rue_shop2: and down with C
02:03 AM rue_shop2: so yea
02:03 AM rue_shop2: Vc = i/C
02:03 AM rue_shop2: ok, so i
02:03 AM rue_shop2: i = Vo/R
02:04 AM rue_shop2: Vc = (Vo/R)/C
02:04 AM rue_shop2: Vc = (Vo/R)/(C/1)
02:04 AM rue_shop2: Vc = (Vo/RC)
02:04 AM rue_shop2: didn't we just say that?
02:04 AM rue_shop2: but, thats not the completel voltage
02:05 AM rue_shop2: we have to accumulate it
02:05 AM rue_shop2: in the right polarity
02:05 AM rue_shop2: there are only two options
02:05 AM rue_shop2: += and -=
02:05 AM rue_shop2: if Vo is positive
02:06 AM rue_shop2: Vc goes u
02:06 AM rue_shop2: so +=
02:12 AM rue_shop2: you forgot to diff it with the input voltage
02:12 AM rue_shop2: !!!!!
02:12 AM rue_shop2: welcome?
02:12 AM rue_shop2: THANKYOU
02:13 AM rue_shop2: wait, what
02:40 AM rue_shop2: attenuation is still double
03:25 AM rue_mohr: why dont you do a low pass and take the output off the resistor
03:25 AM rue_mohr: I cant think
03:25 AM rue_mohr: drat
04:17 AM rue_mohr: oh yea, nyquest
04:18 AM rue_mohr: its still 40db/decade
04:18 AM rue_mohr: maybe your freq is wrong?
04:19 AM rue_mohr: for(t = 0; t < (M_PI*2*CYCLES); t += ((M_PI*2)/SR))
04:19 AM rue_mohr: cycles is 2
04:20 AM rue_mohr: SR is sample rate
04:20 AM rue_mohr: I'm stepping forward 1 cycle, divided by the sample rate
04:21 AM Tom_L: morning
04:21 AM rue_mohr: heh
04:21 AM rue_mohr: Vi = sin(t*freq);
04:21 AM rue_mohr: if the freq is 1, I see two cycles
04:22 AM rue_mohr: with the number of points determned by the sample rate
04:22 AM rue_mohr: so, lets do a test
04:25 AM rue_mohr: so if I set it to 60Hz, and do a run, I get 8000 points
04:25 AM rue_mohr: it always does 2 seconds of processing
04:28 AM Tom_L: no more skool to distract ehh?
04:30 AM rue_mohr: nope
04:31 AM rue_mohr: I sure hope I passed that last govt test
04:31 AM rue_mohr: cause I dont think I could possibly get that all back in my head to do it again
04:32 AM Tom_L: heh
04:34 AM rue_mohr: its like my freq is off by 2 somewhere
04:37 AM rue_mohr: oh
04:37 AM rue_mohr: oooh
04:37 AM rue_mohr: nope, its right
04:37 AM rue_mohr: @500sps I get 1000 points and 2 cycles for 1Hz
01:24 PM polprog: i dont think the actual dsp code does virtual caps and resistor codes
01:24 PM polprog: they probably
01:24 PM polprog: use the transfer function and then idk
01:24 PM polprog: >_<
01:24 PM polprog: thats difficult
01:24 PM rue_mohr: no
01:24 PM rue_mohr: but I'm trying to do that and its just out
01:25 PM rue_mohr: I'm using my RC library, which I'm sure was checked
01:25 PM rue_mohr: do you have time to take a look for errors
01:25 PM rue_mohr: its like the freq is out, but I'm sure its not
01:26 PM polprog: im pretty damn tired :/
01:49 PM rue_mohr: cant for the life of me see whats wrong
01:49 PM rue_mohr: maybe I'm doing the gain wrong
01:50 PM rue_mohr: I'll test that bit
03:26 PM rue_shop1: the memeory failure is intermittent
04:09 PM Tom_L: partial memory loss
04:16 PM rue_mohr: ok I have an idea
04:16 PM rue_mohr: I'm gonna set the gain of my filter to 50% and see what it says
04:16 PM rue_mohr: it should be -10db
04:20 PM rue_mohr: aha!
04:20 PM rue_mohr: -13.86db
04:20 PM rue_mohr: !!! wrong!
04:20 PM rue_mohr: Vo = Vi/2.0;
04:20 PM rue_mohr: if (t > (M_PI*2)) {
04:20 PM rue_mohr: if (Vo > Ph) Ph = Vo;
04:20 PM rue_mohr: if (Vo < Pl) Pl = Vo;
04:20 PM rue_mohr: }
04:20 PM rue_mohr:
04:20 PM rue_mohr: }
04:20 PM rue_mohr: Vopp = Ph - Pl;
04:21 PM rue_mohr: Av = 20.0*log(Vopp/2.0);
04:21 PM rue_mohr: I think I see why
04:21 PM rue_mohr: no I dont
04:28 PM rue_mohr: wtf with log?
04:30 PM rue_mohr: printf("wtf: %f\n", 20.0*log(0.5));
04:30 PM rue_mohr: wtf: -13.862944
04:30 PM rue_mohr: ... natural log, wait a sec
04:33 PM rue_mohr: Av = 20.0*log(Vopp/2.0)/2.302585093;
04:33 PM rue_mohr: ok!
04:34 PM rue_mohr: log10 (3) - base-10 logarithmic function
04:34 PM rue_mohr: }:/
04:35 PM rue_mohr: its like I'm being watched by a million people who can see what I'm doing wrong and dont say a word
04:36 PM * Tom_L could fit that description other than the knowing what's wrong bit
04:37 PM polprog: there arent that much of us here
04:37 PM polprog: i hope we will have digital filtering as a part of some curricullum
04:37 PM rue_mohr: no, but
04:38 PM rue_mohr: polprog, in your C code, make SURE to use log10 instead of log
04:38 PM polprog: :D
04:38 PM polprog: it's a mess
04:39 PM rue_mohr: oo thats a sexy curve now
04:39 PM polprog: forgot to lock the workshop doors :D?
04:40 PM rue_mohr: the simulation is working good
04:41 PM rue_mohr: I need to do log sample points tho
04:41 PM rue_mohr: .1 .2 .3 ... 0.9 1, 2, 3, 4
04:43 PM rue_mohr: tho I'm still having a hard time confirming the rolloff
04:45 PM rue_mohr: http://ruemohr.org/~ircjunk/tempimage/foo.png
04:45 PM rue_mohr: is that -20db/decade
04:45 PM polprog: id say -10
04:46 PM rue_mohr: what
04:46 PM rue_mohr: where it goes linear
04:46 PM polprog: ah
04:47 PM polprog: yeah its close
04:47 PM rue_mohr: the rolloff is supposed to even out at -10/decade
04:47 PM polprog: could use a full decade of linearity
04:47 PM rue_mohr: -20
04:47 PM rue_mohr: yea
04:48 PM rue_mohr: hahah
04:48 PM polprog: what
04:48 PM rue_mohr: double doesn't have enough dynamic range
04:48 PM polprog: haha
04:48 PM polprog: was about to ask did you hit the resolution range :P
04:48 PM rue_mohr: maybe I'll change to long double?
04:49 PM rue_mohr: I'll start at 400Hz
04:49 PM rue_mohr: by the way, if you want to check, thats supposed to be a low pass with 1k and 1uF
04:49 PM polprog: 6dB per octave
04:49 PM rue_mohr: 20db/decade
04:50 PM polprog: thats the same thing
04:50 PM rue_mohr: that got me, I, at some point, thought it was 6db/decade
04:50 PM polprog: yeah
04:50 PM rue_mohr: I dont know how long that scerwed me up for
04:50 PM rue_mohr: definitly years
04:50 PM rue_mohr: possibly about 10
04:51 PM rue_mohr: I'm trying to snap a good range
04:52 PM rue_mohr: arg, its not quite on
04:53 PM rue_mohr: I'm getting like 18.something/decade
04:53 PM rue_mohr: oh its slightly bent tho
04:53 PM rue_mohr: -6db to -25db
04:54 PM rue_mohr: 300Hz to 3kHz
04:54 PM rue_mohr: is 20 supposed to be a bad approximation
04:54 PM rue_mohr: one of those 1% things?
04:56 PM polprog: i think 20 comes from the transfer function
04:56 PM polprog: https://en.wikipedia.org/wiki/Roll-off
04:56 PM rue_mohr: but is it supposed to be *exactly* 20 or like 19.623523616123535
04:56 PM polprog: exactly
04:57 PM polprog: you got maths there, they start from the A = 1/(1+iwRC) function
04:57 PM rue_mohr: I dont think it is
04:57 PM rue_mohr: I think they are both approximite cause someone didn't care about the extra places
04:57 PM rue_mohr: school stuff is SCREWED up that way
04:58 PM polprog: the only approximation there is for w^2 >> 1 but that is fine
04:58 PM polprog: it all works out
04:58 PM rue_mohr: then why isn't my simulation rolling at -20
04:58 PM rue_mohr: ok, my -3db for this 1k / 1uF low pass is 159Hz
04:59 PM rue_mohr: (+- a tiny bit)
04:59 PM rue_mohr: 159.00000000 -3.00516908
04:59 PM rue_mohr: does that jive?
04:59 PM polprog: yeah
04:59 PM polprog: thats the number for 1k 1u
04:59 PM rue_mohr: ok
04:59 PM rue_mohr: so my simulator is ok now
05:00 PM rue_mohr: now I just need to rework it to be doable on an avr
05:00 PM rue_mohr: with a high pass
05:00 PM rue_mohr: :) did you end up memorizing 1k 1uF?
05:01 PM polprog: it kinda started to show up often
05:01 PM polprog: :)
05:01 PM rue_mohr: :)
05:01 PM rue_mohr: 158.00000000 -2.97789309
05:01 PM rue_mohr: 159.00000000 -3.00516908
05:01 PM rue_mohr: 160.00000000 -3.03349372
05:02 PM rue_mohr: it was a sweep from 30Hz to 3k, in 1Hz steps
05:13 PM rue_mohr: it explains why that FIR had such a sharp rolloff
05:14 PM rue_mohr: over 1400 people looking at my FIR chart and nobody mentioned that the rolloff was out by about 2.3
05:23 PM rue_mohr: huh
05:23 PM rue_mohr: the FIR is second order
05:23 PM rue_mohr: 40db/decade
05:23 PM rue_mohr: interesting
05:24 PM rue_mohr: I wonder what a plain old differentiator is
05:25 PM rue_mohr: I dont think a differentiator has a pole
05:25 PM rue_mohr: or do I do a high pass
05:25 PM rue_mohr: or work on something outside
05:29 PM Tom_L: you're waste deep in this, may as well continue
05:29 PM rue_mohr: if I go outside, I could we waste deep in my yard
05:29 PM rue_mohr: literally
05:32 PM rue_mohr: polprog, aandrew I'm using gnumeric to make the charts, do you know something ... else?
05:32 PM polprog: gnuplot, which will probably make any chart if you ask it nicely
05:32 PM polprog: downside is you need to write a script but you could automate plotting that way
05:33 PM polprog: i do that all the time
05:33 PM rue_mohr: its always the same chart
05:33 PM rue_mohr: log x, linear y...
05:33 PM polprog: yeah, so it could even take data on stdin
05:35 PM rue_mohr: its funny I get aliasing cause I'm simulaing the sampling
05:38 PM rue_mohr: hmm
05:38 PM rue_mohr: the idea I had for a HP filter isn't playing out
05:38 PM rue_mohr: the gain doesn't hit 0db
05:39 PM rue_mohr: its leveling off around -0.2
06:05 PM rue_mohr: interseting
06:06 PM rue_mohr: the diff starts to come apart as it hits 0db
06:06 PM rue_mohr: but its *exactly* 20db/decade
06:11 PM polprog: gnuplot is nice, i need to find if there is a way to make it plot live in a window
06:11 PM polprog: it would be super cool, gpib + gnuplot
06:12 PM polprog: id just turn the freq gen frequency and it would measure the amplitude
06:13 PM polprog: and display it livr
06:13 PM polprog: live
06:13 PM rue_mohr: http://ruemohr.org/~ircjunk/tempimage/foo10.png
06:13 PM rue_mohr: differentiator
06:13 PM rue_mohr: no poles
06:14 PM rue_mohr: some alias noise on the end tho
06:14 PM rue_mohr: whats the dynamtic range of 8 bits?
06:14 PM polprog: 8 bits? 0 to 255
06:14 PM polprog: whats 20 log10(255)
06:14 PM rue_mohr: ~ -48db
06:15 PM rue_mohr: 1/256th...
06:15 PM polprog: yeah
06:15 PM polprog: 2 bytes give you 96 db if unsigned
06:18 PM rue_mohr: whats the positive gain?
06:18 PM rue_mohr: or I guess 48db
06:18 PM rue_mohr: 8 bits
06:18 PM rue_mohr: ok
06:22 PM rue_mohr: so
06:22 PM rue_mohr: I dont want a differentiator because I want the gain to level off?
06:23 PM rue_mohr: hmm
06:23 PM rue_mohr: I'm trying to compensate out a low pass system
06:23 PM rue_mohr: Even a high pass will add to the low freqs
06:24 PM rue_mohr: I suppose the expectation is that the low-pass system bottoms out somewhere
06:25 PM rue_mohr: how do I design the high pass to properly compliemnt the low pass
06:25 PM rue_mohr: do I match the -3db points?
06:25 PM rue_mohr: I cant find anything online about this
06:33 PM Tom_L: https://www.electronics-tutorials.ws/filter/band-stop-filter.html
06:36 PM rue_mohr: the idea is that the result of the 2 filters is flat
06:36 PM rue_mohr: want to boost the highs where the low pass starts to roll off
06:36 PM rue_mohr: ya close that band-stop
06:38 PM rue_mohr: ok if I can simulate both high and low pass, I can play with it
06:42 PM polprog: allpass filter?
06:43 PM rue_mohr: well, ponder this
06:43 PM rue_mohr: PID
06:43 PM rue_mohr: P = bypass channel
06:43 PM rue_mohr: D = highpass channel
06:43 PM rue_mohr: I = lowpass channel
06:43 PM rue_mohr: now, there are no poles
06:43 PM rue_mohr: so, you cant adjust anything freqency wise
06:43 PM rue_mohr: you can only adjust the gains
06:44 PM rue_mohr: if you only had PD, the slopes are the same, so, they would cancel out
06:44 PM rue_mohr: -----
06:44 PM rue_mohr: chaning the P and D gain moves the intersection point of the two profiles
06:44 PM rue_mohr: are you able to follow here?
06:45 PM rue_mohr: P gain: -------
06:45 PM rue_mohr: D gain /
06:45 PM rue_mohr: I gain \
06:45 PM rue_mohr: natural system -----\
06:46 PM rue_mohr: compensation required ______/
06:57 PM Tom_L: follow? i'm not even on the path :)
06:57 PM rue_mohr: PID
06:58 PM Tom_L: funny thing, on my PID for the spindle i didn't use P I or D
06:58 PM rue_mohr: yea, but PID
06:58 PM rue_mohr: its a 3 band EQ
06:59 PM rue_mohr: dont tell me I lost ya
07:00 PM Tom_L: i'm here but don't know much about what you're doing
07:00 PM Tom_L: so rather than sounding stupid i'll watch
07:00 PM rue_mohr: doesn't matter
07:00 PM rue_mohr: PID
07:00 PM rue_mohr: is a 3 band EQ
07:00 PM rue_mohr: D is a high pass (treble)
07:00 PM rue_mohr: I is a low pass (base)
07:00 PM rue_mohr: bass?
07:00 PM rue_mohr: meh
07:01 PM Tom_L: bass
07:01 PM rue_mohr: and P is like a bypass
07:01 PM rue_mohr: thanks
07:01 PM rue_mohr: you good with that bit eh?
07:02 PM Tom_L: i never stopped to figure it out, just fiddled til it worked the best i could get
07:02 PM rue_mohr: just like the stereo?
07:04 PM Tom_L: you don't have a jacobs chuck on your mill do you?
07:04 PM Tom_L: or one that would fit it
07:04 PM rue_mohr: the sherline does
07:05 PM rue_mohr: a 1/4" one
07:05 PM rue_mohr: uses a taper
07:05 PM rue_mohr: and pullrod
07:05 PM rue_mohr: why didn't my integrator work
07:06 PM Tom_L: do you have a precision dowel pin?
07:06 PM Tom_L: i was gonna have you check the runout on it sometime
07:06 PM rue_mohr: no
07:07 PM Tom_L: i wanna see if it's the chuck or the adapter i made
07:07 PM rue_mohr: oh I have some ground rod tho
07:07 PM Tom_L: i get pretty good runout on the original sherline taper adapter too
07:07 PM Tom_L: i may make a couple more and see if they turn out better
07:08 PM Tom_L: of these 2 one is not too bad but the other i doubt i can use
07:18 PM rue_mohr: https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQlw_xMq-JRdDXCjS8LFbfhdlxi_HciBSdGjg&usqp=CAU
07:18 PM rue_mohr: why is there a 1/T in there?
07:19 PM Tom_L: does that invert it?
07:19 PM rue_mohr: not sure what their up to
07:21 PM Tom_L: https://ccrma.stanford.edu/~jos/pasp/Digital_Differentiator_Design.html
07:21 PM Tom_L: https://eeweb.engineering.nyu.edu/iselesni/nb_lowdiff/nb_lowdiff_slides.pdf
07:26 PM rue_mohr: my diff is working ok
07:26 PM rue_mohr: for SOME REASON I just cant get an integrator to work
07:27 PM rue_mohr: oh wait a sec...
07:27 PM rue_mohr: maybe thats how I have it backwards
07:28 PM rue_mohr: https://www.dsprelated.com/blogimages/RickLyons/Goertzel_Misconception_fig1.JPG
07:29 PM rue_mohr: I put a call out to my guru
07:31 PM rue_mohr: which means the normal integrator code may not be right
07:31 PM rue_mohr: can you find a good crash course on gnuplot?
07:32 PM rue_mohr: freq Av
07:32 PM rue_mohr: 10.00000000 inf
07:32 PM rue_mohr: 10.10000000 inf
07:32 PM rue_mohr: 10.20000000 inf
07:32 PM rue_mohr: 10.30000000 inf
07:32 PM rue_mohr: ^^ nope
07:33 PM rue_mohr: oh
07:33 PM rue_mohr: no that just turned into what I already tried
07:33 PM rue_mohr: ARG
07:36 PM rue_mohr: ok I'll start again
07:37 PM rue_mohr: https://circuitdigest.com/sites/default/files/projectimage_tut/Operational-Amplifier-Integrator-Circuit.png
07:37 PM rue_mohr: Vo +=
07:38 PM rue_mohr: I cant find any z plane block diagrams for any filters
07:38 PM rue_mohr: not even a differentiator
07:38 PM rue_mohr: wonder if there is anything in the boots
07:38 PM rue_mohr: books
07:42 PM rue_mohr: it says maybe I forgot an inversion
07:58 PM rue_mohr: https://circuitdigest.com/sites/default/files/projectimage_tut/Operational-Amplifier-Integrator-Circuit.png
07:58 PM rue_mohr: cmon rue, digitize
07:58 PM rue_mohr: you did it right before
07:58 PM rue_mohr: we didn't retest that code
07:58 PM rue_mohr: we should
07:59 PM rue_mohr: maybe we should spend the rest of the night rebuilding the file server?
07:59 PM rue_mohr: hmm
07:59 PM rue_mohr: so many threads
07:59 PM rue_mohr: ok, just quick
07:59 PM rue_mohr: I = -Vi/R
08:00 PM rue_mohr: is it?
08:00 PM rue_mohr: yes
08:00 PM rue_mohr: Vc += I/C
08:00 PM rue_mohr: is it?
08:00 PM rue_mohr: yes
08:01 PM rue_mohr: Vo = Vc
08:01 PM rue_mohr: I can try it
08:01 PM rue_mohr: but doesn't that have a pole?
08:01 PM rue_mohr: no
08:01 PM rue_mohr: well
08:02 PM rue_mohr: its got a slew rate
08:02 PM rue_mohr: hmm, so it has to have a pole
08:02 PM rue_mohr: so a differentiator has no poles but an integrator does?
08:02 PM rue_mohr: no wait the slew rate is variable, your trying to trick me
08:11 PM aandrew: man y'all are a bunch of chatty kathys tonight
08:12 PM aandrew: how goes?
08:14 PM rue_mohr: I cant code up an integrator properly
08:14 PM rue_mohr: I keep getting a high pass with a pole
08:15 PM rue_mohr: and I dont understand how its going wrong
08:28 PM aandrew: hm
08:29 PM aandrew: "code up" as in while (1) { acc += in * fb; } ?
08:33 PM Tom_L: https://www.youtube.com/watch?v=9QUtcfyBFhE
08:34 PM Tom_L: http://webpages.ursinus.edu/lriley/doc/gnuplot/gnuplot_tutorial/gnuplot_tutorial.html
08:43 PM rue_mohr: aandrew, I have a loop that generate sine wave points
08:44 PM rue_mohr: and I tried summing them
08:44 PM rue_mohr: but its not comming out how I expect
08:44 PM rue_mohr: I expect a low pass filter with no poles
08:45 PM rue_mohr: for(t = 0; t < (M_PI*2*CYCLES); t += ((M_PI*2)/SR)) {
08:45 PM rue_mohr: Vol = Vo;
08:45 PM rue_mohr: Vi = sin(t*freq);
08:45 PM rue_mohr:
08:45 PM rue_mohr: Vo += -Vi/1000;
08:45 PM rue_mohr: bascially
08:50 PM rue_mohr: cycles is a misnomber, I'm simulating 2 seconds of signal
08:52 PM rue_mohr: its implied that an integrator is not the inverse of a differentiator
08:54 PM rue_mohr: Vo = Vi - (Vi - Vil);
08:54 PM rue_mohr: is a "stricty the difference of a differentiator"
08:57 PM rue_mohr: why didn't that work
08:59 PM rue_mohr: thats the opposite of the gain tho
08:59 PM rue_mohr: cause your only left with -Vil
08:59 PM rue_mohr: vi - vi - vil
08:59 PM rue_mohr: = -vil
09:00 PM rue_mohr: well, damnit
09:02 PM rue_mohr: I think that should have worked
09:02 PM rue_mohr: what are we missing now?
09:03 PM rue_mohr: I'm starting to run out of ideas
09:03 PM rue_mohr: its ok, we have a lot of straws left
09:03 PM * Tom_L looks at the pile of straw and sees a sparkle from a needle at the bottom
09:09 PM rue_mohr: I dont understand
09:09 PM rue_mohr: what is the inverse of this
09:09 PM rue_mohr: you would think if I take whats being trimmed off and make it whats being saved, it would naturally be the inverse
09:14 PM rue_mohr: OMG
09:14 PM rue_mohr: omg omg omg
09:14 PM rue_mohr: this is not it either!
09:14 PM rue_mohr: :/
09:15 PM rue_mohr: arg I really need a peer on this
09:17 PM rue_mohr: if I make a proper integrator, the output of it will be a sine wave with a phase difference
09:20 PM rue_mohr: a differentiator outputs the difference of what was coming in between the two sample times
09:20 PM rue_mohr: an integrator outputs the
09:21 PM rue_mohr: integral of the input something something something
09:22 PM rue_mohr: this is frustrating
09:22 PM rue_mohr: how about the sum of
09:22 PM rue_mohr: ok,
09:22 PM rue_mohr: an integrator outputs the sum of something something something
09:23 PM rue_mohr: how about the sum of the difference of the inputs
09:23 PM rue_mohr: we tried that
09:23 PM rue_mohr: I dont remember
09:25 PM aandrew: what are you integrating? it seems you could simulate this in excel way more quickly
09:25 PM rue_mohr: a sine wave
09:26 PM rue_mohr: so, the bode plot for a diff looks like /
09:26 PM rue_mohr: its a high pass filter
09:26 PM rue_mohr: I expect that an integrator should look like \
09:26 PM rue_mohr: but thats not what I'm getting
09:28 PM * rue_mohr walks over and picks up the carrot, inspects it and tosses it aside
09:30 PM rue_mohr: and my integrators are showing too much gain
09:30 PM rue_mohr: so I must have something fundamentally wrong
09:30 PM rue_mohr: Rue, you still with me?
09:30 PM rue_mohr: yep, no ideas
09:31 PM rue_mohr: I dont get why that inverse amplitude thing didn't work
09:31 PM Tom_L: out of curiosity, wtf is this for?
09:31 PM rue_mohr: digital filters
09:31 PM rue_mohr: this bit wasn't supposed to be hard
09:33 PM aandrew: I get a nice gaussian distribution if I integrate a sine wave
09:34 PM rue_mohr: but the integral of sin(x) should be cos(x)
09:34 PM rue_mohr: shouldn't it?
09:35 PM aandrew: yeah it looks about that
09:35 PM rue_mohr: but
09:35 PM aandrew: not the same amplitude
09:35 PM aandrew: but my integrator is ACC += 0.25*sin(x)
09:35 PM rue_mohr: but if you do a freq sweep, the amplitude should do \
09:35 PM rue_mohr: aka, low pass
09:36 PM rue_mohr: http://paste.debian.net/1180401/
09:36 PM rue_mohr: thats broken right now, but a differentiator is Vo = Vil - Vi;
09:37 PM rue_mohr: and the bode plot is / (high pass)
09:38 PM aandrew: hm it's not cos()
09:39 PM aandrew: https://ibb.co/yNj4hMH
09:40 PM rue_mohr: vert offset is broken
09:40 PM aandrew: well blue is on left, orange on right
09:41 PM rue_mohr: if you do that with a neutral sine wave (-1 =-> +1)
09:41 PM aandrew: that is
09:41 PM rue_mohr: ...
09:42 PM aandrew: look at the right vertical axis. it's just sin(0-360)
09:42 PM rue_mohr: I'm confused
09:42 PM aandrew: orange ranges -1 to 1
09:42 PM aandrew: it's just sin(angle)
09:42 PM aandrew: left is acc += sin(angle) * gain
09:43 PM aandrew: blue not left, although blue axis is on left
09:44 PM rue_mohr: wolfram says you have an error...
09:44 PM rue_mohr: https://www.wolframalpha.com/input/?i=sin%28x%29%2C+%E2%88%ABsin%28x%29
09:44 PM rue_mohr: it ways the integral of sin(s) is -cos(x)
09:45 PM aandrew: I'm quite sure I'm not doing the integral correctly
09:45 PM aandrew: I'm literally doing acc += sin(x)
09:45 PM rue_mohr: I been trying for hours
09:45 PM rue_mohr: and I dont know what I'm doing wrong
09:45 PM rue_mohr: yea
09:45 PM rue_mohr: so, what do we have wrong
09:46 PM rue_mohr: I wonder if the integral of a sine wave doesn't work in discrete time that well
09:48 PM rue_mohr: http://paste.debian.net/1180403/
09:48 PM rue_mohr: apparently isn't right
09:52 PM rue_mohr: "the general antiderivative of sin(x) is -cos(x) + C"
09:54 PM rue_mohr: maybe I should watch V(t) in my code
09:57 PM rue_mohr: oh...
09:58 PM rue_mohr: http://ruemohr.org/~ircjunk/tempimage/foo3.png
09:59 PM rue_mohr: this is not the integral your looking for
10:00 PM aandrew: yeah this is what I was getting
10:12 PM rue_mohr: the gain is Pi
10:13 PM rue_mohr: I think the offset is 1
10:26 PM rue_mohr: I balanced it!
10:27 PM rue_mohr: Vo = -1;
10:27 PM rue_mohr: Vo += Vi / M_PI ;
10:28 PM rue_mohr: Vo = -1 being the initialization situation
10:34 PM aandrew: sure, but why / M_PI?
10:35 PM aandrew: that is just scaling
10:35 PM aandrew: but yes -1 should have been obvious
10:35 PM aandrew: I'm embarassed to have missed that
10:37 PM rue_mohr: well, I think the Pi has to do with a half cycle
10:38 PM rue_mohr: ok, this is integrating properly
10:39 PM rue_mohr: http://ruemohr.org/~ircjunk/tempimage/foo4.png
10:39 PM rue_mohr: ^^^ see I fixed it
10:41 PM aandrew: :-) congrats
10:42 PM rue_mohr: !!! that fixed it!
10:42 PM aandrew: without the M_PI it should look the same, just bigger
10:42 PM aandrew: right?
10:43 PM rue_mohr: hold on I have a guy talking in my ear
10:43 PM rue_mohr: http://ruemohr.org/~ircjunk/tempimage/foo99.png
10:44 PM Tom_L: i knew it all along...
10:44 PM Tom_L: :)
10:44 PM rue_mohr: oh
10:44 PM rue_mohr: I compensated for the gain specifically at 1khz
10:55 PM rue_mohr: I don't get what bend the graph before tho
10:55 PM rue_mohr: or I bet I know
10:55 PM rue_mohr: my peak detector probably broke with the offset
10:56 PM rue_mohr: that might also be the reason for the tail on that graph
10:59 PM rue_mohr: http://ruemohr.org/~ircjunk/tempimage/foo100.png
10:59 PM rue_mohr: yea, ok
10:59 PM rue_mohr: that was probably the reason for the distortion too
10:59 PM rue_mohr: OK!
10:59 PM rue_mohr: my test system was broken!
11:00 PM rue_mohr: it seems that the diff and int hit 0db at the nyquest freq
11:00 PM rue_mohr: wait, maybe not
11:01 PM rue_mohr: thats 20ksps
11:03 PM rue_mohr: oh yea, it dipps under 0db
11:05 PM rue_mohr: 3333.00000000 0.00078766
11:05 PM rue_mohr: 3333.10000000 0.00055139
11:05 PM rue_mohr: 3333.20000000 0.00031508
11:05 PM rue_mohr: 3333.30000000 -0.04765336
11:05 PM rue_mohr: 3333.40000000 -0.00015755
11:05 PM rue_mohr: 3333.50000000 -0.00039388
11:05 PM rue_mohr: 3333.60000000 -0.00063022
11:07 PM rue_mohr: so, the answer is that you were right
11:07 PM rue_mohr: my profiler was broken
11:07 PM rue_mohr: and, the output wave is ugly casue its offset and scaled
11:08 PM rue_mohr: so, now I have an integrator, a differentiator, and a low pass filter
11:08 PM rue_mohr: I might know what I need for a high pass
11:08 PM rue_mohr: (RC)
11:09 PM rue_mohr: but what I wanted to do is see how they interact
11:10 PM rue_mohr: oh now thats interesting
11:12 PM rue_mohr: yea ok, I have to be carefull with my peak detector
11:12 PM rue_mohr: it bends the bode plot if it doesn't like its input
11:12 PM rue_mohr: ok!
11:13 PM rue_mohr: ok I need to think