Hello Guest it is April 29, 2025, 11:04:17 PM

Author Topic: Using MPG and Modbus gives strange behaviour  (Read 1942 times)

0 Members and 1 Guest are viewing this topic.

Using MPG and Modbus gives strange behaviour
« on: February 16, 2025, 05:26:42 AM »
Hi there,
I made a wireless control unit based on arduino/ESP32 and using Modbus TCP.
Everything works great except the MPG. The pulse counts range from 0 - 65535 (16 bits unsigned integer).
When the pulses are received by a brain and rolls over (from 0 to -1) the actual value goes from 0 to 65535 and the axis keeps moving.
When passing the soft limits the axis does not stop.

Can somebody explain how the mpg counting works in Mach3 and in particular handling the transition form a positive to a negative pulse count?
I have seen multiple threads with likely the same problem but no real solution.

kind regards

D
Re: Using MPG and Modbus gives strange behaviour
« Reply #1 on: February 16, 2025, 06:57:31 AM »
Consistent with unsigned integer? If at zero and decremented it rolls back to 65535
Re: Using MPG and Modbus gives strange behaviour
« Reply #2 on: February 16, 2025, 09:57:10 AM »
Thanks for your Reply John,

yes, that is consistent. A the value of a signed integer is in the range of -32758 and +32758
I tried this by sending the sign in a separate  register. However, still the axis move when go from a positive value to a negative value.
If a positive to negative transition occurs, will the axis still jog in the same way or will it move in the opposite direction?
Why does the axis moves beyond the soft limits?

These questions are bugging me
Re: Using MPG and Modbus gives strange behaviour
« Reply #3 on: April 10, 2025, 10:40:21 AM »
Hi
i had same problem a few months ago re +/- integer see my post back end of last year,  this was my final result.

after reading as many posts have finally found out what I was doing wrong. I was writing my MPG value into DRO 101-MPG 0 count. I now put it into Mach variable MPG 1 count, everything is working fine now
thanks for looking