Whow,
Thanks for all suggestions sofar from all of you.
Duane is 50% right. The word exponential is to be found in many rc controllers fr many years to control the power output as shown in the graph.
But in this case it is not for the RC world but for the slotcar world.
For the user for now it is not needed to know how the exp curve runs exactly.
Slot racers are people who are working a lot with the feel of the interaction of the car in the slot and things they do with the trigger.
They are not so interested by the real figures they dial in.
However my slotrace controller project is in the end to show all figures and values they use on PC or Android Mobilephone or tablet by BT.
Although the word negative is used I know the Arduino cant do anything with negative values.
We do not want to output negative values but we want curves that are expected to be different then the linear striagth line when they are following the value of the trigger.
For extra info.
We take the value from a contactless linear hall sensor and map that to 0 to 255
What is mend with negative is the way the curve behaves compared to the linear straigth line.
So if the curve goes below the linear straight line it is a negative curve value.
Here some code:
// control the outputs with output cross block function to prevent speed and brake to be ON together
sensorValue = analogRead(sensorspeedPin); // read the raw value from the linear hall sensor:
sensorValue = map(sensorValue, sensorMin, sensorMax, 0, 255);// apply the calibration to the sensor reading
if (sensorValue > 250) {sensorValue = 255;} // to make sure full 100% PWM value is reached even if sensor value is not 100%
speedValue = map(sensorValue, deathbandValue, 255, 0, 255);
speedvalueWorked = map(speedValue, sensorMin, sensorMax, speedstartValue, 255); // added startspeed value
>>>>>>>> speedcurveValue = speedvalueWorked with the quotation to calculate the exponential power curve // added speedcurve value
speedfinalValue = speedcurvevalue
if (sensorValue > deathbandValue) {analogWrite(pwmoutspeedPin, speedfinalValue); analogWrite(pwmoutbrakePin, 0);} // startspeed and curve included
else
{analogWrite(pwmoutspeedPin, 0); analogWrite(pwmoutbrakePin, brakeValue); digitalWrite(ledPin, HIGH);}
The triggerhandle use a deathband around the 0 point to be sure the mechanical tolerances are taken out.
As long as the sensorvalue is inside the deathband value the breaks are ON. Deathband variable in byte length is adjustable from 0 to 15.
As soon as the sensorvalue is outside the deathband zone the PWM output is activated.
You can add startspeed so the motor does not start at 0 but at a higher value depending on the motor charactristics.
If the speed curve is linear the motor will follow that straight line from lets say startspeed 45 to 255.
When the speed curve is an other value this straight line must be curved.
I hope this clears up more (if not let me know) and other can benefit from it in other projects.
will work on it and let you know th results.
Other tips and tricks are always welcome.
Paco