1 /* Copyright (C) 2013, 2014 Czech Technical University in Prague
4 * - Carlos Jenkins <carlos@jenkins.co.cr>
6 * This document contains proprietary information belonging to Czech
7 * Technical University in Prague. Passing on and copying of this
8 * document, and communication of its contents is not permitted
9 * without prior written authorization.
11 * File : sfunction_hbr.c
13 * C-MEX S-function block for RPP H-Bridge output.
20 * <matlabroot>/bin/mex sfunction_hbr.c
26 Name: H-Bridge Control
27 Category: Power output blocks
32 - { name: "Enable", type: "bool" }
33 - { name: "Control", type: "double" }
36 - { name: "ErrFlag", type: "bool" }
40 # Description and Help is in Markdown mark-up
43 Control H-Bridge (10A, PWM) at default frequency.
45 This block expects input in range [-1.0, 1.0].
49 This block allows to control the H-Bridge on the RPP board. The ErrFlag should raise only if
50 `rpp_hbr_control()` returns error. The H-Bridge is initialized with the default frequency
51 (~18kHz). A future improvement could include a parameter to set the frequency. Because the ErrFlag
52 should never set, once set the following steps will never clear it back.
56 RPP API functions used:
61 - hbridge_analog_control
62 - hbridge_digital_control
63 - hbridge_sinewave_control
67 #define S_FUNCTION_NAME sfunction_hbr
71 static void mdlInitializeSizes(SimStruct *S)
74 * Configure parameters: 0
76 if (!rppSetNumParams(S, 0)) {
81 * Configure input ports: 1
85 if (!ssSetNumInputPorts(S, 2)) {
88 rppAddInputPort(S, 0, SS_BOOLEAN);
89 rppAddInputPort(S, 1, SS_DOUBLE);
92 * Configure output ports: 1
95 if (!ssSetNumOutputPorts(S, 1)) {
98 rppAddOutputPort(S, 0, SS_BOOLEAN);
100 /* Set standard options for this block */
101 rppSetStandardOptions(S);
105 #define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
106 #define UNUSED_MDLCHECKPARAMETERS
107 #define UNUSED_MDLOUTPUTS
108 #define UNUSED_MDLTERMINATE