# Workaround for using floats in CL

18 Apr 2010 17:30 #2623
by cmorley

*Workaround for using floats in CL*was created by

*cmorley*

Classicladder can connect to float pins but internally converts them to S32, chopping off anything past the decimal.

One way around this is multiplying the float by 100, 1000 etc then sending to CL and if CL sends out a float divide it by the same.

Some VFD motor drives do this.

sample code :

here is the general idea to multiply a signal going to CL :

# load the component count equals how many you want

loadrt mult2 count=1

# add component to a thread (pick a valid threadname)

addf mult2.0 thread1

# input_signal

net input_signal mult2.0.in0

# constant of 100 to multiply by

setp mult2.0.in1 100

# connect it to classicladder. CL will demote float to S32 internally

net mult2.0.out classicladder.0.floatin-00

one thing to remember is not to multiply the float so much as it will be higher then the highest possible s32 value.

One way around this is multiplying the float by 100, 1000 etc then sending to CL and if CL sends out a float divide it by the same.

Some VFD motor drives do this.

sample code :

here is the general idea to multiply a signal going to CL :

# load the component count equals how many you want

loadrt mult2 count=1

# add component to a thread (pick a valid threadname)

addf mult2.0 thread1

# input_signal

net input_signal mult2.0.in0

# constant of 100 to multiply by

setp mult2.0.in1 100

# connect it to classicladder. CL will demote float to S32 internally

net mult2.0.out classicladder.0.floatin-00

one thing to remember is not to multiply the float so much as it will be higher then the highest possible s32 value.

Please Log in or Create an account to join the conversation.

Time to create page: 0.060 seconds