The bldc.c component computes the two-phase sin/cos terms from phase angle, but I don't think it outputs them, so a very slight modification would be necessary. The sin/cos output values would be connected to PWM inputs in hostmot2, which would generate the actual signals for two H-bridges to switch the motor phases. The Mesa card generates the high speed PWM. A 1kHz servo thread should be sufficient for computing the sin/cos values. Here are the relevant lines in bldc.c:
sintheta = sin(phase_angle * pi2); costheta = cos(phase_angle * pi2); A_value = out_abs * costheta; B_value = out_abs * (costheta * cos120 + sintheta * sin120); C_value = out_abs * (costheta * cos120 - sintheta * sin120); The sintheta and costheta are appropriate for two-phase steppers, and the A, B, and C_values are for three-phase bldc motors. The sintheta and costheta values could be multiplied by the output of a PID loop to adjust the amplitude based on torque or velocity requirements. Bldc connects to an encoder counter to track rotor angle. -- Ralph ________________________________________ From: Chris Albertson [albertson.ch...@gmail.com] Sent: Wednesday, January 12, 2022 5:41 PM To: Enhanced Machine Controller (EMC) Subject: Re: [Emc-users] Field Oriented Control (FOC) algorithm for BLDC and Stepper motors. CAUTION: This email originated from outside the Walla Walla University email system. So how would I connect the four wire stepper motor to my PC to allow for software commutation and continuous rotation of a stepper? If this works, it could save people money by eliminating the need for a VFD spindle drive and also People are paying quite a lot for these self-contained "closed-loop steppers" If this can already be done in software how? But I have serious doubts a Linuc PC has good enough timing even with an RT kernel. But in theory, how to connect the stepper? On Wed, Jan 12, 2022 at 1:26 AM andy pugh <bodge...@gmail.com> wrote: > On Wed, 12 Jan 2022 at 01:28, Chris Albertson <albertson.ch...@gmail.com> > wrote: > > > This library would allow the stepper to be commanded > > as if it were a serial interfaced servo motor. > > In principle so does LinuxCNC HAL and the "bldc" HAL component. > > -- > 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, 1912 > > > _______________________________________________ > Emc-users mailing list > Emc-users@lists.sourceforge.net > https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Femc-users&data=04%7C01%7Cralph.stirling%40wallawalla.edu%7Cd905773e126a482dd8ab08d9d635e8eb%7Cd958f048e43142779c8debfb75e7aa64%7C0%7C0%7C637776349295328651%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=c2gJ5So48tGLS0ru6%2Fdp6hyrZeGgtYU9A02nJ78jrOU%3D&reserved=0 > -- Chris Albertson Redondo Beach, California _______________________________________________ Emc-users mailing list Emc-users@lists.sourceforge.net https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Femc-users&data=04%7C01%7Cralph.stirling%40wallawalla.edu%7Cd905773e126a482dd8ab08d9d635e8eb%7Cd958f048e43142779c8debfb75e7aa64%7C0%7C0%7C637776349295328651%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=c2gJ5So48tGLS0ru6%2Fdp6hyrZeGgtYU9A02nJ78jrOU%3D&reserved=0 _______________________________________________ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users