PMAC Software Setup Guide
PMAC Software Setup Guide
Application
Note
Title Setting up PMAC software
Filename App Note - PMAC.docx
Date of Creation 17/09/2009 12:28:00 by Howard Slater
Last Updated 21/03/2011 08:45:00 by Paul Shipley
Revision 14
Contents
1. Introduction ........................................................................................................................................... 2
2. What is a PMAC machine and how is it different to an induction machine. ............................... 3
3. UVW Encoder Installation ................................................................................................................... 4
4. Sin Cos Encoder Installation ............................................................................................................... 9
5. Object Dictionary Encoder Setting ................................................................................................... 21
6. Motor Parameters ...............................................................................................................................22
7. On Road eBike Applications .............................................................................................................. 26
8. Summary ............................................................................................................................................. 27
9. Extras .................................................................................................................................................... 28
Sevcon Ltd
TVTE
Gateshead
Tyne & Wear
England NE11 0QA
1. Introduction
This document is intended to guide an applications engineer through the process of setting up a
Gen4 controller using the Permanent Magnet Software.
In order to keep the document simple, the document focuses on setting up the controller to drive
the motor not the overall drivability of the vehicle. For this any other application note that deals
with drivability is applicable.
Examples of DVT command sequences are provided in several places throughout this document.
These commands are intended to provide examples of typical setup values. Although the values
provided are typical for most vehicles, the reader should not make the assumption that they are
going to work for all vehicle types. It is up to the user to investigate what function is being
performed by values being written to the unit’s object dictionary. In most cases, looking up the
object in the ‚Master Object Dictionary.xls‛ spreadsheet, the purpose will become clear.
1.1. Prerequisites
The document assumes some prior knowledge and experience:
The reader should be familiar with the concept of the object dictionary, and be familiar
with reading and writing values to and from the controller. Refer to the CANopen
specifications and software design documentation for more information.
The reader should be familiar with the overall system architecture, particularly the
distinction between vehicle application sub-systems and motor control sub-systems.
Refer to the software architecture design documentation for more information.
Knowledge of PDO functionality is also an advantage, particularly when debugging live
systems and graphing vehicle behaviour. Refer to the application note ‚PDO
Fundamentals.doc‛ for more information.
Page 2 of 28
Setting up PMAC software Commercially Confidential
The ‚synchronous‛ part of the name that is sometimes associated with PMAC motors comes
from the fact that the output frequency of the drive and the mechanical speed of the rotor are
always the same. This differs from asynchronous induction motors, where the drive’s output
frequency and mechanical motor speed are usually different. This difference, known as slip, will
always be zero in PMAC motors.
For induction machines, slip is required to transfer energy to the rotor. The motor does not
contain any brushes like a DC motor. Instead, the slip frequency causes energy to be transferred
to the rotor through induction, similar to a transformer. A constant slip frequency is required to
allow this energy transfer to take place.
In the case on a PMAC motor, the rotor magnets are permanently magnetised, and thus rotor flux
is always present. Slip is not required, and the AC output frequency can remain synchronised to
the mechanical position of the rotor.
A further consequence of the flux existing regardless of the controller being switched on or not is
that the control system no longer has any control over the angle of the flux (an induction
machine induces its rotor flux and therefore controls where it sits). Consequently, to induce
torque into the machine, the controller needs to know the angle of the flux so that its output
vector can be aligned to it. It is for this reason that PMAC motors are normally controlled with
either a UVW or sin-cos encoder. These types of encoder are designed to deliver position
information rather than speed. However it is important that the encoder signals are aligned with
the mechanical position of the rotor. Misalignment in this respect will reduce the torque per amp
available.
Page 3 of 28
Setting up PMAC software Commercially Confidential
Page 4 of 28
Setting up PMAC software Commercially Confidential
Set up a scope to monitor each of the U, V and W encoder signals, referenced to B-. Rotate the
motor in the forwards direction. If the signals are pulsing in the correct order, you should be able
to see a trace that resembles the following:
In the above example, channel 1 is connected to U, channel 2 to V, and channel 3 to W. Note that
the pulses overlap – this is normal. However, the important thing to note in this trace is that the
pulses are occurring in the correct sequence i.e. U first, then V, then W, then back to U again.
If you have a trace where the pulse sequence appears to be reversed, this can be corrected by
exchanging any of the two encoder input signals.
Please remember that this test is only valid if rotating the motor in what is considered to be the
forwards direction. If the motor is turning backwards, the pulse sequence will be different.
As a final check, you can verify that the encoder is connected correctly by monitoring the
controller’s speed measurement. Motor speed can be read from object 0x606C in the object
dictionary. You should receive a positive value when the motor is rotating forwards, and a
negative value when the motor is rotating backwards.
Page 5 of 28
Setting up PMAC software Commercially Confidential
Rotate the wheel by hand in the forwards direction. The scope trace you receive will match one of
the traces in the following sub-sections. These will describe what action should be taken.
When aligning the phase to an encoder pulse, the objective is to the back EMF cross the zero
point when the encoder edge occurs. In the above trace, we can see that the edges do not align
with the back EMF crossover.
To correct this situation, a different phase should be tested. For the scope probe that is in the
motor cables, move the probe tip to a different phase. Also, move the probe ground clip to the
motor cable that you have just removed the probe tip from. Repeat the test.
Page 6 of 28
Setting up PMAC software Commercially Confidential
In this trace, we can see that this time the encoder edges do coincide with the point at which the
back EMF crosses zero. However, the phase is reversed. For correct alignment, it is required that
the back EMF is low when the encoder signal is high.
To correct this, the connection of the ground clip and probe tip for the probe connected to the
motor cable should be reversed.
Page 7 of 28
Setting up PMAC software Commercially Confidential
The above trace shows the expected result. In this case, the encoder signal ‘U’ is aligned with the
motor phase connected to the scope. Note that the back EMF is low when the encoder signal is
high. This is correct when the motor is being rotated forwards.
If you have this graph, then the motor connections are as follows:
The motor cable connected to the probe tip should be connected to the controller’s M1
terminal.
The motor cable connected to the probe’s ground clip should be connected to the
controller’s M2 terminal.
The remaining cable should be connected to the controller’s M3 terminal.
Power down the controller and make the relevant motor terminal connections.
Page 8 of 28
Setting up PMAC software Commercially Confidential
Scope plot of sine input versus cosine input for a rotating motor
Please be aware that due to the change in the input circuit, the controller’s protection is
now limited. While excessive voltages on the input pins should not cause permanent
damage, they could affect the measured values of other inputs. Do not apply more than
5V to these inputs.
Not all Gen4 controllers have had the hardware modification for sin-cos inputs. To determine if
the controller is suitable for use with sin-cos encoders, the hardware version should be checked.
Sin-cos support is encoded into bit 24 of the hardware version, which can be read from object
0x1009,0 of the controller’s object dictionary using the following DVT command:
sdo_rns 1 0x1009 0
Page 9 of 28
Setting up PMAC software Commercially Confidential
If the motor is rotating forwards, then you will see the cosine signal leading the sine signal. So,
for the above example, the channel 1 (dark blue) represents cosine, and the signal cable
corresponding to this should be connected to pin 35 on the Gen4. Similarly, the channel 2 (light
blue) represents sine, and should be connected to pin 21 on the Gen4. In other words, the peak of
the cosine signal will occur just before the peak of the sine signal.
Please note this is only applicable when the motor is rotating forwards. If the motor is rotating
backwards, then the signals will be reversed. When setting up the motor wiring there must be a
clear convention on which motor direction constitutes as rotating in the forwards direction. While
this is straightforward for most vehicles, other vehicle types e.g. sideloaders or palette trucks the
distinction may not be as clear. Please be sure the forward direction is defined and the motor is
rotating in this direction during set up.
Page 10 of 28
Setting up PMAC software Commercially Confidential
Fortunately, the controller provides a measurement of the minimum and maximum voltages it
measures in the object dictionary. These are located in the encoder configuration object.
Object Function
0x4630, 5 Sine input minimum voltage configuration
0x4630, 6 Sine input maximum voltage configuration
0x4630, 7 Cosine input minimum voltage configuration
0x4630, 8 Cosine input maximum voltage configuration
0x4630, 9 Minimum measured voltage on sine signal
0x4630, 10 Maximum measured voltage on sine input
0x4630, 11 Minimum measured voltage on cosine input
0x4630, 12 Maximum measured voltage on cosine input
In object 0x4630, used to configure the encoder, minimum and maximum voltages for the inputs
should be written to sun-indices 5, 6, 7, and 8. The minimum and maximum voltages measured
by the controller can be read from sub-indices 9, 10, 11 and 12.
The values in these objects are measured in volts, scaled such that 0x0FFF equates to 6.0V on the
input. So, to convert these values to voltages, multiply by 6 and then divide by 4095.
The following procedure can be used to commission an encoder:
3. Connect the sine and cosine signals from the encoder to their relevant inputs.
4. Put the controller in to pre-operational and cycle power.
5. Rotate the motor shaft manually by hand, such that the controller can see the signal for
several complete revolutions. While this happens, the controller will monitor the
minimum and maximum voltages measured on the inputs. These values can be read
from sub-indices 9, 10, 11 and 12.
6. To commission the encoder, simply copy the values in sub-indices 9, 10, 11 and 12 to
their respective entries at sub-indices 5, 6, 7 and 8.
The following piece of DVT code can be used to perform the final step in the procedure, copying
the minimum and maximum voltages in as appropriate. It will also output the actual voltages it
measured, so these can be confirmed against what was measured by the scope.
proc commit {{node_id 1}} {
puts "[sdo_wnx $node_id 0x4630 5 [set r [sdo_rnx $node_id 0x4630 9]]] sin min set
to [expr $r] adc counts ([expr (6*$r/4095.0)]V)"
puts "[sdo_wnx $node_id 0x4630 6 [set r [sdo_rnx $node_id 0x4630 10]]] sin max set
to [expr $r] adc counts ([expr (6*$r/4095.0)]V)"
puts "[sdo_wnx $node_id 0x4630 7 [set r [sdo_rnx $node_id 0x4630 11]]] cos min set
to [expr $r] adc counts ([expr (6*$r/4095.0)]V)"
puts "[sdo_wnx $node_id 0x4630 8 [set r [sdo_rnx $node_id 0x4630 12]]] cos max set
to [expr $r] adc counts ([expr (6*$r/4095.0)]V)"
}
When setting the encoder voltages, it is also advised to check the magnitude of the signal.
Normally there should be at least 2V between the minimum and maximum voltage signals. Any
less than this could result in problems occurring due to poor resolution or interference from
external noise sources.
Given a valid encoder configuration, you should be able to measure a motor speed, in rpm, from
object 0x606C. The speed measurement should be stable, give a positive number when the
motor rotates forward and give a negative number when the motor rotates backwards.
Page 11 of 28
Setting up PMAC software Commercially Confidential
3 12
10
1 sin enc ip
8
0 cos enc ip
Mechanical Angle
-1 6
Electrical Angle
-2
4
-3
2
-4
-5 0
wt
Page 12 of 28
Setting up PMAC software Commercially Confidential
5
14
4
3 12
2
10
1 sin enc ip
8
0 cos enc ip
-1 6 Mechanical Angle
-2 Electrical Angle
4
-3
2
-4
-5 0
wt
The voltages on each phase rise and fall, 120 degrees out of phase. What is important to note
here is that phase M1 rises first, aligned to zero degrees. M2 rises next in sequence, 120 degrees
later. A further 120 degrees again, and M3 rises. The rotational sequence is M1, M2, M3, M1, M2,
Page 13 of 28
Setting up PMAC software Commercially Confidential
M3, etc... . The objective here is to align the back EMF of the motor to this sequence of rising
edges.
The remainder of this section of the document will assume the motor cables are labelled ‚U‛,
‚V‛ and ‚W‛. While this may not be the case with the motor you are dealing with now, the set up
procedure is still valid. The actual names of the cables are not important – providing the naming
scheme remains consistent throughout the set up process.
Sin
Cos
Enc gnd
Page 14 of 28
Setting up PMAC software Commercially Confidential
When the motor is rotated by hand, you should get a scope trace showing the back EMF along
with the sine and cosine encoder signal:
The blue lines show the encoder sine and cosine signals. The pink line is the measured motor
back EMF. The number of electrical back EMF cycles per mechanical sin-cos cycles will equal the
number of pole pairs in the motor. In this example, the motor has 4 pole pairs. Therefore, there
are four electrical rotations per mechanical rotation of the motor.
From this trace we need to measure two things:
The length of time for one complete mechanical revolution
The length of time between the encoder showing zero degrees and the start of the
phase’s electrical cycle.
The length of time for a complete mechanical revolution can be calculated by measuring how
long it takes between rising points on the sine signal. in the above trace, a trigger has been set to
activate on the sine signal crossing from a negative value to a positive value. The time between
this event and the next is 220ms. This has been marked on the trace.
The angle offset for the phase under test can be found by measuring the time between the same
point on the sine wave, and the next point after it at which the back EMF goes positive. In the
above example, this has also been marked on the trace, and is measured as 48ms.
The angle offset for this phase can be calculated using the following formula:
So, when the time to the next phase is 48ms, a full rotation is 220ms and we have 4 pole pairs,
the angle offset is 314°.
Page 15 of 28
Setting up PMAC software Commercially Confidential
Next, the process is repeated with the probe tip connected to V and the ground clip connected to
W. The following graph is obtained:
In this trace, the time is shorter, approx 10ms. For this test, the time for a single mechanical
rotation is still 220ms, as the motor was rotating at the same speed as the previous test. Using
the above equation, we get an angle offset of 65°.
Page 16 of 28
Setting up PMAC software Commercially Confidential
The final test is performed with the probe tip connected to W and the ground clip connected to U.
The following graph is obtained:
In this case, the time is 30ms. The angle offset is calculated as 196 degrees.
Page 17 of 28
Setting up PMAC software Commercially Confidential
0°
U
V
314°
65°
196°
As a final check, you should see that the vectors are approximately 120° apart. Although the
measurement scheme is not exact, there should be at least some correlation. If the vectors are
not evenly spaced, there is likely to be a measurement error and the process should be repeated.
The final step is to actually attach the cables to the motor terminals on the controller. The phase
that is closest to zero degrees is connected to M1, in this case it is U. The next phase in clockwise
rotation is connected to M2, in this case V. The next phase in clockwise rotation again is
connected to M3, in this case W.
Page 18 of 28
Setting up PMAC software Commercially Confidential
The ‚S8.8‛ at the end of the command indicates this is a signed number in 8.8 format. Replace
<angle> with the desired offset angle. The following examples are all valid:
sdo_wnx 1 0x4630 4 [ af 7 S8.8 ]
sdo_wnx 1 0x4630 4 [ af 12.3 S8.8 ]
sdo_wnx 1 0x4630 4 [ af -5.8 S8.8 ]
Before starting the alignment procedure for the first time, the offset value should be reset back to
zero:
sdo_wnx 1 0x4630 4 [ af 0 S8.8 ]
Now with the controller in operational, request a small amount of drive demand against an
unladen motor. Try to find a level of drive torque that gives the following:
Torque demand should be absolutely constant. You can use a pot to set the torque
demand, or set demands directly from the DVT. If you only have an accelerator pedal,
don’t try to hold a steady demand using your foot – it won’t be accurate enough. Instead,
set 100% accelerator push to be a low torque demand (e.g. 5%) and hold it there.
The motor should be spinning steadily, ideally somewhere between 1000 and 2000 rpm.
The motor should not be in field weakening, i.e. Id_ref should remain constantly at zero.
This may take only 5% of drive torque but providing the motor is spinning steadily, the test can
be performed.
The idea here is to run the motor with the target d-axis current set to zero. Controlling zero amps
on the d-axis should take zero volts, but if there is an error in the angle then we start to see
current from the q-axis couple on to the d-axis. The end result is that while zero amps is being
controlled, it takes a small amount of d-axis voltage to maintain it.
With the motor running, look at Ud. If it appears to be operating at around zero volts, then this is
a sign that the encoder is closely aligned. If Ud is too low or too high then the encoder alignment
may need to be adjusted. Comment [hjs1]: What about corss
coupling of the voltage, there will be some
It is best to experiment with this to see how adjusting the offset angle affects Ud. While the Ud voltage due to iq depending upon
motor is running, increase the angle by one degree at a time and monitor what happens to Ud. electrical frequency and motor inductances.
Typically, if Ud is lower than zero then the angle offset should be increased, and if Ud is higher
than zero then the angle offset should be decreased.
Page 19 of 28
Setting up PMAC software Commercially Confidential
Page 20 of 28
Setting up PMAC software Commercially Confidential
Page 21 of 28
Setting up PMAC software Commercially Confidential
6. Motor Parameters
In comparison to the flux vector induction machine algorithm the permanent magnet software is
far less dependent upon motor parameters.
Like the Flux Vector code the PMAC code uses two current references, ‘D’ and ‘Q’. The D axis
current controls the flux and the Q axis current controls the torque. Because the motor has its
field provided by the magnets the D axis current is usually controlled to 0A.
In contrast to Induction Machine control the parameters required for PMAC control are
considerably simpler.
1) Current control gains
2) Field weakening control gains
3) Maximum modulation index
4) Minimum field weakening current
5) Maximum stator current.
6) Back EMF constant Ke
7) Power limit table.
6.3. Is Max
This is defined as a maximum short term current rating of the motor. Care must be taken with
thermal protection and duty so that motor is not overheated in long term operation.
This direct relationship between current and torque can be used when setting maximum torque
settings.
Page 22 of 28
Setting up PMAC software Commercially Confidential
Vline
Ke
e
Where Vline is the rms line to line voltage generated and we is the electrical frequency. Clearly
this can be easily measured with the motor not connected to the controller. If the motor is rotated
externally, and the line voltage is captured on an oscilloscope.
Page 23 of 28
Setting up PMAC software Commercially Confidential
There is a PI control loop which attempts to limit the applied voltage to the maximum motoring
mod index (0x4641 sub 30) usually set to 90%. This PI loop reduces Id demand below zero down
to a minimum of the value set as the minimum magnetising current 0x4641 sub 3.
This number must be entered as a negative number, the value is range checked to ensure that
only numbers 0 and less are set in the object.
The number is an 1 amp per bit format, so for example if -50A was required as the minimum
value then a value of 0xffce has to be entered into 0x4641 sub 3. The following table shows a
selection of minimum magnetising currents and the correct 16.0 format number:
Minimum Magnetising current 0x4641 sub 3, 16.0 format
-5A 0xFFFB
-25A 0xFFE7
-50A 0xFFCE
-75A 0xFFBD
-100A 0xFF9C
The gains of the PI controller which reduces Id reference are the usual field weakening controller
gains freq_Kp and freq_Ki which are set via 0x4641 sub 25 and sub 26 respectively.
In to prevent unexpected behaviour of the motor the current controllers must always be in
control this is managed by keeping the mod index away from 1. In order to do this field
weakening must be allowed to control the Id reference to the value which allows the mod index
to be held at 90% up to the value of Is max.
60
50
40
Torque Nm
30
20
10
0
0 200 400 600 800 1000
speed RPM
It was found on early applications that the power limit table if not known could be derived on the
application. This was done be setting the power limit values flat, i.e. all torques set to the
maximum value. The vehicle was then driven and a DVT trace taken of the Iq current. The actual
current would reduce naturally as the speed increases even though the reference was constant,
the current controllers would be saturated. The Ke constant could then be used in the
Page 24 of 28
Setting up PMAC software Commercially Confidential
relationship between torque and Iq in order to calculate what torque would result in the actual Iq
currents measured. By doing this the reference current would then be very close to the actual
achievable.
In order to perform this procedure the current control fault will need to be disabled by setting
Temporary DSP Configuration (0x4653,0) bit 0. This setting is not persistent and will be lost after
a key recycle.
Page 25 of 28
Setting up PMAC software Commercially Confidential
For on road e-bike applications of PMAC the following features must be configured in the
specified way in order to prevent unforeseen and potentially dangerous situations occurring on
the vehicle.
Roll off (0x2930,1) Disabled
Hill hold delay (0x2901,0) set to 0s
Speed limit proportional to throttle disabled (0x2910,1 bit 2) set.
Belly switch not configured (0x2139 does not appear in 0x3300)
Inch switches not configured (0x2129, 0x212A do not appear in 0x3300 )
Electro brake not configured (0x2420 does not appear in 0x3200)
Torque mode (0x2900) set to 0, AND (0x6060) set to 4
The following parameters are highly recommended suggestions which will make the vehicle
initially perform in an acceptable way.
Neutral braking set to 0%
Direction braking set to 100%
Direction braking proportional to throttle (0x2910,1 bit 0) set
Torque ramp up and down rates set appropriately fast
Page 26 of 28
Setting up PMAC software Commercially Confidential
8. Summary
Steps to take in setting up a PMAC Gen4
With the motor not connected to the Gen4, but the UVW wires connected to Gen4, rotate
the motor by hand and check the back emf voltage against the UVW encoder signals.
Identify UVW lines and whether or not encoder is inverted. See section 3.
Still with the motor not connected to the Gen4 controller, spin the motor as fast as
possible, measure back emf generated. Determine motor constant Ke as per section 4.1
enter this into 0x4641 sub 18.
Set maximum torque values, in 0x6076 and power limit table 0x4611. You can check
maximum current which will be requested by using the Ke value and the equation in
section 4.1
Set minimum magnetising current 0x4641 sub 3, ensure some gains are set in 0x4641 25
and 26
Page 27 of 28
Setting up PMAC software Commercially Confidential
9. Extras
A NOTE indicates important information that helps you make better use of your
computer system.
A CAUTION indicates either potential damage to hardware or loss of data and tells you
how to avoid the problem.
A WARNING indicates the potential for bodily harm and tells you how to avoid the
problem.
Page 28 of 28