7/13/2012 9:52 AM | |
Joined: 1/28/2009 Last visit: 12/12/2024 Posts: 6858 Rating: (1365)
|
Dear friends , This is an expansion to discussion previously made here: Laplace equations in Step7Simply this will provide all data and documents required for solving ODEs with SCL.Hopefully, first reading the document may help to refresh the Euler method. Best regards, Hamid Hosseini AttachmentODE.pdf (1670 Downloads) |
Last edited by: hdhosseini at: 6/28/2013 8:09 AM |
|
This contribution was helpful to6 thankful Users |
7/13/2012 10:31 AM | |
Joined: 1/28/2009 Last visit: 12/12/2024 Posts: 6858 Rating: (1365)
|
3- Second order differential equations [code] FUNCTION_BLOCK FB3 //Y 1 //--=------------------------ //F A*S^2 + B*S +C VAR_INPUT // Input Parameters F:REAL; A:REAL:=1.0; B:REAL:=1.0; C:REAL:=1.0; INTERVAL:TIME:=T#1S; END_VAR VAR_IN_OUT REST:BOOL:=FALSE; END_VAR VAR_OUTPUT // Output Parameters Y:REAL; END_VAR VAR_TEMP // Temporary Variables END_VAR VAR // Static Variables // FNEW:REAL:=0.0; X1:REAL:=0.0; X2:REAL:=0.0; X1OLD:REAL:=0.0; X2OLD:REAL:=0.0; DELTA1:REAL:=0.0; DELTA2:REAL:=0.0; T_INTERNAL:REAL:=1.0; END_VAR // Instruction Section T_INTERNAL := (DINT_TO_REAL(TIME_TO_DINT (INTERVAL)))/1000.0; IF REST=1 THEN X1:=0.0; X2:=0.0; X1OLD:=0.0; X2OLD:=0.0; //REST:=0; Y:=0; ELSE DELTA2 :=(F- (C*X1OLD) - (B*X2OLD))/A; X2:= X2OLD + (DELTA2 * T_INTERNAL); DELTA1 :=X2; X1 := X1OLD + (DELTA1 * T_INTERNAL); X2OLD:= X2; X1OLD:=X1; Y:=X1; ; END_IF; ; END_FUNCTION_BLOCK [/code] AttachmentE3.zip (948 Downloads) |
This contribution was helpful to1 thankful Users |
Follow us on