I see there is an unused input on the dsPIC, as i understand the code it was planned for use as a regen throttle input but i was never used because the PIC cannot read both this and the neighboring temperature input, at least not if both are analog inputs.
So i am thinking, that pin could be used as a digital input for controlling reversing, a feature i really wish to have
So, i was poking around in the code a bit and edited it for my liking.
Im not shure about this though, im am not a programmer or an EE nor have i fully understood the currentRadiusRefRef variable and the sign variable.
I just posting this as an idea for people to have thoughts on, or maybe laugh at
![Big Grin](/forum/images/smilies/biggrin.gif)
Do NOT USE the code!
![EEK!](/forum/images/smilies/eek.gif)
![EEK!](/forum/images/smilies/eek.gif)
![EEK!](/forum/images/smilies/eek.gif)
Do you guys think this will work?
Also an other idea i had late last night was to build a small board with connector that fits on the icsp header, instead of using the regen_throttle input. This board would use 2 pins (PGC/PGD), one for input of reverse switch, and one for a relay output.
My car has an gear lever that has a solenoid in it, so it can not move between different gears at the wrong moment.
Actually this is just a BIG switch as there is only 1 gear in the box, and all control is done in SW in the original controller...
anyway... thats what the relay is for
![Smile](/forum/images/smilies/smile.gif)
Pros with this: it simple to build an extension board that plugs in to existing controller board.
Cons: by using these pins you can not do debugging via icsp anymore. at least not as long the pins are defined as I/O in SW.
that is how i understand it, but i am wrong quite often
Code:
if (RPS_times16 < 8) { // if less than 0.5 rev per second, make sure there's no regen. Also allow changing into reverse
if (currentRadiusRefRef < 0) currentRadiusRefRef = 0;
if (I_PORT_REGEN_THROTTLE == 0) { //check input for reverse switch
reversing = 1;
{
else{
reversing = 0;
}
}
}
if (reversing = 0){
if (currentRadiusRefRef < 0) {
currentRadiusRefRef = -currentRadiusRefRef;
sign = -1;
}
else {
sign = 1;
}
}
if (reversing = 1){
if (currentRadiusRefRef > 0) {
currentRadiusRefRef = -currentRadiusRefRef;
sign = -1;
}
else {
sign = 1;
}
}