stes wrote: I'm using Sanyo Denki P5 1kw. Would it be easiest to detect the phase by powering one of the phases at start up?
This motor has hall effect sensors also.
Using Hall sensors is the best way to get the motor initialised. This is the test script I use to set up a motor
Code:
loadrt hostmot2
loadrt hm2_pci config="sserial_port_0=00000000"
loadrt threads name1=thread1 period1=500000
loadrt bldc cfg=h
addf hm2_5i25.0.read thread1
addf bldc.0 thread1
addf hm2_5i25.0.write thread1
addf hm2_5i25.0.pet_watchdog thread1
net h1 hm2_5i25.0.7i76.0.0.input-00 bldc.0.hall1
net h2 hm2_5i25.0.7i76.0.0.input-01 bldc.0.hall2
net h3 hm2_5i25.0.7i76.0.0.input-02 bldc.0.hall3
net ang bldc.0.rotor-angle hm2_5i25.0.8i20.0.1.angle
setp bldc.0.pattern 34
start
Save that in a file somewhere called 8i20.hal. Then edit it to suit your hardware (you won't have any "7i76" pins with a 7i85, for example)
Then start a HAL session and load the script:
Code:
halrun
source 8i20.hal
Now open a some halmeters to check the hall inputs
Code:
loadusr halmeter signal h1
loadusr halmeter signal h2
loadusr halmeter signal h3
and check that the halls twiddle as you manually rotate the motor.
Now you can apply a small current to the motor and see if it spins. It probably won't as there is only a 1 in 42 chance that "34" was the correct hall pattern.
Code:
setp hm2_5i25.0.8i20.0.1.current 0.5
The motor might kick, it might buzz. It might even spin.
Now try all the hall patterns and see which one works best.
Code:
setp bldc.0.pattern 0
setp bldc.0.pattern 1
...
setp bldc.0.pattern 42
Make a note of which ones spin the motor best. You will probably find two that work well, but which spin the motor in different directions. Choose one, that is your hall pattern. A further test that it is a good pattern is to try it at higher and lower currents, and make sure that it will reverse the motor properly.
Code:
setp setp hm2_5i25.0.8i20.0.1.current 0.5
setp hm2_5i25.0.8i20.0.1.current 1
setp hm2_5i25.0.8i20.0.1.current -1
setp hm2_5i25.0.8i20.0.1.current 0.1
and so on.
Running your motors like this will work, but isn't ideal. This is trapezoidal commutation, and it is noisy and less efficient. The next stage is to switch the "bldc" component to "qh" mode, where it uses trapezoidal commutation to start, then uses the quadrature encoder for sinusoidal commutation after the first Hall transition.
So, exit halcmd, and edit the 8i20.hal file:
Code:
loadrt hostmot2
loadrt hm2_pci config="sserial_port_0=00000000"
loadrt threads name1=thread1 period1=500000
loadrt bldc cfg=qh
net rawcounts bldc.0.rawcounts hm2_5i25.0.encoder.00.rawcounts
[color=#ff0000]setp bldc.0.poles 4
setp bldc.0.scale 4000[/color]
addf hm2_5i25.0.read thread1
addf bldc.0 thread1
addf hm2_5i25.0.write thread1
addf hm2_5i25.0.pet_watchdog thread1
net h1 hm2_5i25.0.7i76.0.0.input-00 bldc.0.hall1
net h2 hm2_5i25.0.7i76.0.0.input-01 bldc.0.hall2
net h3 hm2_5i25.0.7i76.0.0.input-02 bldc.0.hall3
net ang bldc.0.rotor-angle hm2_5i25.0.8i20.0.1.angle
[color=#ff0000]setp bldc.0.pattern 34[/color]
start
The lines in red need to be set to suit your hardware. Note that there is a 50:50 chance that the bldc scale will have to be negative.
Now you should find that the motor runs smoothly under speed and direction current commands, and you can integrate the bldc and 8i20 HAL into your machine HAL configuration.
One troubleshooting tip. At the halcmd: prompt
will show you the 8i20 status, if it isn't working then there should be a clue as to why not in there, such as undervoltage, or enable not set, or whatever.