#robotics Logs

Jan 13 2021

#robotics Calendar

12:15 AM rue_bed2: so, I wonder if a PID filter or a high/low pass combination will compensate better for my servo
12:22 AM rue_bed2: The RC filter is more sane, so I think it will win, and its more controllable
01:37 AM flav0r: yeah
01:37 AM flav0r: give it a shot !
01:51 AM Jak_o_Shadows: I'm just glad you're using a computer to plot the bode diagrams
01:51 AM Jak_o_Shadows: I was having flashbacks I was
01:51 AM Jak_o_Shadows: (from the paper ones)
02:05 AM mrdata-: rue_bed2, what happens if you change the sampling frequency?
02:05 AM mrdata-: does that 10.5 factor also change?
02:06 AM mrdata-: because in the code you showed me, the shortest time interval ws 0.1 RC
02:06 AM mrdata-: what if it's 0.01 RC?
02:18 AM mrdata-: there are some mathematical properties to think about
02:18 AM mrdata-: starting with, limit as x -> 0 of (1+x)^(1/x) = e
02:20 AM mrdata-: and you can get a rough approximation with, say, 1.05 ^ 20 = 2.653
02:20 AM mrdata-: but it looks like there are 10 iterations, only, in your formula, not 20
02:21 AM mrdata-: 1.05 ^ 10 = 1.6289
02:24 AM mrdata-: how this is significant? RC / sample interval = 10 which is only 5% away from 10.5 and if you got that by comparing the digital output to a trace on a physical low pass with 1 k R and 1 uF cap, then it's within component tolerance
02:32 AM mrdata-: at 10x the sample rate, does that magic constant change from 10.5 to 105? or some other value?
02:41 AM flav0r: 1.05
02:53 AM rue_bed2: the ~10.5 is for about the same as 1k and 1uF
02:53 AM rue_bed2: you can put in about anything,
02:53 AM flav0r: well i started this print
02:53 AM flav0r: so thats good !
02:54 AM flav0r: what do you people use for 3d modeling of parts etc ?
02:54 AM rue_bed2: 10 itterations?
02:55 AM rue_bed2: the cutoff is affected proportionally with sample freq
02:55 AM rue_bed2: but the darn numberical factor I dont have a handle on yet
02:56 AM Jak_o_Shadows: flav0r, I use autodesk inventor
02:56 AM rue_bed2: according to the maths, it LOOKS like it should be RC, but its not linear
02:57 AM rue_bed2: so mrdata- yes, 10.5 to 105 if the sample rate changed by 10x
02:57 AM rue_bed2: I use librecad and openscad
02:58 AM rue_bed2: I make 2d profiles in librecad and then extrude them/csg in openscad its MUCH faster than only using openscad
02:58 AM rue_bed2: mrdata-, 10.5 isn't the accurate number
02:59 AM rue_bed2: I spent hours trail&erroring it
02:59 AM rue_bed2: the accurate number is...
03:00 AM sorki is now known as srk
03:00 AM flav0r: i think i might learn fusion 360
03:00 AM rue_bed2: 10.4929582
03:00 AM flav0r: i dont do much designing parts etc. and right now i just use designspark mechanical
03:00 AM Jak_o_Shadows: Rue's approach isn't bad
03:00 AM rue_bed2: with a sample rate of 10khz
03:01 AM Jak_o_Shadows: I think I would try to learn freecad, but I bounce off it too hard
03:01 AM Jak_o_Shadows: openscad's not my thing, not parametric
03:01 AM rue_bed2: it helps a lot when you just extruding and csging profiles
03:01 AM rue_bed2: see my things on thingiverse
03:02 AM Jak_o_Shadows: For sure - it's the only sane way to do openscad I think
03:04 AM rue_bed2: mrdata-, I think that there is another factor tho, the sampling, the high pass I got today shows a *bit* on gain, 0.4db which, digging into, seems to be sampling error
03:04 AM rue_bed2: as I dial up the sample rate, it tones down
03:07 AM rue_bed2: flav0r, have you been able to follow the filter stuff I been doing?
03:10 AM rue_bed2: mrdata-, I think you have a good handle on this, for now I'm almost out of questions, less that damned magic constant
03:11 AM rue_bed2: it took a lot of work to pin down that number,
03:11 AM rue_bed2: and I wonder if its out by some sampling error
03:12 AM rue_bed2: I might need to add some noise to the code to get better points on the simulation
03:14 AM rue_bed2: the avr can sample at 4kHz, and the servo hits its major pole somewhere under 4Hz
03:14 AM rue_bed2: so I think I'm ok for room, I'll start combining filters tommorow
03:14 AM Jak_o_Shadows: TBH, I think i'm more interested in your simulation than real
03:15 AM rue_bed2: I want to do a bode sweep on a PID
03:15 AM rue_bed2: I'm satisfied the simulation is within real performance expectations
03:17 AM rue_bed2: then I'd like to set up a highpass filter with the same approx properties that I used on the servo I did and see if it will substitute
03:17 AM mrdata: rue_bed2, did you compare the response to real components? or to a theoretical response
03:18 AM rue_bed2: I'm just doing bode sweeps of the code
03:18 AM rue_bed2: it took me this long to get a working high pass without the exponential function
03:19 AM rue_bed2: but now I have the 4 parts I want to play with mixing, a high-pass, low-pass, integrator and differentiator
03:20 AM rue_bed2: I know how the real RC filters perform
03:20 AM rue_bed2: I'v been there
03:20 AM mrdata: ok, i think i found something interesting
03:20 AM rue_bed2: something just seems wrong about the way PID is done, I need to see it
03:21 AM rue_bed2: mrdata, if you want, I can post code for the high and low pass
03:21 AM rue_bed2: its set to generate csv data for
03:21 AM mrdata: (10.4929582/10)^10 = 1.618
03:21 AM rue_bed2: "excel"
03:21 AM rue_bed2: !!!!
03:22 AM rue_bed2: isn't 1.618 e!?
03:22 AM mrdata: no, it's phi
03:22 AM rue_bed2: hu?
03:22 AM mrdata: e is 2.718281828
03:22 AM mrdata: yeah hu
03:22 AM rue_bed2: phi?
03:22 AM mrdata: phi is the root of the formula, 1+x = 1/x
03:24 AM rue_bed2: I only tried e and Pi in my search
03:24 AM mrdata: phi = 1 + sqrt(5) / 2
03:25 AM rue_bed2: so
03:25 AM rue_bed2: T for 1k / 1uF is..
03:25 AM rue_bed2: .001 ?
03:25 AM mrdata: so your magic constant to more digits might here be 10.492978041576143067537035084822
03:25 AM rue_bed2: omg omg
03:26 AM rue_bed2: if T was .001 for me there
03:27 AM rue_bed2: arg, I cant put this togethor
03:27 AM rue_bed2: k = fn(T,phi)
03:28 AM rue_bed2: its 1am tho
03:28 AM rue_bed2: I'm supposed to be asleep
03:29 AM rue_bed2: (100*T*1.0492978041576143067)^10 =
03:30 AM mrdata: i dont think it's raised ^10
03:30 AM rue_bed2: where T=RC ?
03:30 AM rue_bed2: I'm havin problems, I think a good part of my brain is sleeping
03:30 AM mrdata: the 10 comes in because 10 = RC / sample-rate
03:31 AM rue_bed2: oh yea, the sample rate was 10000
03:31 AM rue_bed2: so 10000*.001 = 10
03:31 AM mrdata: so call this x
03:31 AM rue_bed2: cause RC was .001
03:32 AM rue_bed2: x = SR*T
03:32 AM mrdata: x = RC / sample-rate; then your magic constant might be, phi^(1/x) * x
03:32 AM rue_bed2: but
03:32 AM rue_bed2: RC is .001
03:32 AM rue_bed2: SR is 10000
03:33 AM rue_bed2: oh I want to go try it now!!
03:33 AM mrdata: oh i meant sample interval delta-t
03:33 AM rue_bed2: x*phi^(1/x) ?
03:33 AM mrdata: give it a shot
03:34 AM rue_bed2: cant now, its 1am, in 5 hours my alarm goes off and I have to go to work
03:35 AM mrdata: sure, when ever
03:35 AM mrdata: if it doesnt wormk then the qty 1.618 is a coincidence
03:35 AM rue_bed2: for SR = 10000, RC=0.001, do we get 10.49... ?
03:36 AM mrdata: x = RC * SR = 10; k = x * ph^(1/x)
03:36 AM mrdata: k = 10.492978041576143067537035084822
03:36 AM rue_bed2: :)
03:37 AM rue_bed2: damn, thats like the last mystery
03:37 AM mrdata: i think there are too many digits for it to be a mere coincidence
03:37 AM rue_bed2: yea
03:37 AM rue_bed2: as I was refining it, I was getting a feel for what places were solid, and I'm confident your right
03:38 AM rue_bed2: wow this is awesome good work!
03:38 AM mrdata: yw
03:45 AM rue_bed2: I think I'll make a notebook on this all
03:45 AM rue_bed2: I had to re-derive my lowpass filter to get the highpass working
03:45 AM rue_bed2: so, there are a number of good notes now
03:47 AM rue_bed2: but at the same time, I'v not seen FIR/IIR used for servo loops
04:31 AM rue_mohr: something is wrong with the Fc formula that school gave me, its not 1/RC
04:32 AM rue_mohr: 1/2PiRC
04:32 AM rue_mohr: wtf
04:33 AM rue_mohr: those notes are from tech school back in 1998
04:33 AM rue_mohr: nowonder I was getting everything wrong
04:34 AM rue_mohr: that, rolloffs of 6db/decade and -3db being 50% amplitude, I was doomed
04:40 AM mrdata-: tau = RC; the 2 pi comes in because of circles
04:40 AM mrdata-: but,
04:40 AM mrdata-: e comes in, too
04:41 AM Jak_o_Shadows: e comes in a lot
04:41 AM mrdata-: yes
04:41 AM mrdata-: rise time = RC
04:41 AM rue_mohr: yea, I have an e^ version
04:41 AM mrdata-: for digital signals
04:41 AM mrdata-: because of a trick
04:41 AM rue_mohr: I'm just doing up a program so I can feed in Fc and get k
04:42 AM rue_mohr: 2:30am
04:42 AM mrdata-: RC is the interval required for signal voltage to change by rthe factor e
04:42 AM mrdata-: so whenyou make low <= 0.8 V and high > 2.5 volts (ish) then high / low = e
04:44 AM rue_mohr: I need to re-gather my RC notes
04:44 AM mrdata-: maybe it isnt 2.5 but 2.25, i dont recall precisely
04:44 AM rue_mohr: I have the DC and AC stuff spread into different sections
04:44 AM mrdata-: mhm
04:45 AM mrdata-: so if RC = 0.001 then voltage can change by factor 2.71828 in 0.001 s
04:46 AM rue_mohr: my mental picture of this all is getting really messed up with the digtial simulation stuff
04:47 AM Jak_o_Shadows: Yeah, that's a whole 'nother way of thinking that is
04:47 AM Jak_o_Shadows: I don't tend to think that translating the analog too directly works well
04:48 AM rue_mohr: well
04:48 AM rue_mohr: the interesting bits are when you do thigns like use an if statement to handle the slope
04:49 AM rue_mohr: I cant get into that now tho, too much branching
04:55 AM rue_mohr: ok, it missed -3db gain on the high pass, but the whole response is shifted up about 0.5db, and if you account for that, its bang on
04:58 AM rue_mohr: low pass is bang on
04:58 AM mrdata-: cool
04:59 AM rue_mohr: I wonder if I can work out a compensation for the gain on the high pass
04:59 AM rue_mohr: not now
04:59 AM rue_mohr: I thought it was just a high freq sampling error
04:59 AM rue_mohr: that proves its constant
05:00 AM rue_mohr: wow cooool
05:01 AM rue_mohr: http://paste.debian.net/1180914/
05:01 AM rue_mohr: u is for uF ;)
05:13 AM rue_mohr: phi makes sense as a constant for recursion
05:16 AM rue_mohr: http://paste.debian.net/1180915/
05:16 AM rue_mohr: cleanup
11:01 AM briand2 is now known as AI4AI
07:22 PM Tom_itx is now known as Tom_L
10:55 PM rue_mohr: ok I need to PID constants to emulate
11:01 PM rue_mohr: anyone here know how to use gnuplot?