Closed katodo closed 9 years ago
I've a trick way to resolve this problem:
1) Set default value:
MOTOR_ENABLE = Flag.OutpuEnablePolarity;
2) Change value respect default:
MOTOR_ENABLE ^= 1;
/cc @guiott
I don't understand your trick. For example in your bridge Enable is true with a HIGH level input, in my bridge Enable is true with a LOW level input. In my case input of bridge is a DISABLE ( or !ENABLE ) pin, in your case is a ENABLE ( or !DISABLE ) pin.
"Status" can be MOTOR_ACTIVE or MOTOR_DISABLED.
Flag.OutpuEnablePolarity is set to "1" if pin of bridge is an ENABLE pin or "0" if pin of bridge is a DISABLE input.
in this case function may be:
if( Status == MOTOR_ACTIVE )
MOTOR_ENABLE = Flag.OutpuEnablePolarity;
else
MOTOR_ENABLE = !(Flag.OutpuEnablePolarity);
this is what you meant?
Possible solution : MOTOR_ENABLE1 = enable_motors xor Flag.OutpuEnablePolarity;
Where, enable_motors is a message from protocol, MOTOR_ENABLE1 is a macro used to change pin status.
thanks rbonghi :)
Good morning! Yes @katodo, to solve this problem. I think to add the flag "OutputEnablePolarity" on dspic to change polarity (ON - OFF) switch motor, and add in https://github.com/rbonghi/uNAV.X/blob/develop/src/control/motors_PID.c#L218
The ours solution:
MOTOR_ENABLE1 = enable_motors ^ OutputEnablePolarity;
MOTOR_ENABLE2 = enable_motors ^ OutputEnablePolarity;
Finally, I would like to add a command in "parameters_motor_t": https://github.com/rbonghi/uNAV.X/blob/develop/includes/packet/motion.h#L109 to remotely change enable polarity.
solve with 7c521dc7b8a8784a64661951bae9efc6258d1f5d
Dependig by motor bridge, ENABLE pin can be valid LOW or HIGH. I need a FLAG to chose if ENABLE is true with LOW or HIGH level of output pin...
Now I call this flag Flag.OutpuEnablePolarity If (Flag.OutpuEnablePolarity == 1) I need HIGH level of output EN pin to enable bridge. If (Flag.OutpuEnablePolarity == 0) I need LOW level of output EN pin to enable bridge. Only for example purpose, this is my function on other software: