States are defined as follows
#define ON true
#define OFF false
from line 339 onward there are several functions
void turnOffAllFETs() {
transitionHighSideFET(OFF);
transitionLowSideFET(OFF);
}
void setFETsForBraking() {
transitionHighSideFET(ON);
transitionLowSideFET(OFF);
}
void setFETsForOn() {
transitionHighSideFET(OFF);
transitionLowSideFET(ON);
}
// Abstracts away digitalWrites, helps make code more readable
void transitionHighSideFET(bool toTurnOn) {
// transitioning high side FET can be confusing since the digitalWrite() must
// be inverted
digitalWrite(HIGH_SIDE_PIN, !toTurnOn);
}
// Abstracts away digitalWrites, helps make code more readable
void transitionLowSideFET(bool toTurnOn) {
digitalWrite(LOW_SIDE_PIN, toTurnOn);
}
you can either change the function call arguments (OFF, ON) or use an ! in front of toTurnOn
For example you could change these if you need to invert an output but it might get confusing because the ON could mean OFF if your circuit is different
transitionHighSideFET(OFF); -> transitionHighSideFET(ON);
transitionLowSideFET(ON); -> transitionHighSideFET(OFF);
Or you could do it the right way: (Note the exclamation marks)
digitalWrite(HIGH_SIDE_PIN, !toTurnOn); -> digitalWrite(HIGH_SIDE_PIN, toTurnOn);
digitalWrite(LOW_SIDE_PIN, toTurnOn); -> digitalWrite(LOW_SIDE_PIN, !toTurnOn);
Changing the ON and OFF arguments is the easy way, just make sure that both relay's don't turn on at the same time. That would not end well for your circuit. You should test everything before applying power to avoid shorts.
If you still don't get it, tell me what state of the Arduino pins will cause the relays to be on and I will change the code for you. I cant tell because your schematic has MOSFETs. (low = on, or high = on)
I still think relays are going to cause problems, if they short the battery because they don't open in time then they may get stuck from too much current and possibly cause a fire. Make sure you use a fuse.