Welcome! Log In Create A New Profile

Advanced

Teacup firmware M114 position reporting

Posted by BenJackson 
Teacup firmware M114 position reporting
April 04, 2011 07:05PM
I've made a lot of fixed to ReplicatorG for FiveD-style firmwares (see [groups.google.com] ) and one of the things I did was implement reconcilePosition via M114 which works for FiveD. Other firmware does not work for various reasons: it's not implemented in Tonokip descendents, and Teacup outputs a different string format and in units of steps rather than mm.

I am willing to extend my M114 support to Teacup as it is currently written. The machines/reprap.xml includes the information needed about the steps_per_mm (assuming you set it) so mm position can be recovered from steps. The Teacup string format is distinctive but it could also be an explicit config option.

The other option would be to change Teacup to output a string compatible with FiveD: in the format shown below, and with units scaled to mm.

case 114:
Serial.print("C: X");
Serial.print(where_i_am.x);
Serial.print(" Y");
Serial.print(where_i_am.y);
Serial.print(" Z");
Serial.print(where_i_am.z);
Serial.print(" E");
Serial.println(where_i_am.e);
break;

Note leading C: and no : on XYZE.

Any opinions?

--Ben
Re: Teacup firmware M114 position reporting
April 04, 2011 11:37PM
yeah we can change the format of M114 without issue, however the unit conversion may be trickier :-
Currently, teacup has no good way to print non-integer values to the host. You might notice the temperatures, but these are kludged, as in
printf("%d.%d", temp >> 2, (temp & 3) * 25)
Adding floating point libraries would solve this handily, but also pushes up the size by a fair bit which seems excessive for a single output conversion.

I suppose we could try to reconstruct the floating point value with something like
p = pos;
q = steps_per_mm;
printf("%d.", p / q);
p -= p / q;
q /= 10;
do {
  if (q == 0)
    q = 1;
  printf("%d", p / q);
  p -= p / q;
  q /= 10;
} while p;

or maybe we could get the host to understand Xp/q Yp/q format so we can send raw values and appropriate divisor without having to do the math on our micro?

If you have any suggestions on how to best handle this, I'm very interested smiling smiley


-----------------------------------------------
Wooden Mendel
Teacup Firmware
Re: Teacup firmware M114 position reporting
April 05, 2011 04:15PM
Sending the divisor in the response (or in a separate response done once at startup) is interesting because it avoids mismatches between the machines.xml and the firmware (which could be just as disasterous as not knowing the current position).

Still, it would be nice to just output position. Looks like you're already doing things internally at 1000 scale. Why not just compute p*1000/q, format as integer (with a format like %04d to ensure at least 4 zeros) and manually insert the decimal?

(actually it looks like you made your own printf already, so make a new format that takes 1000x decimals and prints as "float")
Sorry, only registered users may post in this forum.

Click here to login