CL s32in floating points (RPM) input for MODBUS

More
22 Dec 2016 04:06 - 22 Dec 2016 20:00 #84538 by Charlieslasher
Just beginning switch to linuxcnc for my lathe. Started on classicladder to modbus i have Spindle enable, spin direction all working ok but having trouble with getting Spindle RPM to pass into CL.

I think i have assigned it correctly in custom.hal to SpinRPM with s32in but i dont understand how to get the Variable in CL then pass it through with no operations

I think i should be using Compare and operate. But i haven't found any examples to work through

currently i have [%IW4=%W4]
>(Q4)

Can i use %IWx for the floating point data from Spindle rpm motion.spindle-revs-abs

thanks
Last edit: 22 Dec 2016 20:00 by Charlieslasher.

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

More
22 Dec 2016 18:31 #84565 by Todd Zuercher
Replied by Todd Zuercher on topic CL s32in
One thing to remember Classicladder doesn't really do floats (at least not internally). While it has float in and out pins, the numbers are lopped off at the decimal point and treated as s32 internally. For example the number 2.7568 shows up as 2 inside CL.

While you can connect %IWx directly to the register output, it is generally more convenient to use %Wx because you have to choose either W, QW, or IW for all register writes (selected on the Modbus Communication Setup tab of the CL config window). Just use an assignment to set your %Wx you choose equal to the CL input (for motion.spindle-revs-abs it would be a %IFx) Remember that float will be changed to an s32 within CL, so if there are significant decimal point numbers you need to keep you will have to multiply the float by a factor of 10 to keep them and get them into CL.

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

More
22 Dec 2016 19:59 #84570 by Charlieslasher
Ok i was getting float errors trying to connect
Spinrpm classicladder.0.32in-4 <= motion.spindle-rev-abs
I found a classicladder.0.floatpin input (?) which didnt give an error but not sure if its working i cant see any rpm numbers in CL when testing but it dosnt error. Assignment [%IFx=QFx]

I also have problems connecting motion.spindle-rev-abs => Spinrpm classicladder.0.32in-4 if i dont delete the spindle.cmd.rev.abs <= connecting motion.spindle-rev-abs connection. i thought i could connect multiple hall pins to the source motion.spindle-rev-abs

IS it possible to change/convert from %IFx -> %Wx once in classic ladder for modbus to use or can modbus use floating numbers %Qfx
i will try your get floating point numbers into CL as S32. Can i do maths on the floating point outside of classic ladder before it goes in? (i have not done any hal work yet apart from pins)

thanks for the info Todd.

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

More
22 Dec 2016 21:39 #84576 by Todd Zuercher
The CL float input pins should be named
classiclader.0.floatin-xx

You can connect multiple "hal in pins" to a hal signal, but only one "hal out pin". The hal pins motion.spindle-rev-abs and motion.spindle-speed-cmd-rps are both output pins.
(I don't know what spindle.cmd.rev.abs is. Or is that your signal name?)
Also, any hal pin can only be connected to one signal. maybe that is where you were messing up?

Yes you can connect a %IFn to a %Wn in CL using the Assignment function (bottom right icon on CL editor window)
linuxcnc.org/docs/2.6/html/ladder/classi..._variable_assignment

You can do some maths in hal before sending to CL. (or after pulling them back out)
You don't need to bother with converting floats to s32 before inputting them, they will be converted automatically (whether or not you want them to be.)

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

More
23 Dec 2016 08:50 #84600 by Charlieslasher
I get error when trying to connect %IFn to %Wn because %IFn is floating i think (not integer was the warning)
I can get Floating rpm data via classicladder.0.flatin-x into CL and pass it to floating output %QFn
but cant get Floating RPM data into classicladder.0.32in-x it gives floating error in error log.
Are there any examples of Floating in integer out CL. OR RPM in ClassicLadder.

I think next i will try convert it to non floating before CL with HaL.

Any more ideas i am listening

thanks

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

More
23 Dec 2016 09:24 #84601 by cmorley
to pass a float (in) to a s32 (out) pin, use an evaluation

%QW0=%IF0
or if you want to use an internal memory s32 change it to
%W0=%IF0

As noted floats are clipped in classicladder (maybe i should have made it round them?)
If the the decimals are important one trick is to multiply the float by 1000 using HAL components before going in classicladder.

1.234 ----multiply by 1000=1234----send to CL

Chris M

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

More
23 Dec 2016 11:56 - 23 Dec 2016 12:27 #84606 by Charlieslasher
OK thanks this was key ...Assignment [ %W0=%IF0 ] to work and all my ladder logic seems to do what is should values look ok.

Now modbus problems.... this is for HITACHI NF2U 2.2KW

VFD Address
1 write coils Spindle on [ENABLE] address/registers 0,1
2 write coil Spindle FWD/Reverse address/register 0,2
1 Write register SpinRPM address/register 1,1

Classic ladder outputs for modbus to use
%Q2=ENABLE coil
%Q3=FWD coil
%Q4=REVERSE coil (probably not needed with foward 0/1 )
%W3=SPINRPM

Slave address | TypeAccess |1st modbus ELE| # of ELE | logic | 1st Maped|
1 writecoils 5 0 2 2 #ENABLE + FWD
1 writeregister 6 1 1 3 #RPM

My vfd connects disconnects with start stop of CL but i get modbus error pop up ever few seconds and no out puts work.
Just checking if i have the modbus I/0 register done correct.

Edit----
OK got some spindle on and rpm working. I had RPM starting at %W3 when it was %W4 that had the rpm data. I still get modbus error popup. Will keep working and test some more. There is some delay in spindle response i will try put the wait timers at 0ms currently 25ms. this is for a lathe so i was hoping for fast spindle response.
Last edit: 23 Dec 2016 12:27 by Charlieslasher. Reason: IT works (sort of)

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

Time to create page: 0.118 seconds
Powered by Kunena Forum