finalizacao e correcoes dos alarmes
This commit is contained in:
parent
95a88f88a3
commit
0682f8d250
Binary file not shown.
Binary file not shown.
|
|
@ -145,7 +145,7 @@ namespace AgroBase.Models
|
||||||
RampaMin.ToString("0000") + ";" + // 14 ~ 17
|
RampaMin.ToString("0000") + ";" + // 14 ~ 17
|
||||||
RampaMax.ToString("0000") + ";" + // 19 ~ 22
|
RampaMax.ToString("0000") + ";" + // 19 ~ 22
|
||||||
PulsosPorRevolucao.ToString("000") + ";" + // 24 ~ 26
|
PulsosPorRevolucao.ToString("000") + ";" + // 24 ~ 26
|
||||||
_DelayBalanceamento.ToString("000") + ";" + // 28 ~ 32
|
_DelayBalanceamento.ToString("00000") + ";" + // 28 ~ 32
|
||||||
_MargemRPM.ToString("00") + ";" + // 34 ~ 35
|
_MargemRPM.ToString("00") + ";" + // 34 ~ 35
|
||||||
_MaxOffsetRPM.ToString("00"); // 37 ~ 38
|
_MaxOffsetRPM.ToString("00"); // 37 ~ 38
|
||||||
Config.Add(ProtocoloMOD);
|
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;
|
MovimentacaoModel.UltimaDirecao = DirecaoAtual;
|
||||||
}
|
}
|
||||||
|
|
||||||
RPM_SP = DirecaoAtual == Direcao.Parado ? 0 : GeneralJoystick.RPM;
|
RPM_SP =
|
||||||
|
DirecaoAtual == Direcao.Parado ? 0 :
|
||||||
|
CmdAlarme ? 0 :
|
||||||
|
GeneralJoystick.RPM;
|
||||||
|
|
||||||
switch (DirecaoAtual)
|
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
|
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));
|
Variaveis.DispositivosConectados.FirstOrDefault(x => x.Dispositivo == T_Code.Mov).EnviarDadosSerial(ProtocoloComando(Direcao.Frente, true));
|
||||||
Potencia = 0;
|
|
||||||
RPM_SP = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Alm.Valor = _Alarme.Valor;
|
Alm.Valor = _Alarme.Valor;
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -107,7 +107,7 @@ class Motor {
|
||||||
}
|
}
|
||||||
if (_pinoSTP > -1) {
|
if (_pinoSTP > -1) {
|
||||||
pinMode(_pinoSTP, OUTPUT);
|
pinMode(_pinoSTP, OUTPUT);
|
||||||
digitalWrite(_pinoSTP, _Alarme);
|
digitalWrite(_pinoSTP, HIGH);
|
||||||
}
|
}
|
||||||
if (_pinoHLA > -1) {
|
if (_pinoHLA > -1) {
|
||||||
pinMode(_pinoHLA, INPUT);
|
pinMode(_pinoHLA, INPUT);
|
||||||
|
|
@ -359,7 +359,9 @@ class Motor {
|
||||||
if (RPM_Estavel) {
|
if (RPM_Estavel) {
|
||||||
RPM = RPM + _RPM_Offset;
|
RPM = RPM + _RPM_Offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
_PID->Compute();
|
_PID->Compute();
|
||||||
|
|
||||||
RPM = _rpmA;
|
RPM = _rpmA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -413,7 +415,7 @@ class Motor {
|
||||||
digitalWrite(_pinoBRK, _Freio);
|
digitalWrite(_pinoBRK, _Freio);
|
||||||
}
|
}
|
||||||
if (_pinoSTP > -1) {
|
if (_pinoSTP > -1) {
|
||||||
digitalWrite(_pinoSTP, !_Alarme);
|
digitalWrite(_pinoSTP, HIGH);
|
||||||
}
|
}
|
||||||
if (_pinoPWM > -1) {
|
if (_pinoPWM > -1) {
|
||||||
if (_SentidoSP == Parado) {
|
if (_SentidoSP == Parado) {
|
||||||
|
|
@ -614,10 +616,10 @@ void BalancearCargasMotores() {
|
||||||
double mediaPotencia = (M1_Pot + M2_Pot + M3_Pot + M4_Pot) / 4.0;
|
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
|
// 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 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;
|
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;
|
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;
|
double offsetM4_RPM = (M4_Pot != 0 ? (M4.RPM * (mediaPotencia - M4_Pot)) / M4_Pot : 0) * -1;
|
||||||
|
|
||||||
// Aplica o offset com limitação
|
// Aplica o offset com limitação
|
||||||
M1._RPM_Offset = fmin(fmax(offsetM1_RPM, -RPM_Offset_Max), RPM_Offset_Max);
|
M1._RPM_Offset = fmin(fmax(offsetM1_RPM, -RPM_Offset_Max), RPM_Offset_Max);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue