Modbus input for absolute encoder position?

More
6 years 10 months ago #152049 by Henk
I agree, this will be very useful.

Henk

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

More
6 years 10 months ago #152057 by andypugh
So, do you know the register numbers that contain the data? (and thus the modbus transaction data)

You should, I think, be able to connect all the drives to one serial port, including the one on the 7i76e.

I think it might be relatively easy to write a .comp that loads like:
[/code]loadrt mesa_modbus uart="hm2_7i76.0.uart.0" addr="151,151,152", regs="55,65"[/code]

It might be better to have something like the format used for absolute encoders :
ssi_chan_0=error%1bposition%24g
Possibly using all the same code, in fact.

This is one existing implementation of a driver for the Mesa UART:
github.com/LinuxCNC/linuxcnc/blob/master...ivers/mesa_uart.comp

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

More
6 years 10 months ago #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
6 years 10 months ago #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
6 years 10 months ago - 6 years 10 months ago #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: 6 years 10 months ago by 0x2102.

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

More
6 years 10 months ago #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.

Time to create page: 0.066 seconds
Powered by Kunena Forum