I'am trying to make a deaccleration ramp for a project.
I calculate that formula X/Y^0.3 is the speed curve I would try to use, but how can I calcualt with ^0.3 in Arduino?
I'am trying to make a deaccleration ramp for a project.
I calculate that formula X/Y^0.3 is the speed curve I would try to use, but how can I calcualt with ^0.3 in Arduino?
In C/C++ you use the pow() function for exponentiation.
...R
z = x / pow(y, 0.3);
or do you need cubic root == pow(y, 1.0/3.0); ?
then you could use cbrt();
double z = x / cbrt(y);
simple performance test ( UNO, IDE 1.5.8 )
cbrt(y) => 176 uSec
pow(y, 1.0/3.0) => 312uSec
so cbrt(y) is ~1.7x faster
0.3 wouldn't be the cube root. That would be 1/3 = 0.333333....
Use X/pow(y, 0.3) to get what you stated to be your correct formula.
Thanks guys...
I´ll need to use: double z = pow((y/x), 0.3) to get my speedrefernce.
If i starts with for example y and x = 500. Lower y every pulse until I reach y=0 and I got a value to multiply with my speedchannel. I always got a number between 0 and 1. If I would move my deaccelrationramp for a longer time I only need to change 500 to 1000 and I still get value between 0 and 1. Ust mupliply my speedchannel with z.
If I add ^0.3 I got a curve that have a large drop in the end because of my motor, it´s to small torch in the end so I need to cut speed fast in the end of motion.
One calculation and I only need to set a pulsevalue where to start deaccelarate my motor and my fomula take cares of the rest.
My big puzzle is, however, if it takes too much effort to figure this out each loop step so that the encoder track of all pulses. I use a MEGA 2560 and use timer2 to take care of my encoderpulses into Arduino. Sometime it count all the pulse in a very strange way.