BLDC component with 8i20 - how to get to work?

More
04 Jul 2024 10:13 #304372 by viesturs.lacis
Hello!

I am doing a Biesse retrofit and I am replacing original servodrives because they are showing errors and I decided to go with Mesa 8i20.
I have attached one 8i20 and am trying to get it to move the motor (belt is removed, motor is not connected to machine) without any PID modules or anything.

Here is the part of HAL file that relates to BLDC component and 8i20 pins:
loadrt bldc cfg=qi

addf bldc.0        servo-thread

setp bldc.0.scale     4000
setp bldc.0.poles    4
setp bldc.0.initvalue     0.7
setp bldc.0.init     0

# setp bldc.0.rev        1

setp bldc.0.encoder-offset     1517


setp hm2_5i24.0.8i20.0.4.current-minlim        -10
setp hm2_5i24.0.8i20.0.4.current-maxlim        10

net motor.02.rawcounts    hm2_[HOSTMOT2](BOARD).0.encoder.02.rawcounts
net motor.02.rawcounts    bldc.0.rawcounts

net motor.02.index-ena    hm2_[HOSTMOT2](BOARD).0.encoder.02.index-enable
net motor.02.index-ena    bldc.0.index-enable

net motor.02.angle     bldc.0.rotor-angle
net motor.02.angle     hm2_5i24.0.8i20.0.4.angle

net motor.02.current     bldc.0.out
net motor.02.current     hm2_5i24.0.8i20.0.4.current

net test-vel        bldc.0.value


Encoder-offset was calculated following way:
1) connected motor U to 24V, V and W to 0V
2) started LinuxCNC, halshow encoder counts and rawcounts
3) removed 24V from motor
4) setp encoder.index-enable 1
5) turn motor by hand until counts reset to 0
6) difference between counts and rawcounts is 1517

For encoder-offset value I have tried 1517, -1517, 2483 and -2483 (because 4000 - 1517 = 2483 as per suggestion by PCW somewhere in these forums).
I have tried with bldc.0.rev set to 0 and 1
I have tried bldc.0.scale both 4000 and -4000.

Signal test-vel is getting its value from pyvcp slider in range from 0 to 20 with increments of 0.1
The result I am getting:
with setp bldc.0.init 1 it starts rotor homing. With uneven motion it will finish it (initdone pin is set "true") although it is really hard to turn motor by hand with current set at 0.7
Then with slider giving input to bldc.0.value motor will snap to another position with jerking at value of around 8-10 and snap back around at 5-6.
With bldc.0.scale -4000 motor would constantly jerk with bldc.0.value at 7.4 or higher and stop jerking with bldc.0.value lower than 5.3

It was suggested that motor should turn equally fast in both directions with low current as an indication that encoder-offset parameter is correct. I just do not understand what do I need in HAL file to command the motor spin at constant speed.

I have no idea what exactly am I missing or what should I try differently, so any hints will be appreciated.

Please Log in or Create an account to join the conversation.

More
04 Jul 2024 13:25 - 04 Jul 2024 13:29 #304391 by PCW
Have you tried magnetic homing (q instead of qi)

Have you verified the encoder counts per turn?

Have you verified the number of poles?

You can do this by supplying an small current and finding the number of null positions
The number of poles is twice the number of null positions.

Have you tried with a drive offset of 90 degrees?

If you get jerky motion with a commanded move its most likely the scaling or direction
are wrong so the drive phase does not match the rotor angle


 
Last edit: 04 Jul 2024 13:29 by PCW.

Please Log in or Create an account to join the conversation.

More
04 Jul 2024 14:29 #304395 by viesturs.lacis
1) No, I did not try magnetic homing
Are there any specifics to be included in HAL file for that? Or just comment out index related stuff?
2) Yes, I did turn the motor one full turn and observe the change in rawcounts value
3) Yes I did apply small current to motor and turn it by hand and count 4 positions more or less 90 degrees apart where motor tries to snap

 

Please Log in or Create an account to join the conversation.

More
04 Jul 2024 14:43 #304397 by PCW
I would call that an 8 pole motor

Please Log in or Create an account to join the conversation.

More
04 Jul 2024 14:44 - 04 Jul 2024 14:44 #304398 by andypugh
Initially, do as I suggested in the mailing list and try to drive the motor from the command-line. Take the rest of LinuxCNC out of the picture.
Last edit: 04 Jul 2024 14:44 by andypugh.

