10#include "system/pins.h"
15#include "pwrctrl/pwrctrl.h"
16#include "config/version.h"
25#define FIRMWARE_PROTOCOL_ID 0x1000
27#define PBV_GUI_BUTTONS 0x202
28#define PBV_GUI_SLIDERS 0x203
29#define PBV_SYSTEM_TO_GUI_ID 0x204
30#define PBV_LOG_ID 0x300
43uint8_t buffer_eight_rx[64];
44uint16_t buffer_sixteen_rx[32];
46uint8_t buffer_eight_tx[64];
47uint16_t buffer_sixteen_tx[32];
49static uint32_t tick_counter = 0;
50static uint8_t transmit_firmware_id = 1;
53static uint16_t slider_PS_PP = 0 ;
54static uint16_t dead_time_right = 0;
55static uint16_t voltage_ref = 0;
56static uint16_t current_ref = 0;
57static uint16_t current_slider_ref = 0;
60 static uint8_t button_start = 0;
61static uint8_t button_start_sync = 0;
70void App_PBV_psfb_Process_Buttons(uint16_t * data);
71void App_PBV_psfb_Process_Sliders(uint16_t * data);
72void App_PBV_psfb_Frame_Parser(uint16_t protocol_ID, uint16_t length, uint8_t * data);
92 App_PBV_psfb_TX_Ptr->
Length = 64;
99 App_PBV_psfb_ASCII_Ptr->
Length = 64;
101 app_PBV_Init(App_PBV_psfb_TX_Ptr, App_PBV_psfb_ASCII_Ptr, App_PBV_psfb_RX_Ptr);
104 dead_time_right = PG1DTH;
106 current_slider_ref = DAC3DATH;
122 app_Read_Received_From_PBV(App_PBV_psfb_RX_Ptr);
126 app_Receive_From_PBV(App_PBV_psfb_RX_Ptr);
129 if (++tick_counter > 11)
149 App_PBV_psfb_ASCII_Ptr->
Data_Buffer =
"Firmware Version 1.0.0.0.......................................!";
152 transmit_firmware_id = 1;
157 if (transmit_firmware_id) app_PBV_Re_Init(App_PBV_psfb_ASCII_Ptr);
158 transmit_firmware_id = 0;
160 App_PBV_psfb_ASCII_Ptr->
Data_Buffer =
"Log Message From Protocol ID 0x300.............................\r";
178 return App_PBV_psfb_ASCII_Ptr;
199 uint16_t flag_word = enabled + ((status_flags & 0x0003)<<1) + (fault_flags<<3);
202 buffer_sixteen_tx[1] = flag_word;
211 buffer_sixteen_tx[7] = DAC3DATH;
234 buffer_sixteen_tx[21] = PG1TRIGC;
247 buffer_sixteen_tx[27] = (uint16_t)
temp;
254 PBV_Change_from_Sixteen_to_Eight(buffer_sixteen_tx, buffer_eight_tx, 30);
256 App_PBV_psfb_TX_Ptr->
Data_Buffer = buffer_eight_tx;
257 App_PBV_psfb_TX_Ptr->
Length = 30 * 2 ;
268void App_PBV_psfb_Process_Buttons(uint16_t * data) {
269 uint16_t switchcase = data[0];
270 switch (switchcase) {
313void App_PBV_psfb_Process_Sliders(uint16_t * data) {
314 uint16_t switchcase = data[0];
322 switch (switchcase) {
327 slider_PS_PP = data[1];
340 dead_time_right = data[1];
356 PG1STATbits.UPDREQ = 1;
363 current_ref = data[1];
368 voltage_ref = data[1];
374 vreftemp = (float)voltage_ref * 1;
406void App_PBV_psfb_Frame_Parser(uint16_t protocol_ID, uint16_t length, uint8_t * data){
407 PBV_Change_from_Eight_to_Sixteen(data, buffer_sixteen_rx, length);
408 switch (protocol_ID){
409 case PBV_GUI_BUTTONS:
410 App_PBV_psfb_Process_Buttons(buffer_sixteen_rx);
412 case PBV_GUI_SLIDERS:
413 App_PBV_psfb_Process_Sliders(buffer_sixteen_rx);
This is the generated driver header file for the PWM driver.
app PBV psfb Frame map file Example
uint16_t Fault_GetFlags(void)
Contains API functions for fault protection.
POWER_CONTROL_t * psfb_ptr
Contains public functions relevant for power control communication interface.
Contains public functions for PWM.
void app_Send_To_PBV(PBV_Datatype_TX_t *ptr)
@ PBV_MESSAGE_READY_TO_RECEIVE
Message Reception triggered.
@ PBV_MESSAGE_RECEIVED
Message Received.
@ PBV_ASCII_MODE
Object will transmit Ascii data.
@ PBV_SIGNAL_MODE
Object will transmit/receive signals.
@ PBV_MESSAGE_INIT
Init State. Only Send Messages in this State
@ PBV_MESSAGE_TRANSMITTING
Transmitting Message.
void App_PBV_psfb_Task_1s(void)
1 second PBV task to be execution
void App_PBV_psfb_Task_10ms(void)
this is high frequency task to simulate sending of high frequency numeric data. Also to check if ther...
void App_PBV_psfb_Init()
This function initializes the local pbv objects. these objects are then passed on to the app_PBV_init...
PBV_Datatype_TX_t * App_PB_psfb_Get_TX_ASCII_ptr(void)
this function can be used to send log messages from other files.
#define FIRMWARE_PROTOCOL_ID
protocol ids defined. firmware id 0x1000 is fixed. the rest are arbitary
void App_PBV_psfb_Build_Frame(void)
this builds frame
void PwrCtrl_Reset(void)
Resets the power control properties.
void PwrCtrl_MaxDutyCycle(void)
Calculates the max duty cycle for precharge.
void PwrCtrl_PWM_Update()
PWM distribution for PSFB converter.
void PwrCtrl_PWM_Enable(void)
Enable the PWM output.
void PwrCtrl_SetEnable(bool enable)
API function to set the power control enable bit.
uint16_t Dev_PwrCtrl_Get_State(void)
API function to get the current state of the state machine.
uint16_t Dev_PwrCtrl_GetIPri_Offset(void)
API function to get the value of the primary sensor offset value.
uint16_t PwrCtrl_GetAdc_Ipri_ct(void)
API function to get the raw ADC value for primary current transformer current.
void PwrCtrl_SetIReference(uint16_t reference)
API function to set the current controller reference.
uint16_t PwrCtrl_GetAdc_Isec_shunt(void)
API function to get the raw ADC value for secondary current transformer current.
uint16_t Dev_PwrCtrl_GetIsec_Offset(void)
API function to get the value of the secondary sensor offset value.
uint16_t Dev_PwrCtrl_Get_EnableFlag(void)
API function to get the state of the power control enable bit.
uint16_t Dev_PwrCtrl_GetAdc_Vpri(void)
API function to get the value of the sampled ADC for input Voltage.
void PwrCtrl_SetVSecReference(uint16_t reference)
API function to set the secondary voltage controller reference.
uint16_t Dev_PwrCtrl_GetAdc_Vsec(void)
API function to get the value of the sampled ADC for output Voltage.
uint16_t Dev_PwrCtrl_Get_Status(void)
API function to get the power control status.
uint16_t PwrCtrl_GetAdc_Temperature(void)
API function to get the raw ADC value for temperature.
uint16_t Dev_PwrCtrl_GetVoltage_Vcap(void)
API function to get the value of the sampled ADC for Capacitor Voltage.
void PwrCtrl_SetPhaseTarget(uint16_t reference)
API function to set the target PWM phase.
uint16_t PwrCtrl_GetAdc_Vrail_5V(void)
API function to get the raw ADC value for 5V rail.
void Fault_Reset(void)
Clears the fault object flag bits.
#define FAULT_EN_GetValue()
Reads the value of the RD9 GPIO Pin which has a custom name of FAULT_EN.
#define FAULT_EN_SetLow()
Sets the RD9 GPIO Pin which has a custom name of FAULT_EN to Low.
uint32_t PBV_Protcol_ID
Protocol ID.
uint8_t * Data_Buffer
Pointer to the data to be transmitted.
enum PBV_SIGNAL_ASCII_MODE PBV_Signal_Ascii
Object will transmit Signals or ASCII.
PBV_MESSAGE_TX_STATE_t PBV_Message_State
State of the TX object.
uint16_t Length
Length of transmitted message in Bytes.
uint32_t PBV_Protcol_ID
Protocol ID of the received message.
PBV_MESSAGE_RX_STATE_t PBV_Message_State
State of the received message.
uint8_t * Data_Buffer
Received Data pointer.
uint16_t Length
Length of received message in Bytes.
uint16_t Output
controller output
bool Enable
Enable control loop.
int16_t Reference
actual reference
uint16_t VSecReference
User secondary-voltage port reference setting used to control the power converter output voltage in b...
uint16_t Droop_Voltage_Reference_from_PBV
uint16_t calculated_value
CONTROLLER_t ILoop
structure for current controller data
PWR_CTRL_PROPERTIES_t Properties
Power Control properties
PRECHARGE_t Precharge
structure for precharge data
DROOP_t Droop
droop controller data
SEC_REC_t SecRec
structure for secondary rectification data
CALIBRATE_t VoutCalibrate
structure for Calibrating Vout during Droop using Averaged value
CONTROLLER_t VLoop
structure for voltage controller data
AVERAGING_t ISecAveraging
secondary current average
uint16_t Secondary_Rolling_val
Secondary Current Rolling Average Value.