Comments on: I ran out of numbers. http://www.polargraph.co.uk/2013/05/i-ran-out-of-numbers/ drawing by robot Mon, 14 May 2018 00:33:14 +0000 hourly 1 https://wordpress.org/?v=4.9.7 By: MikeOnBike http://www.polargraph.co.uk/2013/05/i-ran-out-of-numbers/#comment-8689 Tue, 11 Jun 2013 19:27:20 +0000 http://www.polargraph.co.uk/?p=786#comment-8689 Since your initial calculation of pageWidth is static you could also calculate a float variation at the same time and use that in getCartesianXFP() and save the overhead of casting every time the function is called.

long pageWidth = machineWidth * stepsPerMM;
float pageWidth_fp = (float)pageWidth;

float getCartesianXFP(float aPos, float bPos) {
float calcX = (sq(pageWidth_fp – sq(bPos) + sq(aPos))
/ (pageWidth_fp * 2.0);
return calcX;
}

You could also pick up some more performance by eliminating the (pageWidth_fp * 2.0) calculation since it is always the same value by assigning it to a static variable inside the function.

float getCartesianXFP(float aPos, float bPos) {
static float twoTimesPageWidth = pageWidth_fp * 2.0;
float calcX = (sq(pageWidth_fp – sq(bPos) + sq(aPos))
/ twoTimesPageWidth;
return calcX;
}

]]>
By: sandy http://www.polargraph.co.uk/2013/05/i-ran-out-of-numbers/#comment-8110 Sun, 12 May 2013 13:03:42 +0000 http://www.polargraph.co.uk/?p=786#comment-8110 Aha! Yes, I suppose I only came across the issue because the polargraphSD uses 8x microstepping so 3200 steps per rev. If I’d gone for full 16x stepping (which the polarshield is happy to do), or used the geared steppers then it would have shown up even earlier I guess. It’s really a symptom of an informal education in C and Arduino.

]]>
By: Wingman http://www.polargraph.co.uk/2013/05/i-ran-out-of-numbers/#comment-8108 Sun, 12 May 2013 10:02:19 +0000 http://www.polargraph.co.uk/?p=786#comment-8108 Actually I had this problem when I was using cheap geared motors. Because of the gears there where 64*64=4096 steps per revolution. It worked for single steps but microstepping was impossible. I already tried to search for the variables that were causing that error but without success.
Its great to hear that you fixed this!

]]>