Machsupport Forum
Mach Discussion => Brains Development => Topic started by: CNC_Guitar 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
-
Consistent with unsigned integer? If at zero and decremented it rolls back to 65535
-
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
-
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
-
Hi,
Thanks for sharing the details of the project! Mach3 does not directly receive absolute position from MPG.
It reads the relative change between pulses in short time.
You should not rely on Mach3 to handle rollover because Mach3 is usually not designed to understand low-level pulse overflow logic without a specific MPG-enabled controller card.