#garfield Logs

Feb 19 2024

#garfield Calendar

01:29 AM rue_mohr: obfuscated_d, ?
11:45 AM rue_mohr: the idea is to be able to mimic the armature of a stepper with a DC motor
01:13 PM rue_shop3: obfuscated_d, check this out
01:13 PM rue_shop3: http://ruemohr.org/%7Eircjunk/tempimage/8000sample.png
01:13 PM rue_shop3: now, I thought this was just a strange glitch from not enough sampling
01:13 PM rue_shop3: but I had it do 8000 samples last night
01:14 PM rue_shop3: the 'nice' bits of the curve are the constructed table values
01:14 PM rue_shop3: but the jaggy ones are where it settled on when it did self-training
01:14 PM rue_shop3: see the hugs gaps??
01:14 PM rue_shop3: see the huge gaps??
01:15 PM rue_shop3: X is the table index (velocity) and Y is the stopping distance
01:31 PM rue_shop3: --
01:31 PM rue_shop3: heh, I'm not sure how many steps its doing
01:39 PM rue_shop3: ok, 10 lines for this (tiny bit of drift) is 18.3Hz, 12.8% duty
01:41 PM rue_shop3: which, according to scope is 47.65ms forward, and 7ms reverse
01:41 PM rue_shop3: --\
03:09 PM obfuscated_d: rue_shop3 where do you think the gaps are coming from?
03:16 PM rue_shop3: well, its data points that the self-correction never hits
03:17 PM rue_shop3: which means that there are some velocity values that the system jumps right over
03:17 PM obfuscated_d: ahh
03:17 PM rue_shop3: which is a strange thought
03:17 PM rue_shop3: so, I have a catch
03:17 PM rue_shop3: I dont know how many lines are on my encoder for 1 rev of the geared output
03:18 PM rue_shop3: so I dont know how big to make step, so I can try to get the controller to replicate the steps
03:18 PM rue_shop3: rifraf, !
03:18 PM obfuscated_d: need to figure out the gear ratio
03:19 PM rue_shop3: its 6.3:1
03:19 PM rue_shop3: according to the sticker
03:19 PM rue_shop3: oh, and according to me, its a 500 line encoder
03:19 PM rue_shop3: huh
03:19 PM rue_shop3: well done
03:47 PM rifraf: ?
03:48 PM rifraf: off to work, good old time difference
04:34 PM obfuscated_d: had to make some dinner
04:35 PM rue_shop1: yup
04:35 PM obfuscated_d: you say you're off to work?
04:38 PM rue_mohr: for a few days
04:38 PM rue_mohr: which, according to scope is 47.65ms forward, and 7ms reverse
04:38 PM rue_mohr: so,
04:38 PM rue_mohr: oh right
04:38 PM rue_mohr: 500*6.3
04:38 PM rue_mohr: 3150 pulses/rev
04:39 PM rue_mohr: so I should set a step to 315
04:39 PM rue_mohr: or 1260 depending on the quadrature
04:40 PM Tom_L: 1261
04:40 PM rue_mohr: ?
04:41 PM Tom_L: then you can use the error as an index signal :)
04:41 PM rue_mohr: heh
04:41 PM rue_mohr: my brain still wont turn
04:42 PM rue_mohr: I need to modify the code for steps that big and see what timing it does
04:49 PM rue_shop3: ok I have fixed3 self-training on that size step
04:49 PM obfuscated_d: nice!
04:53 PM rue_shop3: hmm
04:53 PM rue_shop3: its using 49ms forward drive for the same step
04:54 PM rue_shop3: so, its got the right order of magnitude
04:54 PM rue_shop3: but
04:55 PM rue_shop3: oh
04:55 PM rue_shop3: hmm
04:55 PM rue_shop3: ok, so get this
04:56 PM rue_shop3: the fixed3 code, is, for a 1/10 step, using 48.6ms forward and 7.6ms reverse
04:56 PM rue_shop3: using the signal generator, I got 47.65ms forward, and 7ms reverse
04:56 PM rue_shop3: but then the fixed3 code chatters
04:56 PM rue_shop3: whats to be learned from this?
04:57 PM obfuscated_d: does it still chatter with a larger dead zone?
04:57 PM obfuscated_d: I wonder if the ~1ms longer forward has something to do with code execution time
04:58 PM rue_shop3: I could bring up the deadzone
04:58 PM rue_shop3: I set the entire table to 10, I want to more clearly see what it comes out with
04:58 PM rue_shop3: 1ms is ages for these controllers
04:59 PM obfuscated_d: true
04:59 PM rue_shop3: hmm, I'll toggle an io to see just how much
04:59 PM rue_shop3: oh
04:59 PM rue_shop3: fixed3 has a delay in it
04:59 PM rue_shop3: Delay(2000);
04:59 PM rue_shop3: hmmmmm
04:59 PM obfuscated_d: is that ns?
05:00 PM obfuscated_d: or clock cycles?
05:00 PM rue_shop3: bogo cycles
05:00 PM rue_shop3: its an just a nop loop
05:00 PM rue_shop3: I'm not sure how many cycles there are to 1 count
05:01 PM rue_shop3: tahts under nopDelay.c
05:01 PM obfuscated_d: pretty sure nop is one cycle
05:01 PM obfuscated_d: which at 16mhz is ~4ns I think
05:01 PM rue_shop3: yes, but its in a loop
05:01 PM rue_shop3: with setup times, and compares and adds and stuff
05:02 PM rue_shop3: there are about 724637 to 1 second
05:02 PM obfuscated_d: you think the nopDelay function accounts for that to give an accurate result for the commanded delay?
05:02 PM rue_shop3: I just put in the number that makes it work
05:02 PM rue_shop3: oh
05:02 PM obfuscated_d: ah
05:02 PM rue_shop3: no
05:03 PM rue_shop3: it does the step, then delays, then does another
05:03 PM obfuscated_d: should be okay than
05:03 PM rue_shop3: the delay limits the rate it can do new step attempts
05:03 PM rue_shop3: hahaha
05:03 PM rue_shop3: I forgot to setup the capture the result
05:04 PM rue_shop3: what I dont quite understand it how it learns so fast
05:05 PM rue_shop3: I swear in the first 20 step attempts its got it tuned
05:05 PM Tom_L: dc motor?
05:05 PM rue_shop3: yes
05:05 PM rue_shop3: this is enc_pwm_egmk_fixed3
05:05 PM Tom_L: http://wiki.linuxcnc.org/cgi-bin/wiki.pl?Stepper_Drive_Timing
05:05 PM Tom_L: for a range of stepper timing
05:06 PM rue_shop3: I'm stepping the dc mtoor
05:06 PM Tom_L: i know
05:06 PM rue_shop3: its doing a 1260 line step in 50ms
05:06 PM rue_shop3: er, 57 on my good capture
05:06 PM Tom_L: those are in ns
05:07 PM rue_shop3: yep this control alg has to be working before I get that far
05:12 PM rue_shop3: so
05:13 PM rue_shop3: here is a question, obfuscated_d
05:13 PM obfuscated_d: what's up
05:13 PM rue_shop3: if we did one step and just turned off the drive for a second, how long would it take for the mechanics to just settle
05:13 PM rue_shop3: wow this is crazy
05:14 PM obfuscated_d: for the motor to stop spinning?
05:14 PM rue_shop3: 4000 steps and it doesn't hit all the different velocities in the table
05:14 PM rue_shop3: yea
05:14 PM rue_shop3: or resonating or whatever
05:14 PM obfuscated_d: we'd have to measure each motors performance on that
05:15 PM rue_shop3: well, with any of these we need to profile the system
05:15 PM rue_shop3: but
05:15 PM rue_shop3: I wonder if the mechanics are always going to just ring for a while and then settle on the right position if we dont do anything
05:16 PM obfuscated_d: well, no system is perfectly rigid
05:17 PM rue_shop3: and there needs to be a way to hold a load
05:17 PM rue_shop3: so practically, the drive cant just be shut off
05:17 PM rue_shop3: but we can 'bump' it with 1 line error
05:17 PM obfuscated_d: so, do we step, stop where we think we should, then wait a few ns before we check the position again?
05:17 PM rue_shop3: more than ns
05:17 PM rue_shop3: it takes ~1ms for anything to start really moving at all
05:18 PM rue_shop3: somewhere I have that data that shows how long it takes the armature of a stepper motor to start moving after the coil is energized
05:18 PM rue_shop3: its still a long time
05:21 PM obfuscated_d: might be worth taking one "step" then stop it and monitor the encoder for a few ms. see what that looks like
05:22 PM obfuscated_d: might tell us something
05:22 PM rue_shop3: that state-like code could do that better
05:22 PM rue_shop3: would you like to rough somehting out, I'll play with this self training and try to compare results
05:23 PM obfuscated_d: for the state machine? yeah I can work on that
05:23 PM rue_shop3: I have mine building a table, I'd like to see what kinda velocities never get modified
05:24 PM rue_shop3: I'll abandon fixed4 and pick up with you on the state machine ver as fixed5
05:27 PM rue_shop3: ok I thought this was a glitch, but it keeps comming up
05:27 PM rue_shop3: ...
05:29 PM rue_shop3: http://ruemohr.org/%7Eircjunk/tempimage/6000sample.png
05:29 PM rue_shop3: this is really noisy, but
05:29 PM rue_shop3: I set the entire table to 10 before it started
05:29 PM rue_shop3: so anything not 10, it changed
05:29 PM rue_shop3: see how it goes to 0 between 143 and 182?
05:30 PM rue_shop3: mostly focus on the blue line, the purple is reverse and it wasn't running that way
05:32 PM rue_shop3: that dip to zero and back up has been in every self-training data set so far
05:34 PM obfuscated_d: seems like 0 shouldn't be happening
05:34 PM rue_shop3: means it hit the target
05:34 PM obfuscated_d: that would mean instant stop right/
05:35 PM rue_shop3: but I ahve this code averaging the error when doing the adjustments
05:35 PM obfuscated_d: oh okay, I was reading it wrond
05:35 PM obfuscated_d: wrong
05:35 PM rue_shop3: but yea, it means there was 0 error
05:35 PM rue_shop3: at those velocities
05:36 PM rue_shop3: gonna reset it all to 128 for more contrast in modified values.
06:08 PM rue_shop3: interesting
06:10 PM rue_shop3: http://ruemohr.org/~ircjunk/tempimage/6000sampleB.png
06:10 PM rue_shop3: same dip to zero
06:10 PM rue_shop3: and a huge gap between 39 and 100
06:11 PM rue_shop3: ok, it implies that if you are too slow to the target, you dont make it there
06:12 PM rue_shop3: I'll try it in the other direction
06:13 PM rue_shop3: those last two graphs kinda agree well
06:17 PM rue_shop3: I think after this run I'll have all the data its possible to get
06:18 PM rue_shop3: obfuscated_d, shall I send you a copy of v4 that I'm abandoning?
06:19 PM obfuscated_d: nah, I'm working through the logic of this now. it's almost there for a basic example
06:19 PM rue_shop3: https://paste.debian.net/1307887/ hah, I pasted too fast, there it is anyhow :]
06:31 PM obfuscated_d: here's where I'm at right now. It needs some deadzone added in, and I don't think I have all the direction logic correct at the moment. but, it kinda works in forward. I picked an arbitrary decel start point of 1/2 the error, which is wrong. maybe need a decel position table. IDK, still working on it, but maybe take a look so far, and see if it
06:31 PM obfuscated_d: makes any sense, maybe stop me before I spend too much time haha https://paste.debian.net/1307888
06:32 PM obfuscated_d: needs the coast logic as well, again, it's just a starting point
06:33 PM obfuscated_d: those prints are supposed to be strings . I copy/pasted before I changed it
06:35 PM obfuscated_d: right now it's oscillating often, since there's no deadzone in the accel/decel functions
07:02 PM obfuscated_d: oh boy, yeah there were quite a few wrong things in what I pasted, it's getting slightly better
07:04 PM obfuscated_d: but, maybe you can see what I'm thinking, by having the decel function like that, I think with some tweaking(and better logic honestly), it sort of handles the coasting/bumping to a stop
07:08 PM obfuscated_d: hello?
07:28 PM rue_mohr: erp, sory I'm back
07:28 PM obfuscated_d: no worries, I'm actually about to head to bed. I'm getting somewhere, I'm going to hit it again in the morning. Little foggy, getting late
07:28 PM rue_mohr: ok, want to throw me an update?
07:30 PM rue_mohr: I can chew on it for a while
07:34 PM obfuscated_d: sure , here's the last that wasn't completely broken. It's not great https://paste.debian.net/1307892. only doing forward at the moment
08:09 PM rue_mohr: ok, I'll see what I can do!