Techylah,
So no error codes anymore.
I ran some test but all are different then desired.
I reduced some lines to get the basic without any switchpointValue and only used the lookupTable line.
speedstartValue is set at 1
gammaSValue is set at 1.0
speedfinalValue however in this case is always starting at 171 regardless all other settings.
Also ispeedfinalValue runs through and passing the 255 value going to 0 at the end of full trigger.
Current code for the output.
void setup()
for (int i=0; i<256; i++)
lookupTable[i] = (int) (0.5 - speedfinalValue + pow((255 - i)/127.0, gammaSValue) * ((speedfinalValue - speedstartValue) / 2.0));
void loop()
// +++++++++++++++ regular speed - brake mode +++++++++++++++
// in regular mode 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 from the hall sensor
sensormappedValue = constrain (sensorValue,0,255); // keep value in range
// ++++ curve section +++++++
//if (sensormappedValue < (switchpointValue - speedstartValue)) // switchpoint for test set at 120
//speedValue = map(sensormappedValue, 0, 255, speedstartValue, 255);
//else
//speedValue = 0;
speedValue = lookupTable[sensormappedValue];
// ++++ curve section +++++++
speedfinalValue = constrain (speedfinalValue, 0, 255);
speedfinalValue = speedValue;
if (sensormappedValue > deathbandValue)
{
analogWrite(pwmoutspeedPin, speedfinalValue);
analogWrite(pwmoutbrakePin, 0);
digitalWrite(ledDBPin, LOW);
digitalWrite(ledBPPin, HIGH);
}
else
{
analogWrite(pwmoutspeedPin, 0);
(speedfinalValue, 0);
analogWrite(pwmoutbrakePin, brakeNValue);
digitalWrite (ledDBPin,HIGH);
digitalWrite(ledBPPin, LOW);
}
Paco