Simulation Core
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

248 lines
15 KiB

  1. subroutine TopDrive_Solver
  2. use SimulationVariables
  3. use UnitySignalsModule
  4. IMPLICIT NONE
  5. data%State%TDS%TDS_wOld = ((pi*data%State%TDS%Speed)/30.d0) ![rad/s]
  6. !******************************************************************
  7. if ( data%State%TDS%PowerState==-1 .or. data%State%TDS%OldPowerMode==-1 ) then !FWD
  8. if ( data%State%TDS%DrillTorqueState==0 .and. Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING ) then ! TdsMu_SPINE
  9. data%State%TDS%OperationFaultLed = 0
  10. data%State%TDS%Speed = 0.d0 !Speed [RPM]
  11. data%State%TDS%RpmGaugeOutput = 30.d0
  12. data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput
  13. data%State%TDS%SoundRPM = 30
  14. data%State%TDS%Torque = 0.d0 ![ft.lbf]
  15. data%State%TDS%TorqueGaugeOutput = 0.d0
  16. data%State%TDS%OldPowerMode = -1
  17. else if ( data%State%TDS%DrillTorqueState==0 .and. Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then ! TdsMu_SPINE
  18. data%State%TDS%OperationFaultLed = 0
  19. data%State%TDS%Speed = 0.d0 !Speed [RPM]
  20. data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed
  21. data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput
  22. data%State%TDS%SoundRPM = 0
  23. data%State%TDS%Torque = 0.d0 ![ft.lbf]
  24. data%State%TDS%TorqueGaugeOutput = 1000.d0
  25. data%State%TDS%OldPowerMode = -1
  26. else if ( data%State%TDS%DrillTorqueState==1 ) then ! TdsMu_Torque
  27. if ( data%State%TDS%RpmKnob>0. ) then
  28. data%State%TDS%OperationFaultLed = 1
  29. data%State%TDS%Speed = 0.d0 !Speed [RPM]
  30. data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed
  31. data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput
  32. data%State%TDS%SoundRPM = 0
  33. data%State%TDS%Torque = 0.d0 ![ft.lbf]
  34. data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  35. data%State%TDS%OldPowerMode = -1
  36. else
  37. data%State%TDS%OperationFaultLed = 0
  38. if ( Get_TdsConnectionModes()==TDS_CONNECTION_STRING ) then
  39. data%State%TDS%Speed = 0.d0 !Speed [RPM]
  40. data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed
  41. data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput
  42. data%State%TDS%SoundRPM = 0
  43. data%State%TDS%Torque = 0.d0 ![ft.lbf]
  44. data%State%TDS%TorqueGaugeOutput = max( 1000.d0,((data%State%TDS%TorqueLimitKnob/10.d0)*60000.d0) ) ![ft.lbf] ????
  45. data%State%TDS%OldPowerMode = -1
  46. else if ( Get_TdsConnectionModes()==Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING ) then
  47. data%State%TDS%Speed = 0.d0 !Speed [RPM]
  48. data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed
  49. data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput
  50. data%State%TDS%SoundRPM = 0
  51. data%State%TDS%Torque = 0.d0 ![ft.lbf]
  52. data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  53. data%State%TDS%OldPowerMode = -1
  54. else if ( Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then
  55. data%State%TDS%Speed = 0.d0 !Speed [RPM]
  56. data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed
  57. data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput
  58. data%State%TDS%SoundRPM = 0
  59. data%State%TDS%Torque = 0.d0 ![ft.lbf]
  60. data%State%TDS%TorqueGaugeOutput = 1000.d0 ![ft.lbf]
  61. data%State%TDS%OldPowerMode = -1
  62. end if
  63. end if
  64. else if ( data%State%TDS%DrillTorqueState==-1 ) then ! TdsMu_DRILL
  65. if ( Get_TdsConnectionModes()==TDS_CONNECTION_STRING ) then
  66. data%State%TDS%OperationFaultLed = 0
  67. data%State%TDS%Speed = data%State%TDS%N_ref/data%State%TDS%Conv_Ratio !Speed [RPM]
  68. data%State%TDS%Speed = min(data%State%TDS%Speed,data%State%TDS%MaxRPM)
  69. data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed
  70. data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput
  71. data%State%TDS%SoundRPM = INT(data%State%TDS%Speed)
  72. data%State%TDS%Torque = ( ((data%State%TDS%J_coef+data%State%TDS%String_JCoef)*(((((pi*data%State%TDS%N_ref)/30.d0)/data%State%TDS%Conv_Ratio)-data%State%TDS%TDS_wOld)/data%State%TDS%time_step))+(data%State%TDS%String_Torque) )*0.73756215d0 ![N.m]*0.73756215 = [ft.lbf]
  73. data%State%TDS%Torque = min(data%State%TDS%Torque,data%State%TDS%MaxTorque) ! [ft.lbf]
  74. data%State%TDS%TorqueGaugeOutput = data%State%TDS%Torque
  75. data%State%TDS%OldPowerMode = -1
  76. else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING ) then
  77. data%State%TDS%OperationFaultLed = 0
  78. data%State%TDS%Speed = 0.0d0
  79. data%State%TDS%RpmGaugeOutput = data%State%TDS%N_ref/data%State%TDS%Conv_Ratio !Speed [RPM]
  80. data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput
  81. data%State%TDS%SoundRPM = INT(data%State%TDS%N_ref/data%State%TDS%Conv_Ratio)
  82. data%State%TDS%Torque = 0.0d0
  83. data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  84. data%State%TDS%OldPowerMode = -1
  85. else if ( Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then
  86. if ( data%State%TDS%RpmKnob>0. ) then
  87. data%State%TDS%OperationFaultLed = 1
  88. data%State%TDS%Speed = 0.d0 !Speed [RPM]
  89. data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed
  90. data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput
  91. data%State%TDS%SoundRPM = 0
  92. data%State%TDS%Torque = 0.d0 ![ft.lbf]
  93. data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  94. data%State%TDS%OldPowerMode = -1
  95. else
  96. data%State%TDS%OperationFaultLed = 0
  97. data%State%TDS%Speed = 0.d0 !Speed [RPM]
  98. data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed
  99. data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput
  100. data%State%TDS%SoundRPM = 0
  101. data%State%TDS%Torque = 0.d0 ![ft.lbf]
  102. data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  103. data%State%TDS%OldPowerMode = -1
  104. end if
  105. end if
  106. else
  107. data%State%TDS%OperationFaultLed = 0
  108. data%State%TDS%Speed = 0.d0 !Speed [RPM]
  109. data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed
  110. data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput
  111. data%State%TDS%SoundRPM = 0
  112. data%State%TDS%Torque = 0.d0 ![ft.lbf]
  113. data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  114. data%State%TDS%OldPowerMode = -1
  115. end if
  116. else if ( data%State%TDS%PowerState==1 .or. data%State%TDS%OldPowerMode==1 ) then !REV
  117. if ( data%State%TDS%DrillTorqueState==0 .and. Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING ) then ! TdsMu_SPINE
  118. data%State%TDS%OperationFaultLed = 0
  119. data%State%TDS%Speed = 0.d0 !Speed [RPM]
  120. data%State%TDS%RpmGaugeOutput = 30.d0
  121. data%State%TDS%RPMUnityOutput = -data%State%TDS%RpmGaugeOutput
  122. data%State%TDS%SoundRPM = 30
  123. data%State%TDS%Torque = 0.d0 ![ft.lbf]
  124. data%State%TDS%TorqueGaugeOutput = 0.d0
  125. data%State%TDS%OldPowerMode = 1
  126. else if ( data%State%TDS%DrillTorqueState==0 .and. Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then ! TdsMu_SPINE
  127. data%State%TDS%OperationFaultLed = 0
  128. data%State%TDS%Speed = 0.d0 !Speed [RPM]
  129. data%State%TDS%RpmGaugeOutput = 30.d0
  130. data%State%TDS%RPMUnityOutput = -data%State%TDS%RpmGaugeOutput
  131. data%State%TDS%SoundRPM = 0
  132. data%State%TDS%Torque = 0.d0 ![ft.lbf]
  133. data%State%TDS%TorqueGaugeOutput = 1000.d0
  134. data%State%TDS%OldPowerMode = 1
  135. else if ( data%State%TDS%DrillTorqueState==1 ) then ! TdsMu_Torque
  136. if ( data%State%TDS%RpmKnob>0.d0 ) then
  137. data%State%TDS%OperationFaultLed = 1
  138. data%State%TDS%Speed = 0.d0 !Speed [RPM]
  139. data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed
  140. data%State%TDS%RPMUnityOutput = -data%State%TDS%RpmGaugeOutput
  141. data%State%TDS%SoundRPM = 0
  142. data%State%TDS%Torque = 0.d0 ![ft.lbf]
  143. data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  144. data%State%TDS%OldPowerMode = 1
  145. else
  146. data%State%TDS%OperationFaultLed = 0
  147. if ( Get_TdsConnectionModes()==TDS_CONNECTION_STRING ) then
  148. data%State%TDS%Speed = 0.d0 !Speed [RPM]
  149. data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed
  150. data%State%TDS%RPMUnityOutput = -data%State%TDS%RpmGaugeOutput
  151. data%State%TDS%SoundRPM = 0
  152. data%State%TDS%Torque = 0.d0 ![ft.lbf]
  153. data%State%TDS%TorqueGaugeOutput = 2000.d0
  154. data%State%TDS%OldPowerMode = 1
  155. else if ( Get_TdsConnectionModes()==Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING ) then
  156. data%State%TDS%Speed = 0.d0 !Speed [RPM]
  157. data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed
  158. data%State%TDS%RPMUnityOutput = -data%State%TDS%RpmGaugeOutput
  159. data%State%TDS%SoundRPM = 0
  160. data%State%TDS%Torque = 0.d0 ![ft.lbf]
  161. data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  162. data%State%TDS%OldPowerMode = 1
  163. else if ( Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then
  164. data%State%TDS%Speed = 0.d0 !Speed [RPM]
  165. data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed
  166. data%State%TDS%RPMUnityOutput = data%State%TDS%RpmGaugeOutput
  167. data%State%TDS%SoundRPM = 0
  168. data%State%TDS%Torque = 0.d0 ![ft.lbf]
  169. data%State%TDS%TorqueGaugeOutput = 1000.d0 ![ft.lbf]
  170. data%State%TDS%OldPowerMode = -1
  171. end if
  172. end if
  173. else if ( data%State%TDS%DrillTorqueState==-1 ) then ! TdsMu_DRILL
  174. if ( Get_TdsConnectionModes()==TDS_CONNECTION_STRING ) then
  175. data%State%TDS%OperationFaultLed = 0
  176. data%State%TDS%Speed = data%State%TDS%N_ref/data%State%TDS%Conv_Ratio !Speed [RPM]
  177. data%State%TDS%Speed = min(data%State%TDS%Speed,data%State%TDS%MaxRPM)
  178. data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed
  179. data%State%TDS%RPMUnityOutput = -data%State%TDS%RpmGaugeOutput
  180. data%State%TDS%SoundRPM = INT(data%State%TDS%Speed)
  181. data%State%TDS%Torque = ( ((data%State%TDS%J_coef+data%State%TDS%String_JCoef)*(((((pi*data%State%TDS%N_ref)/30.d0)/data%State%TDS%Conv_Ratio)-data%State%TDS%TDS_wOld)/data%State%TDS%time_step))+(data%State%TDS%String_Torque) )*0.73756215d0 ![N.m]*0.73756215 = [ft.lbf]
  182. data%State%TDS%Torque = min(data%State%TDS%Torque,data%State%TDS%MaxTorque) ! [ft.lbf]
  183. data%State%TDS%TorqueGaugeOutput = data%State%TDS%Torque
  184. data%State%TDS%OldPowerMode = 1
  185. else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING ) then
  186. data%State%TDS%OperationFaultLed = 0
  187. data%State%TDS%Speed = 0.0d0
  188. data%State%TDS%RpmGaugeOutput = data%State%TDS%N_ref/data%State%TDS%Conv_Ratio !Speed [RPM]
  189. data%State%TDS%RPMUnityOutput = -data%State%TDS%RpmGaugeOutput
  190. data%State%TDS%SoundRPM = INT(data%State%TDS%N_ref/data%State%TDS%Conv_Ratio)
  191. data%State%TDS%Torque = 0.0d0
  192. data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  193. data%State%TDS%OldPowerMode = 1
  194. else if ( Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then
  195. if ( data%State%TDS%RpmKnob>0. ) then
  196. data%State%TDS%OperationFaultLed = 1
  197. data%State%TDS%Speed = 0.d0 !Speed [RPM]
  198. data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed
  199. data%State%TDS%RPMUnityOutput = -data%State%TDS%RpmGaugeOutput
  200. data%State%TDS%SoundRPM = 0
  201. data%State%TDS%Torque = 0.d0 ![ft.lbf]
  202. data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  203. data%State%TDS%OldPowerMode = 1
  204. else
  205. data%State%TDS%OperationFaultLed = 0
  206. data%State%TDS%Speed = 0.d0 !Speed [RPM]
  207. data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed
  208. data%State%TDS%RPMUnityOutput = -data%State%TDS%RpmGaugeOutput
  209. data%State%TDS%SoundRPM = 0
  210. data%State%TDS%Torque = 0.d0 ![ft.lbf]
  211. data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  212. data%State%TDS%OldPowerMode = 1
  213. end if
  214. end if
  215. else
  216. data%State%TDS%OperationFaultLed = 0
  217. data%State%TDS%Speed = 0.d0 !Speed [RPM]
  218. data%State%TDS%RpmGaugeOutput = data%State%TDS%Speed
  219. data%State%TDS%RPMUnityOutput = -data%State%TDS%RpmGaugeOutput
  220. data%State%TDS%SoundRPM = 0
  221. data%State%TDS%Torque = 0.d0 ![ft.lbf]
  222. data%State%TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  223. data%State%TDS%OldPowerMode = 1
  224. end if
  225. end if
  226. !******************************************************************
  227. END subroutine