Classicladder, Modbus and read values of a servo motor

More
30 Jan 2019 20:02 #125327 by MATZE-ATZE-SCH
Hello.

I want to read out a servo controller to display the load of the axis in Linuxcnc.
The Controller is connected via Modbus in CL and the connection works.
So i read out the adress 1546. The Servo will output a value between -100 - +100 in HEX.
So the Values from 0-100 are working fine, but if the controller puts anything out with a -,
then i get in the CL values in the range of 65535.
How can I set it up, that the value is always positiv?

Best regards
Marcel

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

More
30 Jan 2019 20:22 #125330 by Grotius
HEX <-> BINARY <-> SIGN
0-7 <-> 0000-0111 <-> pos
8-F <-> 1000-1111 <-> neg

Negative value's cannot be shown positive, unless you add a formula *-1

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

More
30 Jan 2019 21:08 #125342 by MATZE-ATZE-SCH
Hello,

HEX <-> BINARY <-> SIGN
0-7 <-> 0000-0111 <-> pos
8-F <-> 1000-1111 <-> neg

What do you mean with this?

If i define the value to be absolute, then it would be only positiv, right?
With a formula *-1, then my positiv values would become negativ?

Best regards
Marcel

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

More
06 Feb 2019 22:40 #125887 by MATZE-ATZE-SCH
OK,
i´ve got it to work:

I first compare the input value from %Q0, if the input value is <2000, then i output the value on %QW1.
So I have the Imput from 0-100 on %Q0 -> 0-100 on %QW1.

With a nother comparisson I check if the value from %Q0 is > 2001.
If this is true, a use a assignment: %QW1=65535-%Q0.
So when the servo puts out -10, on %Q0 I have a value of 65525.
And 65535-35525=10, so I have on %QW1=10.

Now I have tried to run classicladder without the gui,
so I have written in the .hal:
loadusr classicladder --modbus --nogui myladder.clp .
But the CL doesn´t load, it only loads without the --nogui in the .hal...
What have I wrong?

Best regards

Marcel

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

More
07 Feb 2019 00:42 #125898 by cmorley
Modbus requires the gui to run.
Use the HAL pin hidegui (something like that) to hide the gui

Also I am pretty sure CL has an absolute command:
linuxcnc.org/docs/devel/html/ladder/clas...ladder.html#_compare
Might do what you want.

Chris M

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

More
07 Feb 2019 08:56 #125911 by MATZE-ATZE-SCH
Ok,i will later look at this.

With ABS I had no sucess. But I think it is a error of the servo, who send wrong numbers. Have read out the servo with another modbus programm, it also shows , that for example the servo should output -10, I get a value of 5525 on modbus.

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

More
07 Feb 2019 17:13 #125933 by Mike_Eitel
Are the two bytes inverted?
Means high and low bytes inverted?

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

More
07 Feb 2019 18:52 #125940 by MATZE-ATZE-SCH
Hello,

two bytes inverted?
The Servo response from high to low, if this is what you mean?

Best regards
Marcel

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

More
07 Feb 2019 19:43 #125947 by rodw

Hello,

two bytes inverted?
The Servo response from high to low, if this is what you mean?

Best regards
Marcel


I think Mike means the hardware could store numbers in a high byte,low byte order when the PC is low byte, high byte order.

If that is the case in hexadecimal numbers for decimal 10 (forget the sign for now)
low byte 000A 0000 becomes high byte 0000 000A which is several magnitudes of order larger!

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

More
08 Feb 2019 17:04 #126011 by MATZE-ATZE-SCH
OK,

but I don think that is the error.
If this will be the case, the values would only be offset, right?

But if I look at the Servo drive,
if there is -1, the value in Modbus is 65536,
if there is -10, the value in Modbus is 65526 etc.
So it is going only in the wrong direction.

In the manual of the servo it is high bit low bit.
But what a order expect Classicladder?

Best regards
Marcel

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

Time to create page: 0.103 seconds
Powered by Kunena Forum