diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/815c6f56-7365-4b82-85bd-086d5c3114e1.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/9575d9d6-974e-4322-8aa8-43a6196901c0.vsidx similarity index 54% rename from AgroBase/.vs/AgroBase/FileContentIndex/815c6f56-7365-4b82-85bd-086d5c3114e1.vsidx rename to AgroBase/.vs/AgroBase/FileContentIndex/9575d9d6-974e-4322-8aa8-43a6196901c0.vsidx index c14add710..cf67ef81c 100644 Binary files a/AgroBase/.vs/AgroBase/FileContentIndex/815c6f56-7365-4b82-85bd-086d5c3114e1.vsidx and b/AgroBase/.vs/AgroBase/FileContentIndex/9575d9d6-974e-4322-8aa8-43a6196901c0.vsidx differ diff --git a/AgroBase/.vs/AgroBase/v17/.suo b/AgroBase/.vs/AgroBase/v17/.suo index f2c932fd6..6ee25245c 100644 Binary files a/AgroBase/.vs/AgroBase/v17/.suo and b/AgroBase/.vs/AgroBase/v17/.suo differ diff --git a/AgroBase/AgroBase/Models/Modules/MovimentacaoModel.cs b/AgroBase/AgroBase/Models/Modules/MovimentacaoModel.cs index 5aa69e184..8773fc41a 100644 --- a/AgroBase/AgroBase/Models/Modules/MovimentacaoModel.cs +++ b/AgroBase/AgroBase/Models/Modules/MovimentacaoModel.cs @@ -145,7 +145,7 @@ namespace AgroBase.Models RampaMin.ToString("0000") + ";" + // 14 ~ 17 RampaMax.ToString("0000") + ";" + // 19 ~ 22 PulsosPorRevolucao.ToString("000") + ";" + // 24 ~ 26 - _DelayBalanceamento.ToString("000") + ";" + // 28 ~ 32 + _DelayBalanceamento.ToString("00000") + ";" + // 28 ~ 32 _MargemRPM.ToString("00") + ";" + // 34 ~ 35 _MaxOffsetRPM.ToString("00"); // 37 ~ 38 Config.Add(ProtocoloMOD); @@ -466,16 +466,19 @@ namespace AgroBase.Models } - public string ProtocoloComando(Direcao DirecaoAtual, bool Individual = false) + public string ProtocoloComando(Direcao DirecaoAtual, bool CmdAlarme = false) { - if (Comandar && !Individual) + if (Comandar && (!Alarme || CmdAlarme)) { - if (!Alarme) + if (!CmdAlarme) { MovimentacaoModel.UltimaDirecao = DirecaoAtual; } - RPM_SP = DirecaoAtual == Direcao.Parado ? 0 : GeneralJoystick.RPM; + RPM_SP = + DirecaoAtual == Direcao.Parado ? 0 : + CmdAlarme ? 0 : + GeneralJoystick.RPM; switch (DirecaoAtual) { @@ -560,9 +563,7 @@ namespace AgroBase.Models if (Inicializado && (!AlarmeAnterior || Adicionado) && AlarmeAtual) // Motor iniciado, Não estava em alarme anteriormente ou foi adicionado agora, alarme atual { - Variaveis.DispositivosConectados.FirstOrDefault(x => x.Dispositivo == T_Code.Mov).EnviarDadosSerial(ProtocoloComando(Direcao.Parado, true)); - Potencia = 0; - RPM_SP = 0; + Variaveis.DispositivosConectados.FirstOrDefault(x => x.Dispositivo == T_Code.Mov).EnviarDadosSerial(ProtocoloComando(Direcao.Frente, true)); } Alm.Valor = _Alarme.Valor; diff --git a/AgroBase/AgroBase/obj/Debug/AgroBase.csproj.AssemblyReference.cache b/AgroBase/AgroBase/obj/Debug/AgroBase.csproj.AssemblyReference.cache index b4ca68069..e64ca7b28 100644 Binary files a/AgroBase/AgroBase/obj/Debug/AgroBase.csproj.AssemblyReference.cache and b/AgroBase/AgroBase/obj/Debug/AgroBase.csproj.AssemblyReference.cache differ diff --git a/AgroBase/AgroBase/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/AgroBase/AgroBase/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index 35ffc5d00..e85599949 100644 Binary files a/AgroBase/AgroBase/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/AgroBase/AgroBase/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/Firmware/Movimentação/Movimentacao_v16/Movimentacao_v16.ino b/Firmware/Movimentação/Movimentacao_v16/Movimentacao_v16.ino index e75cad663..b2a477eab 100644 --- a/Firmware/Movimentação/Movimentacao_v16/Movimentacao_v16.ino +++ b/Firmware/Movimentação/Movimentacao_v16/Movimentacao_v16.ino @@ -107,7 +107,7 @@ class Motor { } if (_pinoSTP > -1) { pinMode(_pinoSTP, OUTPUT); - digitalWrite(_pinoSTP, _Alarme); + digitalWrite(_pinoSTP, HIGH); } if (_pinoHLA > -1) { pinMode(_pinoHLA, INPUT); @@ -359,7 +359,9 @@ class Motor { if (RPM_Estavel) { RPM = RPM + _RPM_Offset; } + _PID->Compute(); + RPM = _rpmA; } } @@ -413,7 +415,7 @@ class Motor { digitalWrite(_pinoBRK, _Freio); } if (_pinoSTP > -1) { - digitalWrite(_pinoSTP, !_Alarme); + digitalWrite(_pinoSTP, HIGH); } if (_pinoPWM > -1) { if (_SentidoSP == Parado) { @@ -614,10 +616,10 @@ void BalancearCargasMotores() { double mediaPotencia = (M1_Pot + M2_Pot + M3_Pot + M4_Pot) / 4.0; // Certifique-se de verificar se a potência atual não é zero antes de dividir - double offsetM1_RPM = M1_Pot != 0 ? (M1.RPM * (mediaPotencia - M1_Pot)) / M1_Pot : 0; - double offsetM2_RPM = M2_Pot != 0 ? (M2.RPM * (mediaPotencia - M2_Pot)) / M2_Pot : 0; - double offsetM3_RPM = M3_Pot != 0 ? (M3.RPM * (mediaPotencia - M3_Pot)) / M3_Pot : 0; - double offsetM4_RPM = M4_Pot != 0 ? (M4.RPM * (mediaPotencia - M4_Pot)) / M4_Pot : 0; + double offsetM1_RPM = (M1_Pot != 0 ? (M1.RPM * (mediaPotencia - M1_Pot)) / M1_Pot : 0) * -1; + double offsetM2_RPM = (M2_Pot != 0 ? (M2.RPM * (mediaPotencia - M2_Pot)) / M2_Pot : 0) * -1; + double offsetM3_RPM = (M3_Pot != 0 ? (M3.RPM * (mediaPotencia - M3_Pot)) / M3_Pot : 0) * -1; + double offsetM4_RPM = (M4_Pot != 0 ? (M4.RPM * (mediaPotencia - M4_Pot)) / M4_Pot : 0) * -1; // Aplica o offset com limitação M1._RPM_Offset = fmin(fmax(offsetM1_RPM, -RPM_Offset_Max), RPM_Offset_Max);