robertobucher / pysimCoder

Block diagram editor and real time code generator for Python
GNU General Public License v3.0
142 stars 31 forks source link

MININUM, MAXIMUM blocks: add blocks taking min (or max) from all inputs #82

Closed zdebanos closed 4 months ago

zdebanos commented 4 months ago

The output is only one, outputting the minimum (or maximum).

I've put these blocks under the math library.

robertobucher commented 4 months ago

Hi Stepan Just a little problem: you put the C-code into the STUPD part of the program. STUPD (state update) is used to update the internal states of the block and it is only called if you have states in your block. This means that the STUPD part performs this equation:

x' = Ax+Bu

Usually your part of code should be inserted in the "OUT" part of the code .

Just a little theory remembering: Each block is described by the 2 equations

x' = Ax + Bu y = Cx + Du

in continuous time. and

x[k+1] = Ax[k]+Bu[k] y[k] = Cx[k]+Du[k]

in discrete time. In both cases the first equation updates the internal states of the block and should be called as SECOND function, and the second equation uses the internal states and the inputs to actualize the outputs.

zdebanos commented 4 months ago

Got it, thank you! I deleted the STUPD flag from the functions.

robertobucher commented 4 months ago

Sorry for my (probably pedantic) explications, but as retired professor I profit from every possibility to continue transmit my old experience! Thanks for the update.