Please Log in or Create an account to join the conversation.

More
05 Jul 2024 10:35 #304450 by viesturs.lacis
Peter you were correct. Changing pole count to 8 did the trick.
Andy, my apologies for lack of attention and overlooking that part of email. I looked at that once more this morning and had to reread your instructions several times, but in the end I have the motor spinning at (almost) constant speed if I change bldc.0.value to something around 0.5-0.8 (positive or negative).
As per the steps you described one of the electrical zero positions was at 78 encoder counts from index. I tried to turn motor both directions and the velocity is not equal for the same current, for example, velocity was around -20 for 0.2A and around 27 for -0.2A. I thought that this difference would change by adjusting the encoder offset, but what I got was the increase in velocity for the same current which seems good as if indicating more efficient action, but that difference of velocities stays the same. At encoder offset of 98 counts I have velocity around -30 for 0.2A and around 37 for -0.2A

How do I proceed from here? I tried this:
0) net b.dc.0.init-done -> pid.3.enable
1) net pid.3.output -> bldc.0.value
2) net encoder.02.pos -> pid.3.feedback
3) net encoder.02.vel -> pid.3.feedback-deriv
4) net motor.02.pos-cmd -> pid.3.command
5) net motor.02.vel-cmd -> pid.3.command-deriv

I set ferror to 1000 and have specified some PID parameters. but as I tried to jog that motor, it did not move. It did vibrate slightly and fiddling with bldc.0.init pin caused a motor runaway.
Is it just wrong pid parameters or am I missing something more, like wrong encoder scale sign (should change from positive to negative or vice versa) or something else?

Please Log in or Create an account to join the conversation.

More
05 Jul 2024 12:19 #304457 by viesturs.lacis
I found the issue in config, now I can move the motor with jog keys. Motion is shaky and springy, but since I have set P = 1 and all other PID parameters are 0, I guess that is expected.

It seems to me that PID tuning is next step.
I found this thread and particular post by PCW:
forum.linuxcnc.org/27-driver-boards/3367...sa-8i20-drive#102783

Is there anything else I should take into account?

Please Log in or Create an account to join the conversation.

More
05 Jul 2024 14:25 #304469 by viesturs.lacis
I got a runaway while following PCWs procedure and was adjusting D parameter.Is there something I should check about the config that could cause it?

Please Log in or Create an account to join the conversation.

More
05 Jul 2024 14:46 #304471 by PCW
A runaway means positive feedback

Does the motor hold position with just the P term?
I would comment these lines out:

net encoder.02.vel -> pid.3.feedback-deriv
net motor.02.vel-cmd -> pid.3.command-deriv

and try again

Also note that raising the servo thread rate (to say 4 KHz)
will improve the PID loop performance, and also that
final tuning needs to be done under load.

Please Log in or Create an account to join the conversation.

More
05 Jul 2024 20:06 #304491 by viesturs.lacis
I checked once more with P=1 and all other PID params = 0. Motor is soft but after half a turn it starts to resist and moves slightly back when released. Tried both ways.

Removed command-deriv and feedback-deriv connections.

Checked INI file - servothread is running at 2kHz.

About tuning under load - yes, I put the belt back on, motor is connected to machine. That is why I am nervous about this behavior.

The result I am getting now is that with jogging at 1m/min HalScope shows ferror of approximately 1 mm. I move in relatively small distances 10-20 mm, because overall travel is 150 mm (Z axis on Biesse machines usually have small distance of travel). And occasionaly at the start of the jog move I get runaway. I have made it to 3rd step of trying to add FF2. And I am trying really small values (P=1 and D=1.2, so I tried FF2=0.002). The feeling is that too much of FF2 cause the runaway. Does it make sense? With FF2=0 when adjusting D term I could make more than 10 jog moves and not get a runaway. Add FF2 = 0.01 and immediate runaway. Change to FF2=0.0001 and was fine. FF2=0.002 and immediate runaway. Could be pure coincidence, I have no idea.

I have set ferror limit to 5 mm and connected pid.2.enable to halui.machine.is-on so it gets disabled when ferror limit is tripped so I have managed to avoid any damage.

Any idea where to look? Should I search for flashdrive to get the config files and post them here?

Please Log in or Create an account to join the conversation.

Moderators: PCWjmelson
Time to create page: 0.692 seconds
Powered by Kunena Forum