Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Imaginary number in CoDeSys

davre-1
2007-03-26
2007-03-29
  • davre-1 - 2007-03-26

    Does anybody know how to use imaginary number in CoDeSys?

    thanks for your help

     
  • ndzied1 - 2007-03-29

    Like any computer system, imaginary numbers will have to be handled as either a structure or array where each "number" has two sub-elements; the real part and the imaginary part.

    You will then have to define your own functions for all of the operations you wish to perform on the imaginary numbers. In FORTRAN these are sometimes also called Complex Numbers so that you could write functions such as

    CADD for adding

    CSUB for subrraction

    CMUL for multiplication

    etc....

    At some level of complexity you will have to weigh the option of writing the impginary part of your program in a higher level language such as C++ where you can find ready made libraries for dealing with imaginary numbers.

    I believe there are ways to link your own programs into CoDeSys but I have never done it myself. Others will have to comment on this.

    Good Luck

     

Log in to post a comment.