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 - Compilation and general use.
58 - Faulty situation for the ErrFlag to set.
61 RPP API functions used:
66 - hbridge_analog_control
67 - hbridge_digital_control
68 - hbridge_sinewave_control
72 #define S_FUNCTION_NAME sfunction_hbr
76 static void mdlInitializeSizes(SimStruct *S)
79 * Configure parameters: 0
81 if (!rppSetNumParams(S, 0)) {
86 * Configure input ports: 1
90 if (!ssSetNumInputPorts(S, 2)) {
93 rppAddInputPort(S, 0, SS_BOOLEAN);
94 rppAddInputPort(S, 1, SS_DOUBLE);
97 * Configure output ports: 1
100 if (!ssSetNumOutputPorts(S, 1)) {
103 rppAddOutputPort(S, 0, SS_BOOLEAN);
105 /* Set standard options for this block */
106 rppSetStandardOptions(S);
110 #define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
111 #define UNUSED_MDLCHECKPARAMETERS
112 #define UNUSED_MDLOUTPUTS
113 #define UNUSED_MDLTERMINATE