NN library trained with actual motor data
neural_network_3ph.cpp
- Committer:
- cpm219
- Date:
- 2016-11-07
- Revision:
- 0:efebbd20f066
File content as of revision 0:efebbd20f066:
// // File: neural_network_3ph.cpp // // Code generated for Simulink model 'neural_network_3ph'. // // Model version : 1.12 // Simulink Coder version : 8.10 (R2016a) 10-Feb-2016 // C/C++ source code generated on : Tue Nov 01 15:14:34 2016 // // Target selection: ert.tlc // Embedded hardware selection: ARM Compatible->ARM Cortex // Code generation objectives: Unspecified // Validation result: Not run // #include "neural_network_3ph.h" #include "neural_network_3ph_private.h" // Block signals (auto storage) B_neural_network_3ph_T neural_network_3ph_B; // Real-time model RT_MODEL_neural_network_3ph_T neural_network_3ph_M_; RT_MODEL_neural_network_3ph_T *const neural_network_3ph_M = &neural_network_3ph_M_; real_T rt_roundd_snf(real_T u) { real_T y; if (fabs(u) < 4.503599627370496E+15) { if (u >= 0.5) { y = floor(u + 0.5); } else if (u > -0.5) { y = u * 0.0; } else { y = ceil(u - 0.5); } } else { y = u; } return y; } // Model step function void neural_network_custom(real_T arg_In1[61], real_T arg_Out1[2]) { int32_T i; real_T tmp; real_T tmp_0; real_T tmp_1; real_T tmp_2; real_T tmp_3; real_T rtb_Addminy; real_T rtb_Sum1; // DotProduct: '<S9>/Dot Product' tmp_2 = 0.0; // DotProduct: '<S10>/Dot Product' tmp_3 = 0.0; // DotProduct: '<S11>/Dot Product' rtb_Sum1 = 0.0; // DotProduct: '<S12>/Dot Product' neural_network_3ph_B.d0 = 0.0; // DotProduct: '<S13>/Dot Product' neural_network_3ph_B.d1 = 0.0; // DotProduct: '<S14>/Dot Product' tmp = 0.0; // DotProduct: '<S15>/Dot Product' tmp_0 = 0.0; // DotProduct: '<S16>/Dot Product' tmp_1 = 0.0; for (i = 0; i < 61; i++) { // Bias: '<S22>/Add min y' incorporates: // Bias: '<S22>/Subtract min x' // Gain: '<S22>/range y // range x' // Inport: '<Root>/In1' rtb_Addminy = (arg_In1[i] + neural_network_3ph_ConstP.Subtractminx_Bias[i]) * neural_network_3ph_ConstP.rangeyrangex_Gain[i] + -1.0; // DotProduct: '<S9>/Dot Product' incorporates: // Constant: '<S7>/IW{1,1}(1,:)'' tmp_2 += neural_network_3ph_ConstP.IW111_Value[i] * rtb_Addminy; // DotProduct: '<S10>/Dot Product' incorporates: // Constant: '<S7>/IW{1,1}(2,:)'' tmp_3 += neural_network_3ph_ConstP.IW112_Value[i] * rtb_Addminy; // DotProduct: '<S11>/Dot Product' incorporates: // Constant: '<S7>/IW{1,1}(3,:)'' rtb_Sum1 += neural_network_3ph_ConstP.IW113_Value[i] * rtb_Addminy; // DotProduct: '<S12>/Dot Product' incorporates: // Constant: '<S7>/IW{1,1}(4,:)'' neural_network_3ph_B.d0 += neural_network_3ph_ConstP.IW114_Value[i] * rtb_Addminy; // DotProduct: '<S13>/Dot Product' incorporates: // Constant: '<S7>/IW{1,1}(5,:)'' neural_network_3ph_B.d1 += neural_network_3ph_ConstP.IW115_Value[i] * rtb_Addminy; // DotProduct: '<S14>/Dot Product' incorporates: // Constant: '<S7>/IW{1,1}(6,:)'' tmp += neural_network_3ph_ConstP.IW116_Value[i] * rtb_Addminy; // DotProduct: '<S15>/Dot Product' incorporates: // Constant: '<S7>/IW{1,1}(7,:)'' tmp_0 += neural_network_3ph_ConstP.IW117_Value[i] * rtb_Addminy; // DotProduct: '<S16>/Dot Product' incorporates: // Constant: '<S7>/IW{1,1}(8,:)'' tmp_1 += neural_network_3ph_ConstP.IW118_Value[i] * rtb_Addminy; } // Sum: '<S2>/netsum' incorporates: // DotProduct: '<S10>/Dot Product' // DotProduct: '<S11>/Dot Product' // DotProduct: '<S12>/Dot Product' // DotProduct: '<S13>/Dot Product' // DotProduct: '<S14>/Dot Product' // DotProduct: '<S15>/Dot Product' // DotProduct: '<S16>/Dot Product' // DotProduct: '<S9>/Dot Product' neural_network_3ph_B.dv0[0] = tmp_2; neural_network_3ph_B.dv0[1] = tmp_3; neural_network_3ph_B.dv0[2] = rtb_Sum1; neural_network_3ph_B.dv0[3] = neural_network_3ph_B.d0; neural_network_3ph_B.dv0[4] = neural_network_3ph_B.d1; neural_network_3ph_B.dv0[5] = tmp; neural_network_3ph_B.dv0[6] = tmp_0; neural_network_3ph_B.dv0[7] = tmp_1; // DotProduct: '<S20>/Dot Product' tmp_2 = 0.0; // DotProduct: '<S21>/Dot Product' tmp_3 = 0.0; for (i = 0; i < 8; i++) { // Sum: '<S8>/Sum1' incorporates: // Constant: '<S2>/b{1}' // Constant: '<S8>/one' // Constant: '<S8>/one1' // Gain: '<S8>/Gain' // Gain: '<S8>/Gain1' // Sum: '<S2>/netsum' // Sum: '<S8>/Sum' rtb_Sum1 = 1.0 / (exp((neural_network_3ph_B.dv0[i] + neural_network_3ph_ConstP.b1_Value[i]) * -2.0) + 1.0) * 2.0 - 1.0; // DotProduct: '<S20>/Dot Product' incorporates: // Constant: '<S18>/IW{2,1}(1,:)'' tmp_2 += neural_network_3ph_ConstP.IW211_Value[i] * rtb_Sum1; // DotProduct: '<S21>/Dot Product' incorporates: // Constant: '<S18>/IW{2,1}(2,:)'' tmp_3 += neural_network_3ph_ConstP.IW212_Value[i] * rtb_Sum1; } // Outport: '<Root>/Out1' incorporates: // Bias: '<S24>/Subtract min y' // DotProduct: '<S20>/Dot Product' // DotProduct: '<S21>/Dot Product' // Gain: '<S24>/Divide by range y' // Rounding: '<Root>/Rounding Function' // Sum: '<S3>/netsum' arg_Out1[0] = rt_roundd_snf(fabs(((tmp_2 + -0.2665606286241351) + 1.0) * 0.5)); arg_Out1[1] = rt_roundd_snf(fabs(((tmp_3 + -0.17510563077530578) + 1.0) * 0.5)); } // Model initialize function void neural_network_initialize(void) { // Registration code // initialize error status rtmSetErrorStatus(neural_network_3ph_M, (NULL)); } // Model terminate function void neural_network_3ph_terminate(void) { // (no terminate code required) } // // File trailer for generated code. // // [EOF] //