* apps/include/industry/foc/float/foc_handler.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __INDUSTRY_FOC_FLOAT_FOC_HANDLER_H
#define __INDUSTRY_FOC_FLOAT_FOC_HANDLER_H
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <dsp.h>
#ifdef CONFIG_INDUSTRY_FOC_CORDIC
# include "industry/foc/float/foc_cordic.h"
#endif
* Public Type Definition
****************************************************************************/
struct foc_handler_input_f32_s
{
FAR float *current;
FAR dq_frame_f32_t *dq_ref;
FAR dq_frame_f32_t *vdq_comp;
float angle;
float vbus;
int mode;
};
struct foc_handler_output_f32_s
{
float duty[CONFIG_MOTOR_FOC_PHASES];
};
struct foc_state_f32_s
{
float curr[CONFIG_MOTOR_FOC_PHASES];
float volt[CONFIG_MOTOR_FOC_PHASES];
ab_frame_f32_t iab;
ab_frame_f32_t vab;
dq_frame_f32_t vdq;
dq_frame_f32_t idq;
float mod_scale;
};
typedef struct foc_handler_f32_s foc_handler_f32_t;
struct foc_modulation_ops_f32_s
{
CODE int (*init)(FAR foc_handler_f32_t *h);
CODE void (*deinit)(FAR foc_handler_f32_t *h);
CODE void (*cfg)(FAR foc_handler_f32_t *h, FAR void *cfg);
CODE void (*current)(FAR foc_handler_f32_t *h, FAR float *curr);
CODE void (*vbase_get)(FAR foc_handler_f32_t *h,
float vbus,
FAR float *vbase);
CODE void (*run)(FAR foc_handler_f32_t *h,
FAR ab_frame_f32_t *v_ab_mod,
FAR float *duty);
CODE void (*state_get)(FAR foc_handler_f32_t *h,
FAR void *state);
};
struct foc_control_ops_f32_s
{
CODE int (*init)(FAR foc_handler_f32_t *h);
CODE void (*deinit)(FAR foc_handler_f32_t *h);
CODE void (*cfg)(FAR foc_handler_f32_t *h,
FAR void *cfg);
CODE void (*input_set)(FAR foc_handler_f32_t *h,
FAR float *current,
float vbase,
float angle);
CODE void (*voltage_run)(FAR foc_handler_f32_t *h,
FAR dq_frame_f32_t *dq_ref,
FAR ab_frame_f32_t *v_ab_mod);
CODE void (*current_run)(FAR foc_handler_f32_t *h,
FAR dq_frame_f32_t *dq_ref,
FAR dq_frame_f32_t *vdq_comp,
FAR ab_frame_f32_t *v_ab_mod);
CODE void (*state_get)(FAR foc_handler_f32_t *h,
FAR struct foc_state_f32_s *state);
};
struct foc_handler_ops_f32_s
{
struct foc_control_ops_f32_s *ctrl;
struct foc_modulation_ops_f32_s *mod;
};
struct foc_handler_f32_s
{
#ifdef CONFIG_INDUSTRY_FOC_CORDIC
int fd;
#endif
struct foc_handler_ops_f32_s ops;
FAR void *modulation;
FAR void *control;
};
struct foc_mod_cfg_f32_s
{
float pwm_duty_max;
};
* Public Data
****************************************************************************/
#ifdef CONFIG_INDUSTRY_FOC_CONTROL_PI
extern struct foc_control_ops_f32_s g_foc_control_pi_f32;
#endif
#ifdef CONFIG_INDUSTRY_FOC_MODULATION_SVM3
extern struct foc_modulation_ops_f32_s g_foc_mod_svm3_f32;
#endif
* Public Function Prototypes
****************************************************************************/
* Name: foc_handler_init_f32
****************************************************************************/
int foc_handler_init_f32(FAR foc_handler_f32_t *h,
FAR struct foc_control_ops_f32_s *ctrl,
FAR struct foc_modulation_ops_f32_s *mod);
* Name: foc_handler_deinit_f32
****************************************************************************/
int foc_handler_deinit_f32(FAR foc_handler_f32_t *h);
* Name: foc_handler_run_f32
****************************************************************************/
int foc_handler_run_f32(FAR foc_handler_f32_t *h,
FAR struct foc_handler_input_f32_s *in,
FAR struct foc_handler_output_f32_s *out);
* Name: foc_handler_cfg_f32
****************************************************************************/
void foc_handler_cfg_f32(FAR foc_handler_f32_t *h,
FAR void *ctrl_cfg,
FAR void *mod_cfg);
* Name: foc_handler_state_f32
****************************************************************************/
void foc_handler_state_f32(FAR foc_handler_f32_t *h,
FAR struct foc_state_f32_s *state,
FAR void *mod_state);
#ifdef CONFIG_INDUSTRY_FOC_HANDLER_PRINT
* Name: foc_handler_state_print_f32
****************************************************************************/
void foc_handler_state_print_f32(FAR struct foc_state_f32_s *state);
#endif
#endif