ConOpSys V2970  P004.07
ANVILEX control operating system
PWM_1C2P2L.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //! @file PWM_1C2P2L.h
3 //! @author ANVILEX GmbH
4 //! @version V1.0
5 //! @date 03.05.2016
6 //! @brief Single channel 2-phase 2-level pulse width modulator object header file.
7 //! @attention
8 //!
9 //! COPYRIGHT(C) 2015-2017 ANVILEX GmbH
10 //!
11 //! Redistribution and use in source and binary forms, with or without
12 //! modification, are permitted provided that the following conditions are met:
13 //!
14 //! 1. Redistributions of source code must retain the above copyright notice,
15 //! this list of conditions and the following disclaimer.
16 //!
17 //! 2. Redistributions in binary form must reproduce the above copyright notice,
18 //! this list of conditions and the following disclaimer in the documentation
19 //! and/or other materials provided with the distribution.
20 //!
21 //! 3. Neither the name of ANVILEX nor the names of its contributors may be
22 //! used to endorse or promote products derived from this software without
23 //! specific prior written permission.
24 //!
25 //! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 //! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 //! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 //! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
29 //! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 //! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 //! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 //! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 //! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 //! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 //! POSSIBILITY OF SUCH DAMAGE.
36 //------------------------------------------------------------------------------
37 
38 //------------------------------------------------------------------------------
39 // Protecting header files from mutual, recursive inclusion.
40 //------------------------------------------------------------------------------
41 
42 #pragma once
43 
44 //------------------------------------------------------------------------------
45 // Include standard libraries header files
46 //------------------------------------------------------------------------------
47 
48 //------------------------------------------------------------------------------
49 // Include thrid party header files
50 //------------------------------------------------------------------------------
51 
52 //------------------------------------------------------------------------------
53 // Include ConOpSys header files
54 //------------------------------------------------------------------------------
55 
56 #include "Application_Resource_Configuration.h"
57 #include "Function_Block_Base.h"
58 
59 //------------------------------------------------------------------------------
60 // Include ConOpSys application header files
61 //------------------------------------------------------------------------------
62 
63 //------------------------------------------------------------------------------
64 // Check requered includes
65 //------------------------------------------------------------------------------
66 /*
67 #ifndef __APPLICATION_RESOURCE_CONFIGURATION_H
68 #error "System resourse configuration file not included."
69 #endif
70 */
71 //------------------------------------------------------------------------------
72 // Macros
73 //------------------------------------------------------------------------------
74 
75 //------------------------------------------------------------------------------
76 //! @brief Single channel 2-phase 2-level pulse width modulator object class
77 //------------------------------------------------------------------------------
78 
80 {
81 
82  //----------------------------------------------------------------------------
83  // Public defines, methods and variables
84  //----------------------------------------------------------------------------
85 
86  public:
87 
88  // Register structure for generic access
89  typedef struct
90  {
91 
92  // Control and status registars
93  union
94  {
95  U16 u16_Control; //!< Offset 0x00, Twin PWM module control register
96  U16 u16_Status; //!< Offset 0x00, Twin PWM module status register
97  };
98 
99  // Configuration registers
100  U16 u16_Half_Periode; //!< Offset 0x01, Half PWM periode register
101  U16 u16_Dead_Time_Inverter; //!< Offset 0x02, Dead time register of the inverter
102  U16 u16_Reserve_3; //!< Offset 0x03, Not used
103 
104  // Inverter 1 PWM setpoint registers
105  I16 i16_Setpoint_Inverter_L1; //!< Offset 0x04, Set point of the inverter leg 1
106  I16 i16_Setpoint_Inverter_L2; //!< Offset 0x05, Set point of the inverter leg 2
107  U16 u16_Reserve_6; //!< Offset 0x06, Not used
108  U16 u16_Reserve_7; //!< Offset 0x07, Not used
109 
110  // Inverter 2 PWM Setpoint registers
111  U16 u16_Reserve_8; //!< Offset 0x08, Not used
112  U16 u16_Reserve_9; //!< Offset 0x09, Not used
113  U16 u16_Reserve_A; //!< Offset 0x0A, Not used
114  U16 u16_Reserve_B; //!< Offset 0x0B, Not used
115 
116  // Reserved registers
117  U16 u16_Reserve_C; //!< Offset 0x0C, Not used
118  U16 u16_Reserve_D; //!< Offset 0x0D, Not used
119  U16 u16_Reserve_E; //!< Offset 0x0E, Not used
120  U16 u16_Reserve_F; //!< Offset 0x0F, Not used
121 
123 
124  //--------------------------------------------------------------------------
125  // Public methods
126  //--------------------------------------------------------------------------
127 
128  // Constructor and destructor
129  TPWM_1C2P2L(); //!< Constructor method
130 
131  //!-------------------------------------------------------------------------
132  //! @brief Class destructor method.
133  //! @note None
134  //! \par Override
135  //! Not allowed
136  //! @attention Don't call this method directly.
137  //--------------------------------------------------------------------------
138 
139  virtual ~TPWM_1C2P2L();
140 
141  VOID Map( TPWM_1C2P2L_Registers *struct_Registers_Base_Address ); //!< Hardware mapping method
142 
143  //!-------------------------------------------------------------------------
144  //! @brief Function block initialisation method.
145  //! @note None
146  //! \par Override
147  //! Not allowed
148  //! @attention Don't call this method directly.
149  //--------------------------------------------------------------------------
150 
151  virtual VOID Init();
152 
153  //!-------------------------------------------------------------------------
154  //! @brief Function block execution method.
155  //! @note None
156  //! \par Override
157  //! Not allowed
158  //! @attention None
159  //--------------------------------------------------------------------------
160 
161  virtual VOID Execute();
162 
163  //!-------------------------------------------------------------------------
164  //! @brief Send information about Function block over communication link protocol
165  //! @note This method sends information about Function block over specified communication link protocol.
166  //! @param [in] *object_Protocol - Pointer to the communication link protocol
167  //! @return None
168  //! \par Override
169  //! Not allowed
170  //! @attention None
171  //--------------------------------------------------------------------------
172 
173  virtual VOID Send_Information( TProtocol_Base *object_Protocol );
174 
175  //--------------------------------------------------------------------------
176  // Public variables
177  //--------------------------------------------------------------------------
178 
179  // Parameters
180 
182 
183  // Inputs
184 
186 
189 
191 
192  // Outputs
193 
194  TBlock_Output_Connector object_f32_Sample_Time; // [s] Control event sample time
195 
196  //--------------------------------------------------------------------------
197  // Diagnose outputs
198  //--------------------------------------------------------------------------
199 
200  #ifdef FUNCTIONAL_BLOCK_CREATE_DIAGNOSE_OUTPUTS
201 
202  F32 f32_K;
203 
204  F32 f32_Inverter_Phase_L1_Time;
205  F32 f32_Inverter_Phase_L2_Time;
206 
207  F32 f32_Inverter_Minimum_Time;
208  F32 f32_Inverter_Maximum_Time;
209 
210  F32 f32_Inverter_Offset;
211 
212  I32 i32_Inverter_Phase_L1_Setpoint;
213  I32 i32_Inverter_Phase_L2_Setpoint;
214 
215  U16 u16_Control;
216 
217  #endif
218 
219  //----------------------------------------------------------------------------
220  // Protected defines, variables and methods
221  //----------------------------------------------------------------------------
222 
223  protected:
224 
225  //----------------------------------------------------------------------------
226  // Private defines, variables and methods
227  //----------------------------------------------------------------------------
228 
229  private:
230 
231  TPWM_1C2P2L_Registers *struct_Registers; //!< FPGA mapped registers
232 
233  F32 f32_Clock_Frequency; //!< [Hz] FPGA system clock
234  U16 u16_Periode; //!< [Counts] Periode in counts
235  U16 u16_Half_Periode; //!< [Counts] Half periode in counts
236  U16 u16_Quarter_Periode; //!< [Counts] Quarter periode
237 
238  U16 u16_Inverter_Deadtime; //!< Inverter deadtime in FPGA clock counts
239 
240 };
241 
242 //------------------------------------------------------------------------------
243 // End Of File
244 //------------------------------------------------------------------------------
long I32
2s Compliment 32-Bit signed integer datatype defenition
Definition: Defines.h:206
void VOID
Datatypesess datatype definition.
Definition: Defines.h:105
float F32
IEEE-754 32-Bit single presession floating point numbers datatype defenition.
Definition: Defines.h:324
short I16
2s Compliment 16-Bit signed integer datatype defenition
Definition: Defines.h:196
unsigned short U16
Binary 16-Bit unsigned integer datatype defenition.
Definition: Defines.h:193
Function block base class header file.
Function block input connector class.
Definition: Block_Input_Connector.h:83
Function block output connector class.
Definition: Block_Output_Connector.h:59
Function block base class for device.
Definition: Function_Block_Base.h:96
Single channel 2-phase 2-level pulse width modulator object class.
Definition: PWM_1C2P2L.h:80
TBlock_Input_Connector object_bool_Enable_Inverter
Definition: PWM_1C2P2L.h:185
TBlock_Output_Connector object_f32_Sample_Time
Definition: PWM_1C2P2L.h:194
TBlock_Input_Connector object_f32_Inverter_Phase_L2_Voltage
Definition: PWM_1C2P2L.h:188
U16 u16_Inverter_Deadtime
Inverter deadtime in FPGA clock counts.
Definition: PWM_1C2P2L.h:238
virtual VOID Init()
Function block initialisation method.
Definition: PWM_1C2P2L.cpp:141
VOID Map(TPWM_1C2P2L_Registers *struct_Registers_Base_Address)
Hardware mapping method.
Definition: PWM_1C2P2L.cpp:129
virtual VOID Send_Information(TProtocol_Base *object_Protocol)
Send information about Function block over communication link protocol.
Definition: PWM_1C2P2L.cpp:306
TPWM_1C2P2L()
Constructor method.
Definition: PWM_1C2P2L.cpp:68
TBlock_Input_Connector object_f32_DC_Bus_Voltage
Definition: PWM_1C2P2L.h:190
virtual VOID Execute()
Function block execution method.
Definition: PWM_1C2P2L.cpp:181
TBlock_Input_Connector object_f32_Inverter_Phase_L1_Voltage
Definition: PWM_1C2P2L.h:187
U16 u16_Periode
[Counts] Periode in counts
Definition: PWM_1C2P2L.h:234
U16 u16_Half_Periode
[Counts] Half periode in counts
Definition: PWM_1C2P2L.h:235
TBlock_Input_Connector object_f32_Switching_Frequency
Definition: PWM_1C2P2L.h:181
U16 u16_Quarter_Periode
[Counts] Quarter periode
Definition: PWM_1C2P2L.h:236
TPWM_1C2P2L_Registers * struct_Registers
FPGA mapped registers.
Definition: PWM_1C2P2L.h:231
F32 f32_Clock_Frequency
[Hz] FPGA system clock
Definition: PWM_1C2P2L.h:233
virtual ~TPWM_1C2P2L()
Class destructor method.
Definition: PWM_1C2P2L.cpp:121
Definition: Protocol_Base.h:57
Definition: PWM_1C2P2L.h:90
I16 i16_Setpoint_Inverter_L2
Offset 0x05, Set point of the inverter leg 2.
Definition: PWM_1C2P2L.h:106
U16 u16_Status
Offset 0x00, Twin PWM module status register.
Definition: PWM_1C2P2L.h:96
U16 u16_Reserve_9
Offset 0x09, Not used.
Definition: PWM_1C2P2L.h:112
U16 u16_Reserve_F
Offset 0x0F, Not used.
Definition: PWM_1C2P2L.h:120
I16 i16_Setpoint_Inverter_L1
Offset 0x04, Set point of the inverter leg 1.
Definition: PWM_1C2P2L.h:105
U16 u16_Reserve_D
Offset 0x0D, Not used.
Definition: PWM_1C2P2L.h:118
U16 u16_Reserve_C
Offset 0x0C, Not used.
Definition: PWM_1C2P2L.h:117
U16 u16_Control
Offset 0x00, Twin PWM module control register.
Definition: PWM_1C2P2L.h:95
U16 u16_Reserve_7
Offset 0x07, Not used.
Definition: PWM_1C2P2L.h:108
U16 u16_Reserve_8
Offset 0x08, Not used.
Definition: PWM_1C2P2L.h:111
U16 u16_Half_Periode
Offset 0x01, Half PWM periode register.
Definition: PWM_1C2P2L.h:100
U16 u16_Reserve_3
Offset 0x03, Not used.
Definition: PWM_1C2P2L.h:102
U16 u16_Reserve_E
Offset 0x0E, Not used.
Definition: PWM_1C2P2L.h:119
U16 u16_Dead_Time_Inverter
Offset 0x02, Dead time register of the inverter.
Definition: PWM_1C2P2L.h:101
U16 u16_Reserve_A
Offset 0x0A, Not used.
Definition: PWM_1C2P2L.h:113
U16 u16_Reserve_6
Offset 0x06, Not used.
Definition: PWM_1C2P2L.h:107
U16 u16_Reserve_B
Offset 0x0B, Not used.
Definition: PWM_1C2P2L.h:114