One thing to be aware of: If your application runs the motors in the same direction for long periods of time, absolute position will keep increasing even though relative position doesn't change. If HAL still uses single precision (32bit) floats, you eventually might start losing resolution. If HAL uses double precision it will probably take a very long time before that happens. But you are still looking at small differences between large (and constantly increasing) numbers - never a good thing.
A more elegant solution would involve hacking the Mesa firmware so that each encoder counter accepts counts from two sources: one source is the motor encoder, and the other is a "reference encoder". Every "forward" pulse on the reference encoder increments the position counter, while every "forward" pulse on the feedback encoder decrements the position counter. (And vice-versa for "reverse" pulses.) That way the position counter always tells you the position difference between the reference and feedback, which remains small no matter how long your run the machine. Feed that difference to the feedback input of a PID loop, feed your desired phase angle to the command input, and you are done. If your encoder frequency is low enough to be counted in software, LinuxCNC already has a component called "encoder_ratio" which does exactly that. Just set "master-teeth" and "slave-teeth" both to 1. http://linuxcnc.org/docs/html/man/man9/encoder_ratio.9.html On Wed, Dec 13, 2017, at 04:31 AM, andy pugh wrote: > On 13 December 2017 at 03:21, Ralph Stirling > <ralph.stirl...@wallawalla.edu> wrote: > > We have a project requiring four servo motors run synchronously, with > > the ability to adjust the phase angle between motors. The motors will > > be ramped up and down in velocity (remaining synchronized), but with > > programmable phase offsets. > > This sounds relatively easy. Whatever you do one motor is going to > have to be the reference (zero shift) motor, so program that with a > straightforward velocity PID. > Then the other motors are phased relative to that, and their PID > feedback needs to be difference between the zero-shift motor position > and their own position, whilst their command is the required phase > shift. > > It sounds like you need 4 PID components and three sum2 components > (with negative gain on one input) > > -- > atp > "A motorcycle is a bicycle with a pandemonium attachment and is > designed for the especial use of mechanical geniuses, daredevils and > lunatics." > — George Fitch, Atlanta Constitution Newspaper, 1916 > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Emc-users mailing list > Emc-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/emc-users -- John Kasunich jmkasun...@fastmail.fm ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users