Modbus input for absolute encoder position?

More
06 Dec 2019 01:14 #152122 by 0x2102
I did some further testing today and noticed a potential problem with the MobBus interface on the drives.

It seems like the servo driver can't handle high frequency ModBus updates when the servo drive is on. When off I can read the required registers at high speed (not sure what the update rate is but without a limit set in MB2HAL).

When the servo is on, I am getting checksum errors when I try to read with > 1Hz (1 sample per second) and MB2HAL will stop reading data.

I might just look into reading the ModBus register when I press machine-on for 1 second or so and update LinuxCNC. Is there PIN to update the coordinate system?

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

More
06 Dec 2019 01:21 #152124 by tommylight
That looks like interference from the drives. Are you using shielded cable for modbus ? It has to be twisted pair shielded cable.

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

More
06 Dec 2019 09:15 - 06 Dec 2019 09:17 #152133 by 0x2102
I am using a shielded CAT7 ethernet cable with a simple USB to RS485 converter. Not sure if the USB adapter is the problem or not.

In general I feel like ModBus is not meant to drive a real time PID. I would only need it when I turn on the machine.

I was thinking to use the absolute position data only for a brief period of time to update the coordinate system when I power on / enable the machine. After that the incremental encoder should take over like it does today.

An alternative could be to create a LinuxCNC startup script that updates the "position.txt" from absolute encoder data before it starts LinuxCNC.

I already have a HAL connection example that calculates absolute data into actual position data but I don't know which PIN I need to connect it to to update the coordinate system.

Maybe I way off track here. Thoughts?
Last edit: 06 Dec 2019 09:17 by 0x2102.

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

More
06 Dec 2019 10:08 #152137 by andypugh
For the moment, taking a snapshot of the position at startup and then using incremental is probably a good starting point.

It's really easy, in principle. The only thing that isn't obvious is how to get the data and then store it and stop updating once you have it.

Sample-hold can be used to store the initial position:
linuxcnc.org/docs/2.8/html/man/man9/sample_hold.9.html

The trigger bit could be something read from the drive that is guaranteed to always be true after the first read. Unless mb2hal has pins that (for example) count valid reads?

So,

full-turns -> convert to float
initial counts -> convert to float
turns and counts -> sum2, turns scaled by 65536

sum2.N.out -> sample-hold.0.in

(Magic here to latch the sample-hold)

sample-hold.0.out -> sum2.M.in0 (gain 1)
encoder.N.position -> sum2.M.in1 (gain 1)
sum2.M.out -> PID feedback, axis position feedback, etc.

Then specify HOME_ABSOLUTE_ENCODER in the INI.

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

More
06 Dec 2019 10:13 #152138 by Mike_Eitel
My 5 cents.
Modbus RTU 9600 Baud:
ca 1000 Hex signs per second.
Normal shortes telegram f.x 03 needs at least 8 digits for request plus 7 for answer plus waits. Say 20 hex digits a ca 1ms = 50 one word answers at 9600.
Yes you can use higher serial speeds.....
But don't forget Linux semaphore handling, vfd small processor, if rs485 hw direction switching....
...
Mike

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

More
06 Dec 2019 10:18 #152140 by 0x2102
Thanks Andy. Food for thought. I will play with it this weekend.

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

More
06 Dec 2019 10:21 #152141 by andypugh
I just realised. I changed my mind half-way through.

sample-hold takes S32 data, so you need to latch while the data is still in that form. So you can use two of them, latch the register reads, then pass the output of both to the type conversion. Both can be latched by the same input signal.

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

More
10 Dec 2019 16:46 #152442 by 0x2102
I didn't made much progress on this, as MB2HAL just randomly stops working for me. I open LinuxCNC, PIN are created and updating and then it just stops a few minutes after.

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

More
13 Dec 2019 08:43 #152594 by 0x2102
Made some progress. Still need to set this up and test but I think I figured out why MB2HAL randomly stops working for me. Long story short, I upgraded libmodbus from 3.0.6-2 to the latest release 3.1.6 - which was the reason.

I upgraded libmodbus to see if that would solve another issue I am having with MB2HAL. I am trying to read my servo motor load and while tools like modpoll report the correct values e.g 200 / -200 depending on motor load and direction, MB2HAL pins show only positive number 200 / 65336 (65536 - 200).

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

More
13 Dec 2019 14:22 #152603 by andypugh
Are the HAL pins set as signed?

Can you adjust the range?

65536 is a very recognizable but unexpected number for 16bit data.

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

Time to create page: 0.097 seconds
Powered by Kunena Forum