#garfield Logs
Mar 24 2019
#garfield Calendar
12:00 AM zhanx: nothing yet, same as last year so far, 14 esp's
12:05 AM zhanx: i started seeds today for it
12:05 AM zhanx: i have a 6 week staggered start for them
12:14 AM Tom_L: you can grow peppers that far north?
12:14 AM zhanx: yep, tent the whole time for heat
12:16 AM Tom_L: are you about the same latitude as rue?
12:17 AM zhanx: yea but, huge difference in climate
12:17 AM zhanx: i am way higher in elevation
12:17 AM Tom_L: oh
01:18 AM rue_mohr: https://tutorial.cytron.io/2012/06/22/pid-for-embedded-design/
01:18 AM rue_mohr: my damping term addeda pole
01:34 AM rue_mohr: ah well thats a useless article, no antiwindup or anything
07:42 PM zhanx: rue_mohr, i have sprouts in 2 of the 4 pots i started last week
07:48 PM rue_mohr: k
07:53 PM zhanx: so, my suv is still in the shop
07:54 PM zhanx: shocks came in wrong, wheel bearing is fixed, brake caliper was wrong
07:54 PM zhanx: tires came in R16 instead of R15
07:54 PM zhanx: can i catch a break?
08:06 PM rue_mohr: wow
08:06 PM rue_mohr: so, from powering the servomotor, no motion is seen for 1ms
08:06 PM zhanx: i ordered parts by vin fyi
08:08 PM zhanx: is that an issue?
08:18 PM rue_mohr: well I have to keep it in mind
08:18 PM rue_mohr: I'm using 1Khz pwm, so
08:18 PM rue_mohr: I'm clocking the feedback loop on the pwms counter rollover
08:20 PM Tom_L: so what's goin on?
08:20 PM rue_mohr: took a nap, trying to work out this servo
08:20 PM rue_mohr: part of the reason pid dosn't work for me
08:20 PM rue_mohr: is the fact that
08:21 PM rue_mohr: my loop, would get only up to 3 counts for velocity each cycle
08:21 PM Tom_L: rather coarse sample rate
08:21 PM rue_mohr: so I'm redoing how I meter the speed
08:21 PM rue_mohr: but I'm using that LM2907 method, and the math is hokey
08:22 PM Tom_L: ran another part with the adjustments.. turned out alot better
08:22 PM rue_mohr: nice.
08:22 PM Tom_L: LM2907?
08:22 PM zhanx: need to add some functions to c-log
08:22 PM Tom_L: like what?
08:23 PM Tom_L: i can turn you loose with the code...
08:23 PM zhanx: chip definitions etc
08:23 PM Tom_L: somebody has to enter it all
08:24 PM zhanx: thats fine, i can add it as we go
08:24 PM rue_mohr: no, its all in GIICM
08:24 PM rue_mohr: or the site that was it
08:24 PM zhanx: LM2907 devices are monolithic frequency-to-voltage converters with a high gain op amp
08:26 PM zhanx: Tom_L, the one function i would like to see is when some posts a link the bot, gives a summary
08:26 PM rue_mohr: aka rpm measurement
08:26 PM rue_mohr: tigger could do it
08:27 PM zhanx: tigger has a huge database that is for sure
08:27 PM rue_mohr: did anyhow
08:27 PM rue_mohr: no telling how much of a labotomy it got
08:27 PM zhanx: did she kill it?
08:27 PM rue_mohr: :/
08:27 PM rue_mohr: yea
08:27 PM zhanx: that is wrong
08:28 PM rue_mohr: hmm
08:28 PM rue_mohr: I got proportionate working
08:28 PM rue_mohr: I want to make a straight integral drive
08:29 PM rue_mohr: got to have a really slow pickup rate tho
08:30 PM Tom_L: would wind up really slow
08:30 PM Tom_L: if it ever got to the setpoint...
08:30 PM rue_mohr: integral has too
08:31 PM rue_mohr: I cant think tho
08:32 PM rue_mohr: I want to use the integral to control velocity till its at position, I cant manage the math in my head to know what level that is
08:32 PM rue_mohr: (PID)
08:32 PM Tom_L: setp pid.0.Pgain 1
08:32 PM Tom_L: setp pid.0.Igain 3.5
08:32 PM Tom_L: setp pid.0.FF0 1
08:32 PM Tom_L: setp pid.0.maxerror 200
08:33 PM Tom_L: that's on my mill spindle
08:33 PM rue_mohr: if the integrator is feeding a speed, I think thats P
08:33 PM rue_mohr: thats for spindle, yes?
08:34 PM Tom_L: yeah
08:34 PM Tom_L: i use a near component to for loading and floating 'near' the setpoint
08:34 PM Tom_L: kindof a buffer area
08:35 PM Tom_L: setp near.0.scale 1.40
08:35 PM Tom_L: maybe that's to balance the signal to the motor with the encoder count.. i can't remember
08:36 PM zhanx: pid is something i need to learn
08:38 PM Tom_L: i was doing a plunge cut with it and the spindle bounced back pretty good
08:41 PM Tom_L: i _was_ a little nervous the first time i sent the .250" cutter straight down into the steel with only .6 hp behind it
08:44 PM rue_mohr: zhanx, pid is easy
08:44 PM rue_mohr: real world pid SUCKS
08:44 PM Tom_L: every case is a little different
08:45 PM rue_mohr: making sure the differentiator has resolution, integrator antiwindup, bounding, rollover
08:45 PM zhanx: if i had a week to sit down, no kids i could learn it
08:46 PM zhanx: but with work, kids, life its a pita
08:46 PM rue_mohr: its making a system around it to make it work thats the issue
08:46 PM Tom_L: zhanx been there done that
08:46 PM rue_mohr: I'm trying to work out a better way to measure speed
08:46 PM zhanx: yep i know, i am waiting for rue's turn on that Tom_L
08:46 PM rue_mohr: I know that in 1ms I get ~3 counts in the speed range I'm targeting
08:46 PM Tom_L: he'll be too tired by then
08:47 PM rue_mohr: which is about 85 timer ticks/line
08:47 PM rue_mohr: but 1/n measurements suck too
08:48 PM rue_mohr: lets go there
08:48 PM rue_mohr: I need target units
08:48 PM rue_mohr: that make sense
08:48 PM rue_mohr: degrees/second?
08:49 PM zhanx: well in order to have kids you need a target unit yes
08:49 PM zhanx: degrees/second/ with a unit of measurement the shaft moves
08:49 PM Tom_L: resolver
08:49 PM rue_mohr: I'm targeting 60rpm
08:49 PM rue_mohr: so
08:49 PM rue_mohr: 360 degrees/sec
08:50 PM Tom_L: analog phase shift
08:50 PM rue_mohr: this works for 16 bits anyhow
08:50 PM rue_mohr: the encoder resolution is fine
08:50 PM Tom_L: iirc i used a 20ms loop on the 68332 but that was a long time ago...
08:51 PM rue_mohr: the encoder I'm playing with is roughly 3000 cpr
08:51 PM Tom_L: that's plenty
08:51 PM rue_mohr: wow, in the balancer?
08:51 PM Tom_L: i think so
08:51 PM Tom_L: i could be wrong
08:51 PM rue_mohr: its amazing how slow the world is
08:51 PM rue_mohr: ok
08:51 PM Tom_L: iirc it ran at 25Mhz
08:52 PM rue_mohr: 3000 cpr, 1rps
08:52 PM rue_mohr: 3khz
08:52 PM rue_mohr: the pwm is ~1khz
08:52 PM rue_mohr: aka 3 counts/loop
08:52 PM Tom_L: hard to tune
08:53 PM rue_mohr: Tom_L, 20ms would give me up to 60 velocity counts/control cycle, which isn't bad
08:53 PM rue_mohr: 8 bit pwm counter
08:54 PM rue_mohr: so 85 counts between lines
08:54 PM rue_mohr: the goal is to get from 85count/line to 360 degrees/sec
08:55 PM rue_mohr: so 85 counts/line
08:55 PM rue_mohr: 3000 lines/rev
08:56 PM rue_mohr: and 256000 counts/sec
08:57 PM zhanx: oh rue_mohr we got a new cat today
08:57 PM rue_mohr: bobcat?
08:57 PM zhanx: house cat i hope
08:57 PM rue_mohr: ah
08:57 PM zhanx: its hiding under my desk, wife seems to like getting recuse cats
09:02 PM rue_mohr: 256000 counts/sec * 1/85 lines/count * 1/3000 rev/line * 360 degrees/rev
09:02 PM rue_mohr: if I didn't moof that...
09:04 PM rue_mohr: 30720/85
09:05 PM rue_mohr: hmm 361.41 degrees/second
09:05 PM zhanx: slightly over
09:05 PM rue_mohr: tho...
09:05 PM rue_mohr: the real number isn't 85
09:06 PM rue_mohr: 85.333333
09:06 PM rue_mohr: calc 30720/85.3333
09:06 PM rue_mohr: 30720/85.3333 -->> 360
09:06 PM rue_mohr: ok, the math proofs out
09:06 PM rue_mohr: it shows the resolution sucks a bit, but ok
09:06 PM zhanx: math checks out with 85.3333
09:06 PM rue_mohr: hey 30720 fits in 16 bits, THATS cool
09:07 PM zhanx: double checked it for you
09:07 PM rue_mohr: :)
09:07 PM rue_mohr: I used to love playing with units
09:07 PM rue_mohr: canceling everything out
09:08 PM rue_mohr: odd, cause 30720 is a number that seems strangely familiar
09:08 PM Tom_itx: output = (p->Kp * Perror + p->Kd * (Perror - p->PrevErr) + p->Ki * p->Ierror)/p->Ko;
09:08 PM rue_mohr: integrator antiwindup?
09:08 PM Tom_itx: there's the money line on the bot
09:09 PM rue_mohr: calc "30720(ResultBase=2)"
09:09 PM rue_mohr: 30720(ResultBase=2) -->> 0b111100000000000
09:09 PM rue_mohr: maybe thats why
09:10 PM rue_mohr: Tom_itx, it was all integer wasn't it?
09:10 PM rue_mohr: I had the code open, dont see the window here right now...
09:11 PM Tom_itx: i think so, no float
09:11 PM rue_mohr: hmm, well it did have 20ms
09:13 PM Tom_itx: what did/
09:13 PM Tom_itx: ?
09:14 PM Tom_itx: see on it you could set the interrupt rate
09:15 PM Tom_itx: for a 20ms rate irq_rate needs to be 157 and for 10ms it's 78
09:15 PM Tom_itx: in my notes from way back
09:15 PM rue_mohr: yea, I can do that with a timer, I'm using an 8 bit pwm timer rollover, its clocked at 256kHz
09:15 PM rue_mohr: 1khz pwm, 1khz loop
09:17 PM Tom_itx: mcpwm_init(0, 3, period, 157); /* master channel (chan, pri, period, irq_rate15) */
09:17 PM Tom_itx: gawd that was a long time ago
09:18 PM Tom_itx: the mcpwm used a phase shift
09:18 PM rue_mohr: :)
09:20 PM rue_mohr: ok, so 30720/counts
09:20 PM rue_mohr: so then, how do I do the measurement
09:20 PM rue_mohr: every time there is a line edge, I capture the timer and do a diff
09:20 PM rue_mohr: BUT
09:21 PM rue_mohr: if there are no lines going by, I need someone to reset me to 0degrees/sec
09:21 PM rue_mohr: tho wait, if the interval is larger than 30720, I get 0 by rounding
09:21 PM rue_mohr: what is that
09:22 PM rue_mohr: 0degrees/sec
09:22 PM rue_mohr: what is the range of this thing
09:22 PM rue_mohr: 1 degrees/sec - 30720 degrees/sec
09:22 PM rue_mohr: 5120 rpm
09:22 PM rue_mohr: ok, fair enough for now
09:23 PM Tom_L: that's about where my spindle tops out
09:23 PM rue_mohr: this is the X axis motor :)
09:23 PM rue_mohr: (no, this is a test)
09:24 PM Tom_L: better gear it down
09:24 PM zhanx: no gear it up
09:24 PM Tom_L: or you might get smacked in the head with a lead screw
09:24 PM zhanx: 10:1
09:24 PM rue_mohr: the real motor is targeted at 12000 rpm w/ 100counts/rev and 19:1 gearbox
09:25 PM rue_mohr: no leadscrews
09:25 PM zhanx: print so fast you need liquid nitrogen to cool the print
09:25 PM Tom_L: and the drivers
09:25 PM rue_mohr: the Y will likley be timing belt, and the X rack/pinion
09:25 PM rue_mohr: shopvac motors
09:25 PM Tom_L: i still could bump my drivers up to 5A but i see no reason to
09:25 PM Tom_L: still running them at 2.5A iirc
09:25 PM rue_mohr: "2 HP" hahahaha
09:26 PM Tom_L: the Z axis doesn't hesitate a bit under load
09:26 PM rue_mohr: I did a torque profile for full voltage/current and got 1/2hp
09:27 PM rue_mohr: oooh maybe they meant input power
09:27 PM rue_mohr: calc 120*12/746
09:27 PM rue_mohr: 120*12/746 -->> 1.93029
09:28 PM rue_mohr: 120V, 12A, ..
09:28 PM rue_mohr: haha
09:28 PM rue_mohr: 26% eff?!
09:28 PM rue_mohr: maybe
09:29 PM rue_mohr: "maybe I should look at other motors"
09:29 PM rue_mohr: I found a really nice PM motor in the mud at the wreckers, gave 'em $5
09:29 PM rue_mohr: it works,
09:30 PM rue_mohr: huge shaft, seems bent!?
09:30 PM rue_mohr: I can deal with it
09:30 PM rue_mohr: oh I just worked out how too, hahahah
09:38 PM rue_shop1: ah no, its worse
09:38 PM rue_shop1: count is 8 bit
09:38 PM rue_shop1: I can only go down to 255
09:39 PM rue_shop1: so min. speed is 120.47 degrees/sec
09:40 PM rue_shop1: I can survive 1 rollover
09:40 PM rue_shop1: if there are two rollovers, my data is garbage
09:41 PM rue_shop1: but I almost just happen to be counting rollovers
09:42 PM rue_shop1: ok, hmmm
10:18 PM rue_shop1: I'm failing miserably here
10:21 PM Tom_L: is the dark side winning?
10:40 PM rue_mohr: right now the target is to do a speed servo
10:40 PM rue_mohr: I'm failing
10:41 PM rue_mohr: I think I need to know more of the values that are going on
10:41 PM rue_mohr: my head is all foggy and its not forthcomming
10:56 PM rue_shop1: ok, I think most of these problems are realted to the way C is handling numbers
10:58 PM rue_shop1: when I say signed_int = unsigned_int its being stupid and just copying across the binary
11:10 PM rue_mohr: need to think extra hard
11:30 PM rue_mohr: I cant do the difference like I am