Go Down

Topic: From linear to exponential PWM output (Read 19 times) previous topic - next topic

backbone

Hi Mitch and others,

OK after a long radio silence I report back again.
Worked on the code to get the menu navigation by analog port and 10 switches.
Finally I got it to work.
Happy with it I checked the working of the controller then found out some other code was not working.
Had to sort that out too. To much time taken sofar but learned a lot again.
Have to check this week if the look up table and the connection (by bluetooth) is working with the PC.
Then the guys have to do some more testing t the track.

Keep you informed about the progress.

Paco
Never to old to learn and I learn every day

Techylah


backbone

Hum,

Still debugging code (nemu navigation still working fine :-) )
While moving the speed trigger I suddenly see the deaband led coming ON and OFF even if we are not in the deadband range.
Never seen this behavior before.
It looks like the constrain function is not working.
MIN = 48 MAX = 212 are calibrated for the full throw of the trigger.
As soon as sensorRawValue passes the 212 the sensorValue jumps to "0" I can see on the display.

Hum again.

Do I overlook something basic?

Code: [Select]

void loop()
{
sensorRawValue = analogRead(sensorspeedPin); // read the raw value from the linear hall sensor / potentio meter:
sensorValue = map(sensorRawValue, sensorMin, sensorMax, 0, 255);// map the calibration to the sensor reading from the hall sensor / potentiometer
}

Never to old to learn and I learn every day

Techylah

#108
Oct 03, 2012, 04:35 pm Last Edit: Oct 03, 2012, 09:47 pm by Techylah Reason: 1
Hi!
I think you did.
Add the constrain line in between, to make it:
Code: [Select]
sensorRawValue = analogRead(sensorspeedPin); // read the raw value from the linear hall sensor / potentiometer
sensorRawValue = constrain(sensorRawValue, sensorMin, sensorMax);
sensorValue = map(sensorRawValue, sensorMin, sensorMax, 0, 255);// map the calibration to the sensor reading from the hall sensor / potentiometer

The problem is that analogRead is returning values outside the range MIN to MAX
Mitch

backbone

Mitch,

Your on the spot. Thanks
Moving the constrain upwards did the trick.
Due to the fact the speed trigger potentiometer is giving eratic values I am converting to neodyne magnet and linear hall sensor.
Hope to have it ready at the end of the week.
From now on I use an original slot race controller body (with the magnet) instead of the custom made white controller handle.
To be continued.

paco
Never to old to learn and I learn every day

Go Up