c2000 piccolo f2805x mcu analog front end and motor controlmanual. abstract the c2000™ piccolo™...
TRANSCRIPT
IntroductionIn motor control inverter applications, motor line current and/or phase voltage are required by
the processor’s motor algorithm. Before these analog signals are sampled by the processor,
all signals are processed by an analog circuit. The external analog circuits add component
cost and increase board size. The Piccolo F2805x series of C2000 real-time control MCUs
addresses this issue by adding internal analog conditioning components for the motor
feedback signals, called the analog front end (AFE). This document will cover the application
of the AFE to motor control, specifically:
• The AFE block diagram
• Circuit layout considerations for the feedback signals
• Using the programmable gain amplifiers (PGA) for current feedback
• Adjusting current protection with the internal comparators and digital-to-analog converters
(DACs)
The whole AFE block diagram is shown in Figure 1 on the following page. The AFE contains
blocks of programmable gain amplifiers, fixed gain amplifiers, DACs, analog switches and
comparators. The Piccolo F2805x has been designed to control both trapezoidal and sinusoidal
motors, provide fault detection, and power factor correction control. For more detailed
information about the Piccolo F2805x MCUs, you may refer to the technical reference
manual.
Abstract
The C2000™ Piccolo™ TMS320F2805x
microcontroller (MCU) is the first C2000
MCU to include integrated programmable
gain amplifiers (PGAs) and windowed
comparators as part of a larger analog
conditioning subsystem, called the analog
front end (AFE). The AFE can benefit motor-
based applications through lowered bill
of materials costs, increased application
performance, reduced design complexity
and decreased board area. This paper
will provide a technical introduction to the
AFE of the Piccolo TMS320F2805x MCU
and provide technical guidance in the
context of motor-based application design.
C2000™ Piccolo™ F2805x MCU Analog Front End for Motor Control
Eric Thomas,Applications Engineer,
C2000™ MCUs
Texas Instruments
W H I T E P A P E R
C2000™ Piccolo™ F2805x MCU Analog Front End for Motor Control May 2013
2 Texas Instruments
Before addressing topics covering the implementation and usage of the PGAs and comparators, it is
recommended to consider how current feedback signals are routed from the shunt and then to the input
of the PGA. When a shunt resistor is used to measure line current, its value must be small to reduce the
amount of power dissipated in the shunt. Because the value is small, so is the resulting voltage drop across
the shunt. There is a significant amount of current flowing through the shunt resistors. Copper traces that
connect the shunts from the bottom of the power device and then to ground become a resistor in series with
Routing current signals
Figure 1: Analog Front End (AFE).
2
Figure 1: Analog Front End (AFE)
Routing current signals Before addressing topics covering the implementation and usage of the PGAs and comparators, it is recommended to consider how current feedback signals are routed from the shunt and then to the input
C2000™ Piccolo™ F2805x MCU Analog Front End for Motor Control May 2013
3Texas Instruments
the shunt. The parasitic resistance that forms on the copper trace must be taken into consideration when
measuring motor line currents with a shunt resistor.
The AFE can have up to three different grounds. The Piccolo F2805x MCUs have multiple groups of
amplifier blocks. Each group of amplifiers has a different ground. M1 ground is used for the group of three
PGAs that will feedback three-phase motor currents for this paper. For systems with power factor correction
(PFC), there is another single PGA and its ground is PFC ground. The fixed gain amplifier block uses M2
ground for its reference and is used in this paper for three motor voltage feedbacks.
Two options for the feedback of motor shunt current signals to the M1 PGA block of the AFE are
discussed. The first option is to use only the internal op-amps for the current feedback as shown in Figure
2. All three op-amps share the same ground for the inverting input, and therefore, a differential signal of the
shunt current cannot be created. With single-ended signals, careful layout must be done when grounding
the shunts to reduce the amount of differing trace resistance between shunts. What is advised is to have
the shunt grounds to be as close together as possible. A trace must run from the point that the shunts come
together to the M1gnd pin of the integrated circuit. Because common mode noise can be added to the
amplifier, the M1gnd pin and PGA inputs must be made as short as possible. The three-phase current traces
must be routed as close to the M1gnd trace as possible to reduce the size of the Faraday loop. The Faraday
loop is created around the phase current trace that starts from the top of the shunt to the IC and then back
on the M1gnd trace to the bottom of the shunt, through the shunt and back to the top of the shunt.
The second, and most noise-immune option, is to use external op-amps in a differential amplifier
configuration. A true Kelvin connection can feedback directly to the differential amplifier, and then the output
Figure 2: Current signal routing directly to the PGAs with single-ended connections.
3
of the PGA. When a shunt resistor is used to measure line current, its value must be small to reduce the amount of power dissipated in the shunt. Because the value is small, so is the resulting voltage drop across the shunt. There is a significant amount of current flowing through the shunt resistors. Copper traces that connect the shunts from the bottom of the power device and then to ground become a resistor in series with the shunt. The parasitic resistance that forms on the copper trace must be taken into consideration when measuring motor line currents with a shunt resistor.
Figure 2: Current signal routing directly to the PGAs with single‐ended connections.
The AFE can have up to three different grounds. The Piccolo F2805x MCUs have multiple groups of amplifier blocks. Each group of amplifiers has a different ground. M1 ground is used for the group of three PGAs that will feedback three-phase motor currents for this paper. For systems with power factor correction (PFC), there is another single PGA and its ground is PFC ground. The fixed gain amplifier block uses M2 ground for its reference and is used in this paper for three motor voltage feedbacks. Two options for the feedback of motor shunt current signals to the M1 PGA block of the AFE are discussed. The first option is to use only the internal op-amps for the current feedback as shown in Figure 2. All three op-amps share the same ground for the inverting input, and therefore, a differential signal of the shunt current cannot be created. With single-ended signals, careful layout must be done when grounding the shunts to reduce the amount of differing trace resistance between shunts. What is advised is to have the shunt grounds to be as close together as possible. A trace must run from the point that the shunts come together to the M1gnd pin of the integrated circuit. Because common mode noise can be added to the amplifier, the M1gnd pin and PGA inputs must be made as short as possible. The three-phase current traces must be routed as close to the M1gnd trace as possible to reduce the size of the Faraday loop. The Faraday loop is created around the phase current trace that starts from the top of the shunt to the IC and then back on the M1gnd trace to the bottom of the shunt, through the shunt and back to the top of the shunt. The second, and most noise-immune option, is to use external op-amps in a differential amplifier configuration. A true Kelvin connection can feedback directly to the differential amplifier, and then the
C2000™ Piccolo™ F2805x MCU Analog Front End for Motor Control May 2013
4 Texas Instruments
of the differential amplifier is sent into the PGA input. Figure 3 shows a typical layout when using external
differential op-amps. Since the Kelvin connection has low impedance and is a truly differential signal, it
provides excellent noise immunity. The external op-amp circuit converts the differential circuit into a single-
ended output. The single-ended output is more susceptible to noise; therefore, it is best to place the output
of the op-amp as close to the AFE input of the processor.
Why use the PGAs when external amplifiers are already being used? One case would be if many different
current rated motors are powered with the same inverter. Amplification of the current signal can be adjusted
to best suit the motor size that is controlled. The output of the PGA block is the input of the comparator
windows. The PGA still needs to be connected to enable the use of the fault detection circuitry.
Current can flow through the shunt in both positive and negative directions which will create both a positive
and negative voltage that is fed back to the shunt amplifier circuit. Most cost-effective motor inverters do not
have both positive and negative power supplies that can handle this bipolar signal. A bipolar current signal
is brought into an amplifier that will only be effective from zero to the positive voltage supply. To allow the
unipolar op-amp circuit to measure a bipolar signal, a voltage reference is summed into the non-inverting
side of the current feedback op-amps. The AFE of the F2805x MCUs contains a 6-bit DAC with a voltage
follower for providing an output reference for this reason. A circuit configuration that can use a voltage
reference to measure the bipolar current signal is shown in Figure 4 on the following page.
Equation 1 shows how to calculate the voltage at VPGA. As an example, set the PGA gain = 3. VADCIN will be
2VBIPOLAR + VREF. Assume the system’s VREFHI is 3.3V. To allow for maximum voltage swing in both directions,
VREF is set to 1.65V. Now the maximum peak VBIPOLAR voltage that can be measure is ± 0.825V.
Voltage reference connection
Figure 3: Feedback of phase currents using external differential amplifiers.
4
output of the differential amplifier is sent into the PGA input. Figure 3 shows a typical layout when using external differential op-amps. Since the Kelvin connection has low impedance and is a truly differential signal, it provides excellent noise immunity. The external op-amp circuit converts the differential circuit into a single-ended output. The single-ended output is more susceptible to noise; therefore, it is best to place the output of the op-amp as close to the AFE input of the processor. Why use the PGAs when external amplifiers are already being used? One case would be if many different current rated motors are powered with the same inverter. Amplification of the current signal can be adjusted to best suit the motor size that is controlled. The output of the PGA block is the input of the comparator windows. The PGA still needs to be connected to enable the use of the fault detection circuitry.
Figure 3: Feedback of phase currents using external differential amplifiers.
Voltage reference connection Current can flow through the shunt in both positive and negative directions which will create both a positive and negative voltage that is fed back to the shunt amplifier circuit. Most cost-effective motor inverters do not have both positive and negative power supplies that can handle this bipolar signal. A bipolar current signal is brought into an amplifier that will only be effective from zero to the positive voltage supply. To allow the unipolar op-amp circuit to measure a bipolar signal, a voltage reference is summed into the non-inverting side of the current feedback op-amps. The AFE of the F2805x MCUs contains a 6-bit DAC with a voltage follower for providing an output reference for this reason. A circuit configuration that can use a voltage reference to measure the bipolar current signal is shown in Figure 4.
VPGA VBIPOLAR+ VREF + VREF= =
2 · ( – )R V VBIPOLAR REF 2 1
3 3(1 + )R 2R
Equation 1.
C2000™ Piccolo™ F2805x MCU Analog Front End for Motor Control May 2013
5Texas Instruments
Suppose the same hardware is used and a higher resolution is required. The PGA gain = 6. VADCIN is
4VBIPOLAR + 2VREF. VREF must be adjusted to be 0.825V. The maximum peak VBIPOLAR voltage that can be
measured is ± 0.4125V.
The voltage reference output is adjusted by a 6-bit DAC. The VREFOUTCTL register controls the DAC’s
voltage output by Equation 2 below.
In sinusoidal motor-control drives, the voltage signals vary slowly when compared to current signals.
Therefore, larger hardware filters can be applied to the voltage feedback signal which helps to make it less
susceptible to noise. Voltage signals are unipolar, so no special circuit and reference have to be used. Lower
voltage motors (under 400VDCBUS) typically only require resistor dividers with a capacitive low-pass filter. For
a brushless DC motor control, the voltage needs as little phase shift as possible, and therefore, the low-pass
filtering depends on the maximum speed achieved by the motor. The only critical layout of voltage feedback
signals is that the low-pass filter capacitor must be located as close to the AFE or A/D input pin as possible.
For the rest of this paper, a sensorless, field-oriented control (FOC) is implemented using the Piccolo F2805x
MCU. The current and voltage signals are brought into the F2805x MCU as below:
Figure 4: Using the AFE’s built-in voltage reference for measuring a bipolar signal.
5
Figure 4: Using the AFE’s built in voltage reference for measuring a bipolar signal.
Equation 1 shows how to calculate the voltage at VPGA. As an example, set the PGA gain = 3. VADCIN will be 2VBIPOLAR + VREF. Assume the system’s VREFHI is 3.3V. To allow for maximum voltage swing in both directions, VREF is set to 1.65V. Now the maximum peak VBIPOLAR voltage that can be measure is +/- 0.825V.
���� � 2� ∙ ��������� � ������1� � 2�� � ���� � 2
3�������� �13���� Equation 1
Suppose the same hardware is used and a higher resolution is required. The PGA gain = 6. VADCIN is 4VBIPOLAR + 2VREF. VREF must be adjusted to be 0.825V. The maximum peak VBIPOLAR voltage that can be measured is +/- 0.4125V. The voltage reference output is adjusted by a 6bit DAC. The VREFOUTCTL register controls the DAC’s voltage output by Equation 2 below.
���� � ������ ∙ ����������������� � 1�64 Equation 2
Routing voltage signals In sinusoidal motor control drives, the voltage signals vary slowly when compared to current signals. Therefore, larger hardware filters can be applied to the voltage feedback signal which helps to make it less susceptible to noise. Voltage signals are unipolar, so no special circuit and reference have to be used. Lower voltage motors (under 400VDCBUS) typically only require resistor dividers with a capacitive low pass filter. For a brushless DC motor control, the voltage needs as little phase shift as possible, and therefore, the low-pass filtering depends on the maximum speed achieved by the motor. The only critical layout of voltage feedback signals is that the low-pass filter capacitor must be located as close to the AFE or A/D input pin as possible.
Routing voltage signals
VREF
VREFHI=( + 1)VREFOUTCTLDACVAL
64
Equation 2.
Motor-control system using the
Piccolo F2805x MCUs
C2000™ Piccolo™ F2805x MCU Analog Front End for Motor Control May 2013
The AFE amplifiers and voltage reference are set up to be able to run a permanent magnet synchronous
motor with FOC. The sequence that the registers are setup is shown by the flowchart in Figure 5. After the
AFE is enabled and setup, the ADCs function the same as any Piccolo MCU. For more information about the
AFE registers, see the technical document.
The PGAs are divided into groups, and each group contains its own ground. For motor control, up to three
current feedbacks and three voltage feedbacks are needed. The M1 bank contains three programmable
amplifiers, and the M2 bank contains three constant gain amplifiers. For the next experiments, the M1 PGAs
will feedback the current waveforms, and the M2 amplifier bank will feedback the voltage signals.
Before any of the active components can function in the AFE, they have to be enabled. Registers that pertain
to enabling the M1 PGAs and the M2 amplifiers are listed in Table 2 below. Setting the appropriate address
to 1 enables the corresponding amplifier.
6 Texas Instruments
PGA and amplifier setup
Figure 5: AFE setup for the motor feedback PGAs and the reference output voltage.
6
Motor control system using the Piccolo F2805x MCUs For the rest of this paper, a sensorless, field-oriented control (FOC) is implemented using the Piccolo F2805x MCU. The current and voltage signals are brought into the F2805x as below:
Table 1: Motor signals and PGA connections
Motor Signal PGA/ADC input Ia A1 Ib B1 Ic A3 Va A6 Vb B6 Vc B4
AFE amplifier and reference setup The AFE amplifiers and voltage reference are set up to be able to run a permanent magnet synchronous motor with FOC. The sequence that the registers are setup is shown by the flowchart in Figure 5. After the AFE is enabled and setup, the ADCs function the same as any Piccolo MCU. For more information about the AFE registers, see the technical document.
Figure 5: AFE setup for the motor feedback PGAs and the reference output voltage.
PGA and amplifier setup The PGAs are divided into groups, and each group contains its own ground. For motor control, up to three current feedbacks and three voltage feedbacks are needed. The M1 bank contains three programmable amplifiers, and the M2 bank contains three constant gain amplifiers. For the next experiments, the M1 PGAs will feedback the current waveforms, and the M2 amplifier bank will feedback the voltage signals. Enable M1 PGAs and M2 amplifiers Before any of the active components can function in the AFE, they have to be enabled. Registers that pertain to enabling the M1 PGAs and the M2 amplifiers are listed in the table below. Setting the appropriate address to 1 enables the corresponding amplifier.
Motor signal PGA/ADC input
Ia A1
Ib B1
Ic A3
Va A6
Vb B6
Vc B4
Table 1: Motor signals and PGA connections
AFE amplifier and reference setup
Enable M1 PGAs and M2 amplifiers
C2000™ Piccolo™ F2805x MCU Analog Front End for Motor Control May 2013
The gains of the M1 PGA are controlled by the register AMPM1_GAIN. The gains can be 3, 6 or 11 and are
shown in Table 3 below.
The voltage output reference is another circuit that takes cost out of a motor-control board design. The
voltage reference circuit consists of a programmable, 64-bit DAC and a follower amplifier. The output of the
amplifier is at pin VrefOut/A0. The ADC input A0 can also be used to monitor the voltage reference if needed.
The voltage reference is enabled in the same fashion as the M1 and M2 amplifier banks. The corresponding
enable register for VREFOUT is shown in Table 4 below.
The 64-bit programmable DAC is set by the register shown in Table 5 below.
7Texas Instruments
Register Address Channels Controlled Bit Values
PGAEN 0x6412
A1 0
0 – disable1 – enable
B1 1
A3 2
A6 3
B6 4
B4 5
Table 2: AFE registers used to enable the M1 and M2 amplifier banks.
Adjust the gains
Register Address Channels Controlled Bit Values
AMPM1_GAIN 0x6414
A1 1 to 000 -> Gain = 301 -> Gain = 610 -> Gain = 11
A3 5 to 4
B1 9 to 8
Table 3: AFE register used to setup the M1 PGA gains.
VrefOut setup
Enable VrefOut
Register Address Channels Controlled Bit Values
VREFOUTEN 0x6411 VREFOUT 0 0 – disable1 – enable
Table 4: AFE registers used to enable the voltage reference.
Adjust VrefOut DAC
Register Address Channels Controlled Bit Values
VREFOUTCTL 0x6405 VREFOUT 5 to 0 0 to 0x3F
Table 5: AFE register used to setup the DAC output voltages.
C2000™ Piccolo™ F2805x MCU Analog Front End for Motor Control May 2013
This paper will now cover FOC motor control in detail but is using it to show examples of how the Piccolo
F2805x MCUs can be used to run a motor-control system. Figure 6 shows a general observer-based
sensorless FOC system that has been programmed in the Flash of the Piccolo F2805x MCU. Table 6 lists the
motor and inverter used during this test. When observing the quality of a FOC system, motor-line currents
explain a lot about the inverter system. The line currents must be sinusoidal with very few harmonics – ideally
no harmonics. Poor current feedback results in a FOC system that has less control at lower speeds. A screen
capture of the current waveform of the motor under full load is shown in Figure 7. The current feedback
contains very little noise and the majority of the sinusoidal signal is in the first harmonic. Under low load,
there will be less current signal to measure. The PGAs can be of great use to adjust the feedback gain if
smaller current signals need to be measured. Figure 8 shows the current waveform with low load. More
noise appears to be present on the current waveform. By using the “center-aligned” sampling technique, the
noise is filtered out of the signal. The current that the MCU is sampling is the average of the upper and lower
bounds of the signal shown in Figure 8. Even with the switching noise present in the current waveform, the
general signal is a very smooth sinusoid.
Figure 6: FOC block diagram system.
8
This paper will now cover FOC motor control in detail but is using it to show examples of how the Piccolo F2805x MCUs can be used to run a motor control system. Figure 6 shows a general observer based sensorless FOC system that has been programmed in the FLASH of the Piccolo F2805x MCU. Table 6 lists the motor and inverter used during this test. When observing the quality of a FOC system, motor line currents explain a lot about the inverter system. The line currents must be sinusoidal with very few harmonics – ideally no harmonics. Poor current feedback results in a FOC system that has less control at lower speeds. A screen capture of the current waveform of the motor under full load is shown in Figure 7. The current feedback contains very little noise and the majority of the sinusoidal signal is in the first harmonic. Under low load, there will be less current signal to measure. The PGAs can be of great use to adjust the feedback gain if smaller current signals need to be measured. Figure 8 shows the current waveform with low load. More noise appears to be present on the current waveform. By using the “center-aligned” sampling technique, the noise is filtered out of the signal. The current that the MCU is sampling is the average of the upper and lower bounds of the signal shown in Figure 8. Even with the switching noise present in the current waveform, the general signal is a very smooth sinusoid.
Table 6: Electronics used to implement the FOC motor control system.
Motor Anaheim Automation BLY172S‐24V‐4000Inverter Texas Instruments DRV8312MCU Texas Instruments TMS320F28055
Figure 6: FOC block diagram system.
8 Texas Instruments
FOC system
Motor Anaheim Automation BLY172S-24V-4000
Inverter Texas Instruments DRV8312
MCU Texas Instruments TMS320F28055
Table 6: Electronics used to implement the FOC motor control system.
C2000™ Piccolo™ F2805x MCU Analog Front End for Motor Control May 2013
The Piccolo F2805x MCU’s AFE contains comparators with accompanying DACs for current fault protection.
This section will cover the setup and use of these comparators and will show an example of how faults of
both positive and negative current can be protected against.
The comparators are included to detect over-current conditions in the motor inverter. Since each shunt of
the inverter is being measured, the current can flow in both a positive and negative direction. There are two
comparators for each current feedback allowing detection of both positive and negative flowing currents. In
the next sections, the setup and some usage cases of the comparators and their accompanying DACs will be
investigated.
Figure 7: Phase current of the FOC system with the test motor under full load.
9
Figure 7: Phase current of the FOC system with the test motor under full load.
Figure 8: Phase current of the FOC system with the test motor under low load.
Current protection The Piccolo F2805x MCU’s AFE contains comparators with accompanying DACs for current fault protection. This section will cover the setup and use of these comparators and will show an example of how faults of both positive and negative current can be protected against. Comparator setup The comparators are included to detect over-current conditions in the motor inverter. Since each shunt of the inverter is being measured, the current can flow in both a positive and negative direction. There are two comparators for each current feedback allowing detection of both positive and negative flowing currents. In the next sections, the setup and some usage cases of the comparators and their accompanying DACs will be investigated.
A1 Compare Low 1
0
A1 Compare High 1
0 1
0
Digital Filter
1
0
Comparator Subsystem Filter Subsystem
A1 STS latchSTS latchSTS latch
A3B1
TRIP EPWM
A3outB1out
GPIO
A1outM1 STS latch 1
01
0
CTRIP Subsystem
Figure 9: Comparator output logic for the M1 system.
Enable and setup of the comparator system
9Texas Instruments
Figure 8: Phase current of the FOC system with the test motor under low load.
9
Figure 7: Phase current of the FOC system with the test motor under full load.
Figure 8: Phase current of the FOC system with the test motor under low load.
Current protection The Piccolo F2805x MCU’s AFE contains comparators with accompanying DACs for current fault protection. This section will cover the setup and use of these comparators and will show an example of how faults of both positive and negative current can be protected against. Comparator setup The comparators are included to detect over-current conditions in the motor inverter. Since each shunt of the inverter is being measured, the current can flow in both a positive and negative direction. There are two comparators for each current feedback allowing detection of both positive and negative flowing currents. In the next sections, the setup and some usage cases of the comparators and their accompanying DACs will be investigated.
A1 Compare Low 1
0
A1 Compare High 1
0 1
0
Digital Filter
1
0
Comparator Subsystem Filter Subsystem
A1 STS latchSTS latchSTS latch
A3B1
TRIP EPWM
A3outB1out
GPIO
A1outM1 STS latch 1
01
0
CTRIP Subsystem
Figure 9: Comparator output logic for the M1 system.
Enable and setup of the comparator system
Current protection
Comparator setup
Figure 9: Comparator output logic for the M1 system.
9
Figure 7: Phase current of the FOC system with the test motor under full load.
Figure 8: Phase current of the FOC system with the test motor under low load.
Current protection The Piccolo F2805x MCU’s AFE contains comparators with accompanying DACs for current fault protection. This section will cover the setup and use of these comparators and will show an example of how faults of both positive and negative current can be protected against. Comparator setup The comparators are included to detect over-current conditions in the motor inverter. Since each shunt of the inverter is being measured, the current can flow in both a positive and negative direction. There are two comparators for each current feedback allowing detection of both positive and negative flowing currents. In the next sections, the setup and some usage cases of the comparators and their accompanying DACs will be investigated.
A1 Compare Low 1
0
A1 Compare High 1
0 1
0
Digital Filter
1
0
Comparator Subsystem Filter Subsystem
A1 STS latchSTS latchSTS latch
A3B1
TRIP EPWM
A3outB1out
GPIO
A1outM1 STS latch 1
01
0
CTRIP Subsystem
Figure 9: Comparator output logic for the M1 system.
Enable and setup of the comparator system
C2000™ Piccolo™ F2805x MCU Analog Front End for Motor Control May 2013
Once the analog comparators make a comparison between the DAC input and the current waveform, the
output of the comparator is processed and routed by the comparator output logic as shown in Figure 9 on
the previous page. Only the M1 system, which contains comparators for A/D inputs of A1, B1 and A3, is
considered in this write-up. The setup is shown in the steps of the figure below.
For an example, the DACs are setup so that the comparator switches when the motor input is at 2A. The
equation for setting up the DAC voltage of the comparators is the same as Equation 2, except that the
reference voltage is VDDA. The limit of the motor current feedbacks, for the kit being used, is ± 8.845A and
the feedback amplifiers are biased at 1.65V (assume a 3.3V VDDA is used). To be able to trip the comparator
at 2A, the DAC voltage reference must be set to (1.65+3.3/8.845) = 2.023 volts. Setting Equation 3 equal
to 2.023V, assuming VDDA = 3.3V and solving for n results in n=38. Using a similar technique for the lower
comparator to trip on -2A results in n=23.
10 Texas Instruments
Enable and setup of the comparator
system
Figure 10: Comparator system setup steps.
10
Once the analog comparators make a comparison between the DAC input and the current waveform, the output of the comparator is processed and routed by the comparator output logic as shown in Figure 9. Only the M1 system, which contains comparators for A/D inputs of A1, B1 and A3, is considered in this write-up. The setup is shown in the steps of the figure below.
Figure 10: Comparator system setup steps.
DAC voltage setup For an example, the DACs are setup so that the comparator switches when the motor input is at 2A. The equation for setting up the DAC voltage of the comparators is the same as Equation 2, except that the reference voltage is VDDA. The limit of the motor current feedbacks, for the kit being used, is +/- 8.845A and the feedback amplifiers are biased at 1.65V (assume a 3.3V VDDA is used). To be able to trip the comparator at 2A, the DAC voltage reference must be set to ���6� � ���
������ �� ����� volts. Setting Equation 3 equal to 2.023V, assuming ���� = 3.3V and solving for � results in � � ��� Using a similar technique for the lower comparator to trip on -2A results in � � ���
���� � �� � ��64 �� ����� Equation 3
Example positive and negative fault setup The option of routing the comparator output to a GPIO pin is very helpful when debugging faults that happen. In the experiments to follow, the “OUT” option of the CTRIP setup is enabled to send the comparator outputs to a GPIO pin. The block diagram of how the system is setup is shown in Figure 11.
DAC voltage setup
VDAC=VDDA n· ( + 1)
64
Equation 3.
C2000™ Piccolo™ F2805x MCU Analog Front End for Motor Control May 2013
The option of routing the comparator output to a GPIO pin is very helpful when debugging faults that happen.
In the experiments to follow, the “OUT” option of the CTRIP setup is enabled to send the comparator outputs
to a GPIO pin. The block diagram of how the system is setup is shown in Figure 11. The digital filter has been
bypassed so that only raw comparator outputs can be captured on the oscilloscope.
The motor was run under load and the line current, processed current feedback and comparator out from the
GPIO signals were monitored on an oscilloscope. Load to the motor was increased so that the peak current
of the motor was 3A. The current and comparator waveforms are shown in Figure 12. When the current
reaches 2A, the upper comparator switches high. When the current reaches –2A the lower comparator
switches low, but its output is inverted so the result looks the same as the upper comparator.
Looking closer at the processed current feedback (Feedback Current) and comparator (Comparator
Output) waveforms in Figure 13 on the following page shows that only when current is flowing through the
shunt resistor is when the comparator output is valid. When no current is flowing through the shunt resistor,
the feedback amplifier and comparator see zero current.
11Texas Instruments
Example positive and negative fault setup
Figure 11: Comparator output logic as setup for the experiment.
11
The digital filter has been bypassed so that only raw comparator outputs can be captured on the oscilloscope.
A1 Compare Low 1
0
A1 Compare High 1
01
0
Digital Filter
1
0
Comparator Subsystem Filter Subsystem
A1 STS latchSTS latchSTS latch
A3B1
TRIP EPWM
A3outB1out
GPIO
A1outM1 STS latch 1
01
0
CTRIP Subsystem
OUT block
Figure 11: Comparator output logic as setup for the experiment. Experiment results The motor was run under load and the line current, processed current feedback, and comparator out from the GPIO signals were monitored on an oscilloscope. Load to the motor was increased so that the peak current of the motor was 3A. The current and comparator waveforms are shown in Figure 12. When the current reaches 2A, the upper comparator switches high. When the current reaches -2A the lower comparator switches low, but its output is inverted so the result looks the same as the upper comparator.
Figure 12: Comparator output from the GPIO.
Looking closer at the processed current feedback (Feedback Current) and comparator (Comparator Output) waveforms in Figure 13 shows that only when current is flowing through the shunt resistor is when the comparator output is valid. When no current is flowing through the shunt resistor, the feedback amplifier and comparator see zero current.
Line Current
Feedback Current
Comparator Output
Experiment results
Figure 12: Comparator output from the GPIO.
11
The digital filter has been bypassed so that only raw comparator outputs can be captured on the oscilloscope.
A1 Compare Low 1
0
A1 Compare High 1
01
0
Digital Filter
1
0
Comparator Subsystem Filter Subsystem
A1 STS latchSTS latchSTS latch
A3B1
TRIP EPWM
A3outB1out
GPIO
A1outM1 STS latch 1
01
0
CTRIP Subsystem
OUT block
Figure 11: Comparator output logic as setup for the experiment. Experiment results The motor was run under load and the line current, processed current feedback, and comparator out from the GPIO signals were monitored on an oscilloscope. Load to the motor was increased so that the peak current of the motor was 3A. The current and comparator waveforms are shown in Figure 12. When the current reaches 2A, the upper comparator switches high. When the current reaches -2A the lower comparator switches low, but its output is inverted so the result looks the same as the upper comparator.
Figure 12: Comparator output from the GPIO.
Looking closer at the processed current feedback (Feedback Current) and comparator (Comparator Output) waveforms in Figure 13 shows that only when current is flowing through the shunt resistor is when the comparator output is valid. When no current is flowing through the shunt resistor, the feedback amplifier and comparator see zero current.
Line Current
Feedback Current
Comparator Output
C2000™ Piccolo™ F2805x MCU Analog Front End for Motor Control May 2013
The Piccolo F2805x MCU’s AFE can help eliminate external components that are needed in a motor control
inverter. When using the AFE, it is very important to use proper board layout especially for the current
feedback signals. The AFE setup is straightforward and after it is setup the Piccolo F2805x MCU’s A/D
inputs operate in the same manner as a Piccolo MCU. Built-in comparators allow hardware tripping of the
MCU PWMs or can be output directly out of a GPIO. Each A/D channel contains both an upper and lower
comparator for bipolar over-current detection.
The AFE code example below is written in C but follows an object-oriented style. The AFE object is the
physical peripheral on the MCU. First the AFE handle is declared. An instance of the AFE object is passed to
the newly declared AFE handle by the AFEinit function. Any AFE function that is called uses its corresponding
AFE handle as the first parameter in that function call. Any headers that are used in the example code below
but are not listed can be found in the TI MotorWare™ software package at www.ti.com/motorware.
Conclusion
12 Texas Instruments
12
Figure 13: Zoomed in view of the comparator output from the GPIO.
Conclusion The Piccolo F2805x MCU’s AFE can help eliminate external components that are needed in a motor control inverter. When using the AFE, it is very important to use proper board layout especially for the current feedback signals. The AFE setup is straightforward and after it is setup the Piccolo F2805x MCU’s A/D inputs operate in the same manner as a Piccolo MCU. Built-in comparators allow hardware tripping of the MCU PWMs or can be output directly out of a GPIO. Each A/D channel contains both an upper and lower comparator for bipolar over-current detection. Appendix The AFE code example below is written in C but follows an object-oriented style. The AFE object is the physical peripheral on the MCU. First the AFE handle is declared. An instance of the AFE object is passed to the newly declared AFE handle by the AFEinit function. Any AFE function that is called uses its corresponding AFE handle as the first parameter in that function call. Any headers that are used in the example code below but are not listed can be found in the TI MotorWare™ software package at www.ti.com/motorware. AFE instantiation // ************************************************************************** // the includes #include "sw/drivers/afe/src/32b/f28x/f2805x/afe.h" // Declare an AFE handle AFE_Handle afeHandle; // Pass the handle of the AFE peripheral to the newly declared AFE handle afeHandle = AFE_init((void *)AFE_BASE_ADDR,sizeof(AFE_Obj)); AFE setup code // enable the PGA amplifiers
Line Current
Feedback Current
Comparator Output
Figure 13: Zoomed-in view of the comparator output from the GPIO.
Appendix
// **************************************************************************// the includes
#include “sw/drivers/afe/src/32b/f28x/f2805x/afe.h”
// Declare an AFE handleAFE_Handle afeHandle;
// Pass the handle of the AFE peripheral to the newly declared AFE handleafeHandle = AFE_init((void *)AFE_BASE_ADDR,sizeof(AFE_Obj));
// enable the PGA amplifiersAFE_enablePGA(afeHandle, (AFE_PGAEN_e)(AFE_AMPA1EN \ | AFE_AMPB1EN \ | AFE_AMPA3EN \ | AFE_AMPB6EN \ | AFE_AMPA6EN \ | AFE_AMPB4EN));
// enable VrefOutAFE_enableVrefOut(afeHandle);
// set the VrefOut voltageAFE_setVrefOut(afeHandle,47);
// enable the DACs for the M1 comparatorsAFE_enableDAC(afeHandle, (AFE_DACEN_e)(AFE_DAC1EN \ | AFE_DAC2EN));
// set the DAC output voltageAFE_setDacCtl(afeHandle, AFE_DAC1, (31 + 7));AFE_setDacCtl(afeHandle, AFE_DAC2, (31 - 8));
// enable the M1 comparatorsAFE_enableComp(afeHandle, (AFE_COMPEN_e)(AFE_COMPA1EN \ | AFE_COMPA3EN \ | AFE_COMPB1EN));
// Bypass the M1 system digital filter, send both high and low of M1 comparator// outputs to the digital filter subsystemAFE_setA1CompSubsystem(afeHandle, (AFE_CTRIPxxICTL_FIELDS_e)(AFE_CTRIPOUTBYP \ | AFE_CTRIPBYP \ | AFE_COMPLINPEN \ | AFE_COMPHINPEN \ | AFE_COMPLPOL));
AFE_setB1CompSubsystem(afeHandle, (AFE_CTRIPxxICTL_FIELDS_e)(AFE_CTRIPOUTBYP \ | AFE_CTRIPBYP \ | AFE_COMPLINPEN \ | AFE_COMPHINPEN \ | AFE_COMPLPOL));
AFE_setA3CompSubsystem(afeHandle, (AFE_CTRIPxxICTL_FIELDS_e)(AFE_CTRIPOUTBYP \ | AFE_CTRIPBYP \ | AFE_COMPLINPEN \ | AFE_COMPHINPEN \ | AFE_COMPLPOL));
// Enable the M1 CTRIP output to the GPIOAFE_setM1CtripOut(afeHandle, (AFE_CTRIPMxOCTL_FIELDS_e)(AFE_CTRIPA1OUTEN));
13Texas Instruments
AFE instantiation
AFE setup code
C2000™ Piccolo™ F2805x MCU Analog Front End for Motor Control May 2013
AFE header code
afe.c
// **************************************************************************// the includes
#include “sw/drivers/afe/src/32b/f28x/f2805x/afe.h”
// **************************************************************************// the functions
// current sampled lastAFE_Handle AFE_init(void *pMemory,const size_t numBytes){ AFE_Handle afeHandle;
if(numBytes < sizeof(AFE_Obj)) return((AFE_Handle)NULL);
// assign the handle afeHandle = (AFE_Handle)pMemory;
return(afeHandle);} // end of AFE_init() function
afe.h
#ifndef _AFE_H_#define _AFE_H_
//! \file ~/dmc_dev/sw/drivers/afe/src/32b/f28x/f2803x/afe.h//! \brief Contains public interface to various functions related//! to the analog front end (AFE) object//!//! (C) Copyright 2011, Texas Instruments, Inc.
// **************************************************************************// the includes
// drivers//#include “sw/drivers/cpu/src/32b/f28x/f2805x/cpu.h”
// **************************************************************************// modules#include “sw/modules/math/src/32b/math.h”#include “sw/modules/types/src/32b/types.h”#include “sw/drivers/cpu/src/32b/f28x/f2805x/cpu.h”
//!//! \defgroup AFE
//!//! \ingroup AFE//@{
14 Texas Instruments
AFE driver code
C2000™ Piccolo™ F2805x MCU Analog Front End for Motor Control May 2013
#ifdef __cplusplusextern “C” {#endif
// **************************************************************************// the defines
//! \brief Defines the base address of the analog-to-digital converter//! (ADC) registers//!#define AFE_BASE_ADDR (0x006400)
// **************************************************************************// the typedefs
//! \brief Enumeration to define the afe amplifier enable number//!typedef enum{ AFE_AMPB7EN=(1 << 6), //!< Denotes that the pga amplifier for adc B7 is enabled AFE_AMPB6EN=(1 << 5), //!< Denotes that the pga amplifier for adc B6 is enabled AFE_AMPB4EN=(1 << 4), //!< Denotes that the pga amplifier for adc B4 is enabled AFE_AMPA6EN=(1 << 3), //!< Denotes that the pga amplifier for adc A6 is enabled AFE_AMPB1EN=(1 << 2), //!< Denotes that the pga amplifier for adc B1 is enabled AFE_AMPA3EN=(1 << 1), //!< Denotes that the pga amplifier for adc A3 is enabled AFE_AMPA1EN=(1 << 0) //!< Denotes that the pga amplifier for adc A1 is enabled} AFE_PGAEN_e;
//! \brief Enumeration to define the afe amplifier enable number//!typedef enum{ AFE_DAC1EN=(1 << 0), //!< Denotes that DAC 1 is enabled/disabled AFE_DAC2EN=(1 << 1), //!< Denotes that DAC 2 is enabled/disabled AFE_DAC3EN=(1 << 2), //!< Denotes that DAC 3 is enabled/disabled AFE_DAC4EN=(1 << 3), //!< Denotes that DAC 4 is enabled/disabled AFE_DAC5EN=(1 << 4) //!< Denotes that DAC 5 is enabled/disabled} AFE_DACEN_e;
//! \brief Enumeration to define the afe DAC number//!typedef enum{ AFE_DAC1=0, //!< Selects DAC1 AFE_DAC2, //!< Selects DAC2 AFE_DAC3, //!< Selects DAC3 AFE_DAC4, //!< Selects DAC4 AFE_DAC5 //!< Selects DAC5} AFE_DAC_NUMBER_e;
//! \brief Enumeration to define the afe Comparator enable number//!typedef enum{ AFE_COMPB7EN=(1 << 0), //!< Denotes that Comparator B7 is enabled/disabled AFE_COMPA1EN=(1 << 2), //!< Denotes that Comparator A1 is enabled/disabled AFE_COMPA3EN=(1 << 4), //!< Denotes that Comparator A3 is enabled/disabled AFE_COMPB1EN=(1 << 6), //!< Denotes that Comparator B1 is enabled/disabled AFE_COMPA6EN=(1 << 8), //!< Denotes that Comparator A6 is enabled/disabled
15Texas Instruments
C2000™ Piccolo™ F2805x MCU Analog Front End for Motor Control May 2013
AFE_COMPB4EN=(1 << 10), //!< Denotes that Comparator B4 is enabled/disabled AFE_COMPB6EN=(1 << 12) //!< Denotes that Comparator B6 is enabled/disabled} AFE_COMPEN_e;
//! \brief Enumeration to define the afe Comparator hysteresis enable number//!typedef enum{ AFE_COMPB7_HYST_EN=(1 << 6), //!< Denotes that Comparator Hysteresis B7 is enabled/disabled AFE_COMPB6_HYST_EN=(1 << 5), //!< Denotes that Comparator Hysteresis B6 is enabled/disabled AFE_COMPB4_HYST_EN=(1 << 4), //!< Denotes that Comparator Hysteresis B4 is enabled/disabled AFE_COMPB1_HYST_EN=(1 << 3), //!< Denotes that Comparator Hysteresis B1 is enabled/disabled AFE_COMPA6_HYST_EN=(1 << 2), //!< Denotes that Comparator Hysteresis A6 is enabled/disabled AFE_COMPA3_HYST_EN=(1 << 1), //!< Denotes that Comparator Hysteresis A3 is enabled/disabled AFE_COMPA1_HYST_EN=(1 << 0) //!< Denotes that Comparator Hysteresis A1 is enabled/disabled} AFE_COMP_HYST_EN_e;
//! \brief Enumeration to define the afe Comparator CTRIP Filter Input and//! Function Control Registers (CTRIPxxICTL) Fields//!typedef enum{ AFE_CTRIPOUTBYP=(1 << 12), AFE_CTRIPBYP=(1 << 11), AFE_COMPLINPEN=(1 << 3), AFE_COMPHINPEN=(1 << 2), AFE_COMPLPOL=(1 << 1), AFE_COMPHPOL=(1 << 0)} AFE_CTRIPxxICTL_FIELDS_e;
typedef enum{ AFE_COMP_A1=(0), AFE_COMP_A3, AFE_COMP_B1} AFE_CTRIP_SEL_e;
//! \brief Enumeration to define the afe Comparator CTRIP Filter Input and//! Function Control Registers (CTRIPxxICTL) Fields//!typedef enum{ AFE_CTRIPOUTLATEN=(1 << 15), AFE_CTRIPOUTPOL=(1 << 14), AFE_CTRIPB1OUTEN=(1 << 10), AFE_CTRIPA3OUTEN=(1 << 9), AFE_CTRIPA1OUTEN=(1 << 8), AFE_CTRIPB1EN=(1 << 2), AFE_CTRIPA3EN=(1 << 1), AFE_CTRIPA1EN=(1 << 0)} AFE_CTRIPMxOCTL_FIELDS_e;
16 Texas Instruments
C2000™ Piccolo™ F2805x MCU Analog Front End for Motor Control May 2013
//! \brief Enumeration to define the afe Comparator CTRIP Filter Input and//! Function Control Registers (CTRIPxxICTL) Fields//!typedef enum{ AFE_CTRIPOUTM1FLG=(1 << 15), AFE_CTRIPB1FLG=(1 << 10), AFE_CTRIPA3FLG=(1 << 9), AFE_CTRIPA1FLG=(1 << 8), AFE_CTRIPOUTM1STS=(1 << 7), AFE_CTRIPB1STS=(1 << 2), AFE_CTRIPA3STS=(1 << 1), AFE_CTRIPA1STS=(1 << 0)} AFE_CTRIPMxSTATUS_FIELDS_e;
//! \brief Enumeration to define the afe Comparator CTRIP Filter Input and//! Function Control Registers (CTRIPxxICTL) Fields//!typedef enum{ AFE_CTRIPOUTM1FLGCLR=(1 << 15), AFE_CTRIPB1FLGCLR=(1 << 10), AFE_CTRIPA3FLGCLR=(1 << 9), AFE_CTRIPA1FLGCLR=(1 << 8)} AFE_CTRIPMxFLAG_FIELDS_e;
//! \brief Defines the analog-to-digital converter (ADC) object//!typedef struct _AFE_Obj_{ uint16_t DACxCTL[0x05]; //!< DAC 1-5 control registers uint16_t VREFOUTCTL; //!< VREFOUT (DAC6) control uint16_t rsvd1[0x0A]; //!< Reserved uint16_t DACEN; //!< DAC Enables uint16_t VREFOUTEN; //!< VREFOUT Enable uint16_t PGAEN; //!< Programmable Gain Amplifier Enable uint16_t COMPEN; //!< Comparator Enable uint16_t AMPM1_GAIN; //!< Motor Unit 1 PGA Gain controls uint16_t AMPM2_GAIN; //!< Motor Unit 2 PGA Gain controls uint16_t AMPPFC_GAIN; //!< PFC PGA Gain controls uint16_t rsvd2[0x0A]; //!< Reserved uint16_t ADCINSWITCH; //!< ADC input-select switch control uint16_t rsvd3[0x07]; //!< Reserved uint16_t COMPHYSTCTL; //!< Comparator High AND Low hysteresis enable/disable uint16_t rsvd4[0x06]; //!< Reserved uint16_t CTRIPA1ICTL; //!< CTRIPA1 Filter Input & function Control uint16_t CTRIPA1FILCTL; //!< CTRIPA1 Filter parameters uint16_t CTRIPA1FILCLKCTL; //!< CTRIPA1 Filter Sample Clock Control uint16_t rsvd5; //!< Reserved uint16_t CTRIPA3ICTL; //!< CTRIPA3 Filter Input & function Control uint16_t CTRIPA3FILCTL; //!< CTRIPA3 Filter parameters uint16_t CTRIPA3FILCLKCTL; //!< CTRIPA3 Filter Sample Clock Control uint16_t rsvd6; //!< Reserved uint16_t CTRIPB1ICTL; //!< CTRIPB1 Filter Input & function Control uint16_t CTRIPB1FILCTL; //!< CTRIPB1 Filter parameters uint16_t CTRIPB1FILCLKCTL; //!< CTRIPB1 Filter Sample Clock Control uint16_t rsvd7[0x02]; //!< Reserved uint16_t CTRIPM1OCTL; //!< CTRIPM1 CTRIP Filter Output Control uint16_t CTRIPM1STS; //!< CTRIPM1 CTRIPx outputs status
17Texas Instruments
C2000™ Piccolo™ F2805x MCU Analog Front End for Motor Control May 2013
uint16_t CTRIPM1FLGCLR; //!< CTRIPM1 CTRIPx flag clear uint16_t rsvd8[0x10]; //!< Reserved uint16_t CTRIPA6ICTL; //!< CTRIPA6 Filter Input & function Control uint16_t CTRIPA6FILCTL; //!< CTRIPA6 Filter parameters uint16_t CTRIPA6FILCLKCTL; //!< CTRIPA6 Filter Sample Clock Control uint16_t rsvd9; //!< Reserved uint16_t CTRIPB4ICTL; //!< CTRIPB4 Filter Input & function Control uint16_t CTRIPB4FILCTL; //!< CTRIPB4 Filter parameters uint16_t CTRIPB4FILCLKCTL; //!< CTRIPB4 Filter Sample Clock Control uint16_t rsvd10; //!< Reserved uint16_t CTRIPB6ICTL; //!< CTRIPB6 Filter Input & function Control uint16_t CTRIPB6FILCTL; //!< CTRIPB6 Filter parameters uint16_t CTRIPB6FILCLKCTL; //!< CTRIPB6 Filter Sample Clock Control uint16_t rsvd11[0x02]; //!< Reserved uint16_t CTRIPM2OCTL; //!< CTRIPM2 CTRIP Filter Output Control uint16_t CTRIPM2STS; //!< CTRIPM2 CTRIPx outputs status uint16_t CTRIPM2FLGCLR; //!< CTRIPM2 CTRIPx flag clear uint16_t rsvd12[0x10]; //!< Reserved uint16_t CTRIPB7ICTL; //!< CTRIPB7 Filter Input & function Control uint16_t CTRIPB7FILCTL; //!< CTRIPB7 Filter parameters uint16_t CTRIPB7FILCLKCTL; //!< CTRIPB7 Filter Sample Clock Control uint16_t rsvd13[0x0A]; //!< Reserved uint16_t CTRIPPFCOCTL; //!< CTRIPPFC CTRIPx outputs status uint16_t CTRIPPFCSTS; //!< CTRIPPFC CTRIPx flag clear uint16_t CTRIPPFCFLGCLR; //!< CTRIPPFC COMP Test Control uint16_t rsvd14[0x70]; //!< Reserved uint16_t LOCKCTRIP; //!< Lock Register for CTRIP Filters uint16_t rsvd15; //!< Reserved uint16_t LOCKDAC; //!< Lock Register for DACs uint16_t rsvd16; //!< Reserved uint16_t LOCKAMPCOMP; //!< Lock Register for Amplifiers & Com-parators uint16_t rsvd17; //!< Reserved uint16_t LOCKSWITCH; //!< Lock Register for Switches} AFE_Obj;
//! \brief Defines the analog front end (AFE) handle//!typedef struct AFE_Obj *AFE_Handle;
// **************************************************************************// the globals
// **************************************************************************// the function prototypes
//! \brief Initializes the analog front end (AFE)//! \param[in] *pMemory The memory address of the object//! \param[in] size_t The size of the object in bytesAFE_Handle AFE_init(void *pMemory,const size_t numBytes);
//! \brief Enables programmable gain amps for the analog front end (AFE)//! \param[in] AFE_Handle A handle to the AFE object//! \param[in] AFE_PGAEN_e An enumeration selecting the PGA input the enableinline void AFE_enablePGA(AFE_Handle afeHandle, AFE_PGAEN_e PgaEnable){ AFE_Obj *afe = (AFE_Obj *)afeHandle;
18 Texas Instruments
C2000™ Piccolo™ F2805x MCU Analog Front End for Motor Control May 2013
19Texas Instruments
ENABLE_PROTECTED_REGISTER_WRITE_MODE;
//set the selection bits afe->PGAEN |= PgaEnable;
DISABLE_PROTECTED_REGISTER_WRITE_MODE;
return;} // end of AFE_EnablePGA() function
//! \brief Disables programmable gain amps for the analog front end (AFE)//! \param[in] AFE_Handle A handle to the AFE object//! \param[in] AFE_PGAEN_e An enumeration selecting the PGA input the disableinline void AFE_disablePGA(AFE_Handle afeHandle, AFE_PGAEN_e PgaEnable){ AFE_Obj *afe = (AFE_Obj *)afeHandle;
ENABLE_PROTECTED_REGISTER_WRITE_MODE;
//set the selection bits afe->PGAEN &= ~PgaEnable;
DISABLE_PROTECTED_REGISTER_WRITE_MODE;
return;} // end of AFE_DisablePGA() function
//! \brief Enables the VrefOut DAC for the analog front end (AFE)//! \param[in] AFE_Handle A handle to the AFE objectinline void AFE_enableVrefOut(AFE_Handle afeHandle){ AFE_Obj *afe = (AFE_Obj *)afeHandle;
ENABLE_PROTECTED_REGISTER_WRITE_MODE;
//set the selection bits afe->VREFOUTEN |= 0x0001;
DISABLE_PROTECTED_REGISTER_WRITE_MODE;
return;} // end of AFE_EnablePGA() function
//! \brief Disables the VrefOut DAC for for the analog front end (AFE)//! \param[in] AFE_Handle A handle to the AFE objectinline void AFE_disableVrefOut(AFE_Handle afeHandle){ AFE_Obj *afe = (AFE_Obj *)afeHandle;
ENABLE_PROTECTED_REGISTER_WRITE_MODE;
//set the selection bits afe->VREFOUTEN &= ~0x0001;
DISABLE_PROTECTED_REGISTER_WRITE_MODE;
return;} // end of AFE_DisablePGA() function
//! \brief Controls the VrefOut DAC for the analog front end (AFE). Sets the//! \brief DAC gain by the fraction VREFHI * [1,64]/64;
C2000™ Piccolo™ F2805x MCU Analog Front End for Motor Control May 2013
//! \param[in] AFE_Handle A handle to the AFE object//! \param[in] uint16_t A value from 0 to 63.inline void AFE_setVrefOut(AFE_Handle afeHandle, uint16_t VrefOutVal){ AFE_Obj *afe = (AFE_Obj *)afeHandle;
ENABLE_PROTECTED_REGISTER_WRITE_MODE;
//set the last 6 bits of the Register afe->VREFOUTCTL = (VrefOutVal & 0x003F);
DISABLE_PROTECTED_REGISTER_WRITE_MODE;
return;} // end of AFE_setVrefOut() function//! \brief Controls the comparator DAC for the analog front end (AFE). Sets//! \the brief DAC gain by the fraction VDDA * [1,64]/64;//! \param[in] AFE_Handle A handle to the AFE object//! \param[in] AFE_DAC_NUMBER_e for selecting which DAC to control//! \param[in] uint16_t A value from 0 to 63.inline void AFE_setDacCtl(AFE_Handle afeHandle, AFE_DAC_NUMBER_e DacNumber, uint16_t DacOutVal){ AFE_Obj *afe = (AFE_Obj *)afeHandle;
ENABLE_PROTECTED_REGISTER_WRITE_MODE;
//set the last 6 bits of the Register afe->DACxCTL[DacNumber] = (DacOutVal & 0x003F);
DISABLE_PROTECTED_REGISTER_WRITE_MODE;
return;} // end of AFE_setDacCtl() function
//! \brief Enables DAC outputs for the analog front end (AFE)//! \param[in] AFE_Handle A handle to the AFE object//! \param[in] AFE_DACEN_e An enumeration selecting the DAC output the enableinline void AFE_enableDAC(AFE_Handle afeHandle, AFE_DACEN_e DacEnable){ AFE_Obj *afe = (AFE_Obj *)afeHandle;
ENABLE_PROTECTED_REGISTER_WRITE_MODE;
//set the selection bits afe->DACEN |= DacEnable;
DISABLE_PROTECTED_REGISTER_WRITE_MODE;
return;} // end of AFE_enableDAC() function
//! \brief Enables Comparators for the analog front end (AFE)//! \param[in] AFE_Handle A handle to the AFE object//! \param[in] AFE_COMPEN_e An enumeration selecting the Comparator to enableinline void AFE_enableComp(AFE_Handle afeHandle, AFE_COMPEN_e CompEnable){ AFE_Obj *afe = (AFE_Obj *)afeHandle;
ENABLE_PROTECTED_REGISTER_WRITE_MODE;
//set the selection bits afe->COMPEN |= CompEnable;
20 Texas Instruments
C2000™ Piccolo™ F2805x MCU Analog Front End for Motor Control May 2013
DISABLE_PROTECTED_REGISTER_WRITE_MODE;
return;} // end of AFE_enableComp() function
//! \brief Enables Hysteresis for the Comparators for the analog front end (AFE)//! \param[in] AFE_Handle A handle to the AFE object//! \param[in] AFE_COMP_HYST_EN_e An enumeration selecting the Comparator Hysteresis to enableinline void AFE_enableCompHyst(AFE_Handle afeHandle, AFE_COMP_HYST_EN_e CompHystEnable){ AFE_Obj *afe = (AFE_Obj *)afeHandle;
ENABLE_PROTECTED_REGISTER_WRITE_MODE;
//set the selection bits afe->COMPHYSTCTL &= ~CompHystEnable;
DISABLE_PROTECTED_REGISTER_WRITE_MODE;
return;} // end of AFE_enableCompHyst() function
//! \brief Disables Comparators for the analog front end (AFE)//! \param[in] AFE_Handle A handle to the AFE object//! \param[in] AFE_COMPEN_e An enumeration selecting the Comparator to enableinline void AFE_disableComp(AFE_Handle afeHandle, AFE_COMPEN_e CompEnable){ AFE_Obj *afe = (AFE_Obj *)afeHandle;
ENABLE_PROTECTED_REGISTER_WRITE_MODE;
//set the selection bits afe->COMPEN &= ~CompEnable;
DISABLE_PROTECTED_REGISTER_WRITE_MODE;
return;} // end of AFE_disableComp() function
//! \brief Disables DAC outputs for the analog front end (AFE)//! \param[in] AFE_Handle A handle to the AFE object//! \param[in] AFE_DACEN_e An enumeration selecting the DAC output the enableinline void AFE_disableDAC(AFE_Handle afeHandle, AFE_DACEN_e DacEnable){ AFE_Obj *afe = (AFE_Obj *)afeHandle;
ENABLE_PROTECTED_REGISTER_WRITE_MODE;
//set the selection bits afe->DACEN &= ~DacEnable;
DISABLE_PROTECTED_REGISTER_WRITE_MODE;
return;} // end of AFE_disableDAC() function
21Texas Instruments
C2000™ Piccolo™ F2805x MCU Analog Front End for Motor Control May 2013
//! \brief Disables Hysteresis for the Comparators for the analog front end (AFE)//! \param[in] AFE_Handle A handle to the AFE object//! \param[in] AFE_COMP_HYST_EN_e An enumeration selecting the Comparator Hys-teresis to disableinline void AFE_disableCompHyst(AFE_Handle afeHandle, AFE_COMP_HYST_EN_e CompHystEnable){ AFE_Obj *afe = (AFE_Obj *)afeHandle;
ENABLE_PROTECTED_REGISTER_WRITE_MODE;
//set the selection bits afe->COMPHYSTCTL |= CompHystEnable;
DISABLE_PROTECTED_REGISTER_WRITE_MODE;
return;} // end of AFE_disableCompHyst() function
//! \brief Sets the A1 Comparator Subsystem settings for the analog front end (AFE)//! \param[in] AFE_Handle A handle to the AFE object//! \param[in] AFE_CTRIPxxICTL_FIELDS_e A single or or’d list of enumerations selecting the//! Comparator input settingsinline void AFE_setA1CompSubsystem(AFE_Handle afeHandle, AFE_CTRIPxxICTL_FIELDS_e CtripBitFields){ AFE_Obj *afe = (AFE_Obj *)afeHandle;
ENABLE_PROTECTED_REGISTER_WRITE_MODE;
//set the selection bits afe->CTRIPA1ICTL |= (uint16_t)CtripBitFields;
DISABLE_PROTECTED_REGISTER_WRITE_MODE;
return;} // end of AFE_setA1CompSubsystem() function
//! \brief Sets the A3 Comparator Subsystem settings for the analog front end (AFE)//! \param[in] AFE_Handle A handle to the AFE object//! \param[in] AFE_CTRIPxxICTL_FIELDS_e A single or or’d list of enumerations selecting the Comparator//! input settingsinline void AFE_setA3CompSubsystem(AFE_Handle afeHandle, AFE_CTRIPxxICTL_FIELDS_e CtripBitFields){ AFE_Obj *afe = (AFE_Obj *)afeHandle;
ENABLE_PROTECTED_REGISTER_WRITE_MODE;
//set the selection bits afe->CTRIPA3ICTL |= CtripBitFields;
DISABLE_PROTECTED_REGISTER_WRITE_MODE;
return;} // end of AFE_setA3CompSubsystem() function
22 Texas Instruments
C2000™ Piccolo™ F2805x MCU Analog Front End for Motor Control May 2013
//! \brief Sets the B1 Comparator Subsystem settings for the analog front end (AFE)//! \param[in] AFE_Handle A handle to the AFE object//! \param[in] AFE_CTRIPxxICTL_FIELDS_e A single or or’d list of enumerations se-lecting the Comparator//! input settingsinline void AFE_setB1CompSubsystem(AFE_Handle afeHandle, AFE_CTRIPxxICTL_FIELDS_e CtripBitFields){ AFE_Obj *afe = (AFE_Obj *)afeHandle;
ENABLE_PROTECTED_REGISTER_WRITE_MODE;
//set the selection bits afe->CTRIPB1ICTL |= CtripBitFields;
DISABLE_PROTECTED_REGISTER_WRITE_MODE;
return;} // end of AFE_setB1CompSubsystem() function
//! \brief Sets the Comparator Trip Out settings for the M1 block for the analog front end (AFE)//! \param[in] AFE_Handle A handle to the AFE object//! \param[in] AFE_CTRIPMxOCTL_FIELDS_e A single or or’d list of enumerations selecting the Comparator//! out settingsinline void AFE_setM1CtripOut(AFE_Handle afeHandle, AFE_CTRIPMxOCTL_FIELDS_e CtripOutBitFields){ AFE_Obj *afe = (AFE_Obj *)afeHandle;
ENABLE_PROTECTED_REGISTER_WRITE_MODE;
//set the selection bits afe->CTRIPM1OCTL |= CtripOutBitFields;
DISABLE_PROTECTED_REGISTER_WRITE_MODE;
return;} // end of AFE_setM1CtripOut() function
//! \brief Returns the TRUE/FALSE status of the M1 Comparator Trip flags for the analog//! \brief front end (AFE)//! \param[in] AFE_Handle A handle to the AFE object//! \param[in] AFE_CTRIPMxSTATUS_FIELDS_e A single enumeration selecting a single Comparator//! Status Flag to poll//! \return bool_t Boolean result of whether the status flag is set or clearinline bool_t AFE_getM1CtripStatus(AFE_Handle afeHandle, AFE_CTRIPMxSTATUS_FIELDS_e CtripStatusBitFields){ AFE_Obj *afe = (AFE_Obj *)afeHandle; bool_t status = FALSE;
ENABLE_PROTECTED_REGISTER_WRITE_MODE;
//set the selection bits status = (bool_t)(afe->CTRIPM1STS & (uint16_t)CtripStatusBitFields);
23Texas Instruments
Important Notice: The products and services of Texas Instruments Incorporated and its subsidiaries described herein are sold subject to TI’s standard terms and conditions of sale. Customers are advised to obtain the most current and complete information about TI products and services before placing orders. TI assumes no liability for applications assistance, customer’s applications or product designs, software performance, or infringement of patents. The publication of information regarding any other company’s products or services does not constitute TI’s approval, warranty or endorsement thereof.
SPRY234© 2013 Texas Instruments Incorporated
DISABLE_PROTECTED_REGISTER_WRITE_MODE;
return (status);} // end of AFE_getM1CtripStatus() function
//! \brief Clears the Comparator Trip Flags for the analog front end (AFE)//! \param[in] AFE_Handle A handle to the AFE object//! \param[in] AFE_CTRIPMxFLAG_FIELDS_e A single or or’d list of enumerations selecting the Comparator//! flags to resetinline void AFE_clearM1CtripFlag(AFE_Handle afeHandle, AFE_CTRIPMxFLAG_FIELDS_e CtripFlagBitFields){ AFE_Obj *afe = (AFE_Obj *)afeHandle;
ENABLE_PROTECTED_REGISTER_WRITE_MODE;
//set the selection bits afe->CTRIPM1STS |= CtripFlagBitFields;
DISABLE_PROTECTED_REGISTER_WRITE_MODE;
return;} // end of AFE_clearM1CtripFlag() function
#ifdef __cplusplus}#endif // extern “C”
//@} // ingroup
#endif // end of _AFE_H_ definition
24 Texas Instruments
IMPORTANT NOTICE
Texas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, enhancements, improvements and otherchanges to its semiconductor products and services per JESD46, latest issue, and to discontinue any product or service per JESD48, latestissue. Buyers should obtain the latest relevant information before placing orders and should verify that such information is current andcomplete. All semiconductor products (also referred to herein as “components”) are sold subject to TI’s terms and conditions of salesupplied at the time of order acknowledgment.
TI warrants performance of its components to the specifications applicable at the time of sale, in accordance with the warranty in TI’s termsand conditions of sale of semiconductor products. Testing and other quality control techniques are used to the extent TI deems necessaryto support this warranty. Except where mandated by applicable law, testing of all parameters of each component is not necessarilyperformed.
TI assumes no liability for applications assistance or the design of Buyers’ products. Buyers are responsible for their products andapplications using TI components. To minimize the risks associated with Buyers’ products and applications, Buyers should provideadequate design and operating safeguards.
TI does not warrant or represent that any license, either express or implied, is granted under any patent right, copyright, mask work right, orother intellectual property right relating to any combination, machine, or process in which TI components or services are used. Informationpublished by TI regarding third-party products or services does not constitute a license to use such products or services or a warranty orendorsement thereof. Use of such information may require a license from a third party under the patents or other intellectual property of thethird party, or a license from TI under the patents or other intellectual property of TI.
Reproduction of significant portions of TI information in TI data books or data sheets is permissible only if reproduction is without alterationand is accompanied by all associated warranties, conditions, limitations, and notices. TI is not responsible or liable for such altereddocumentation. Information of third parties may be subject to additional restrictions.
Resale of TI components or services with statements different from or beyond the parameters stated by TI for that component or servicevoids all express and any implied warranties for the associated TI component or service and is an unfair and deceptive business practice.TI is not responsible or liable for any such statements.
Buyer acknowledges and agrees that it is solely responsible for compliance with all legal, regulatory and safety-related requirementsconcerning its products, and any use of TI components in its applications, notwithstanding any applications-related information or supportthat may be provided by TI. Buyer represents and agrees that it has all the necessary expertise to create and implement safeguards whichanticipate dangerous consequences of failures, monitor failures and their consequences, lessen the likelihood of failures that might causeharm and take appropriate remedial actions. Buyer will fully indemnify TI and its representatives against any damages arising out of the useof any TI components in safety-critical applications.
In some cases, TI components may be promoted specifically to facilitate safety-related applications. With such components, TI’s goal is tohelp enable customers to design and create their own end-product solutions that meet applicable functional safety standards andrequirements. Nonetheless, such components are subject to these terms.
No TI components are authorized for use in FDA Class III (or similar life-critical medical equipment) unless authorized officers of the partieshave executed a special agreement specifically governing such use.
Only those TI components which TI has specifically designated as military grade or “enhanced plastic” are designed and intended for use inmilitary/aerospace applications or environments. Buyer acknowledges and agrees that any military or aerospace use of TI componentswhich have not been so designated is solely at the Buyer's risk, and that Buyer is solely responsible for compliance with all legal andregulatory requirements in connection with such use.
TI has specifically designated certain components as meeting ISO/TS16949 requirements, mainly for automotive use. In any case of use ofnon-designated products, TI will not be responsible for any failure to meet ISO/TS16949.
Products Applications
Audio www.ti.com/audio Automotive and Transportation www.ti.com/automotive
Amplifiers amplifier.ti.com Communications and Telecom www.ti.com/communications
Data Converters dataconverter.ti.com Computers and Peripherals www.ti.com/computers
DLP® Products www.dlp.com Consumer Electronics www.ti.com/consumer-apps
DSP dsp.ti.com Energy and Lighting www.ti.com/energy
Clocks and Timers www.ti.com/clocks Industrial www.ti.com/industrial
Interface interface.ti.com Medical www.ti.com/medical
Logic logic.ti.com Security www.ti.com/security
Power Mgmt power.ti.com Space, Avionics and Defense www.ti.com/space-avionics-defense
Microcontrollers microcontroller.ti.com Video and Imaging www.ti.com/video
RFID www.ti-rfid.com
OMAP Applications Processors www.ti.com/omap TI E2E Community e2e.ti.com
Wireless Connectivity www.ti.com/wirelessconnectivity
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265Copyright © 2013, Texas Instruments Incorporated