Modbus input for absolute encoder position?

More
6 years 8 months ago #157762 by 0x2102

andypugh wrote: ...

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.


Hello,

wanted to provide a quick update and ask a question. I did exactly as suggested by Andy. All working but there is one remaining issue.

The sum2.M.in1 (encoder.N.position) or in my case (stepgen.00.position-fb) is "0" when I start LinuxCNC for the first time. Machine on triggers the sample hold. Then I jog the machine in X +50mm and set machine to off. When I turn it back on the position is off by 50mm.

The encoder.N.position or stegen.00.position-fb counters remains at 50.00000mm or whatever value it has and does not reset to 0 between machine off and on. Sum2.M adds the actual absolute encoder position + the encoder.N.position stored for the new absolute position.

Example:
Turn on machine: x-pos = 200mm + 0 = 200mm, jog X+ 50mm, turn off machine -> new x-pos = 250 + 50 = 300 but the real position is 250.

I might be able to add a mux2 or use an offset to subtract the encoder value but maybe someone has another idea. I already have to use quite a # of rt modules: offset, abs, conv_float_s32, sample_hold, conv_s32_float, 2 x sum2 to make it work and I am starting to see "Insufficient memory for pin.." warnings. :)

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

More
6 years 8 months ago #158413 by andypugh

0x2102 wrote: I might be able to add a mux2 or use an offset to subtract the encoder value but maybe someone has another idea. I already have to use quite a # of rt modules: offset, abs, conv_float_s32, sample_hold, conv_s32_float, 2 x sum2 to make it work and I am starting to see "Insufficient memory for pin.." warnings. :)


I am surprised that you are that close to the pin memory limit.

One answer might be a custom HAL component. If you can write C code at all then this fairly easy.
linuxcnc.org/docs/2.7/html/hal/comp.html

Or you could try just not turning off the machine :-)

Actually, it sounds like you need to trigger the sample-hold with something other than machine-on. Maybe a timedelay component?

Set up a timedelay for a few mS (as long as it takes to get the initial position read) and trigger that in the HAL file at load time.
(ie setp timedelay.0.in 1)

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

More
6 years 8 months ago #158420 by 0x2102
I will take your advise and never turn the machine off :)

I am at a point where I can't turn it back on due to following error warning in LinuxCNC. This is actually better than having the actual position all wrong.

I think in closed-loop setup I would be able to reset the encoder feedback to 0 before I turn the machine back on. I found a reset bit in the hostmot2 manual. I might give that a try later, when I have glass scales on the machine.

I could use the servo encoder feedback but when I set them up in closed-loop (with the servo's auto-tuning on) I have some strange behavior in LinuxCNC PID tuning. Might need to turn auto-tuning off.

Anyway, thanks for all your help so far. I will provide an update, if things change.
The following user(s) said Thank You: besriworld

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

More
3 years 6 months ago #268482 by besriworld
Hello, any progress here? I have servo motors with 24bit absolute encoder. I want to read the current starting position and axle load when the machine is moving .Again, communication is modbus. Can you share your config files . I am new to LinuxCNC. Thanks!

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

More
1 year 9 months ago #319352 by Ehsan_R
Has anyone been able to get the position of the servo motor via modbus and then do the homing operation?

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

More
1 year 8 months ago #320515 by Ehsan_R
I have a servo motor with an absolute encoder that can send and receive data via RS485 RTU. I was also able to receive the encoder data using mb2hal. The encoder data includes the pulse count and the number of turns. The pulse count changes between 0 and 65535 per turn. The number of turns counts up from zero for positive numbers and decreases by one from 65536 for negative numbers. Now, my question is, first, how can I convert this value in HAL to an angle and then to a length, and second, how can I use this value for homing?

 

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

Time to create page: 0.133 seconds
Powered by Kunena Forum