Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: L432KC_SPI_Pey_Lal
Revision 117:58148bdd13b7, committed 2022-05-23
- Comitter:
- voltxd
- Date:
- Mon May 23 13:05:26 2022 +0000
- Parent:
- 116:6dfcafa00e42
- Child:
- 118:67d6698069fd
- Commit message:
- CuttingPIcommandWhenPWMcommand
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon May 23 12:55:02 2022 +0000
+++ b/main.cpp Mon May 23 13:05:26 2022 +0000
@@ -83,6 +83,8 @@
switch(receivedCommand)
{
case COMMAND_PWM:
+ //Turn off PI
+ commandEnabled = false;
//1st. get the values
pulsewidth_propulsion = protocolReceivedPayload[0] << 8;
pulsewidth_propulsion += protocolReceivedPayload[1];
@@ -94,6 +96,8 @@
break;
case COMMAND_ASSERVISSEMENT:
+ //Turn on PI
+ commandEnabled = true;
//1st.
commandSpeed = convertBytesToFloat(protocolReceivedPayload, 0);
pulsewidth_direction = protocolReceivedPayload[4] << 8;
@@ -103,7 +107,9 @@
break;
case COMMAND_PARAMETRES:
- {
+ {
+ //Turn on PI
+ commandEnabled = true;
//1st.
float kp = convertBytesToFloat(protocolReceivedPayload, 0);
float ki = convertBytesToFloat(protocolReceivedPayload, 4);
@@ -158,8 +164,11 @@
void onTickerAsservissementInterrupt()
{
//Command car's speed
- pulsewidth_propulsion = PID(commandSpeed - currentSpeed, CONTROL_RATE);
+ if (commandEnabled)
+ pulsewidth_propulsion = PID(commandSpeed - currentSpeed, CONTROL_RATE);
propulsion.pulsewidth_us(pulsewidth_propulsion);
- //Open loop (for coef)
+ //Open loop (for transformation parameters)
+ //pulsewidth_propulsion = PID(commandSpeed, CONTROL_RATE);
+ //propulsion.pulsewidth_us(pulsewidth_propulsion);
}
\ No newline at end of file