diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/1c90bbc2-e560-4813-83c0-ec0baf9b1c51.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/1c90bbc2-e560-4813-83c0-ec0baf9b1c51.vsidx
deleted file mode 100644
index abf4fe1c4..000000000
Binary files a/AgroBase/.vs/AgroBase/FileContentIndex/1c90bbc2-e560-4813-83c0-ec0baf9b1c51.vsidx and /dev/null differ
diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/4057b060-9899-436f-a13f-bb185308047a.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/4057b060-9899-436f-a13f-bb185308047a.vsidx
deleted file mode 100644
index 3e4060350..000000000
Binary files a/AgroBase/.vs/AgroBase/FileContentIndex/4057b060-9899-436f-a13f-bb185308047a.vsidx and /dev/null differ
diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/76165549-d1cf-4a1a-9852-2164e462bead.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/76165549-d1cf-4a1a-9852-2164e462bead.vsidx
new file mode 100644
index 000000000..0f461a606
Binary files /dev/null and b/AgroBase/.vs/AgroBase/FileContentIndex/76165549-d1cf-4a1a-9852-2164e462bead.vsidx differ
diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/c7bafaa5-a785-4edd-91b6-8c4823d45a44.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/8d2cb818-4867-4ca3-a4e3-7c76532b11ff.vsidx
similarity index 99%
rename from AgroBase/.vs/AgroBase/FileContentIndex/c7bafaa5-a785-4edd-91b6-8c4823d45a44.vsidx
rename to AgroBase/.vs/AgroBase/FileContentIndex/8d2cb818-4867-4ca3-a4e3-7c76532b11ff.vsidx
index d65ff4e5c..679c73bc1 100644
Binary files a/AgroBase/.vs/AgroBase/FileContentIndex/c7bafaa5-a785-4edd-91b6-8c4823d45a44.vsidx and b/AgroBase/.vs/AgroBase/FileContentIndex/8d2cb818-4867-4ca3-a4e3-7c76532b11ff.vsidx differ
diff --git a/AgroBase/.vs/AgroBase/FileContentIndex/bfb9e13b-eddc-4085-a81c-671bf9831286.vsidx b/AgroBase/.vs/AgroBase/FileContentIndex/bfb9e13b-eddc-4085-a81c-671bf9831286.vsidx
new file mode 100644
index 000000000..18c76f914
Binary files /dev/null and b/AgroBase/.vs/AgroBase/FileContentIndex/bfb9e13b-eddc-4085-a81c-671bf9831286.vsidx differ
diff --git a/AgroBase/.vs/AgroBase/v17/.suo b/AgroBase/.vs/AgroBase/v17/.suo
index 5bbb2f059..e31d56484 100644
Binary files a/AgroBase/.vs/AgroBase/v17/.suo and b/AgroBase/.vs/AgroBase/v17/.suo differ
diff --git a/AgroBase/AgroBase/AgroBase.csproj b/AgroBase/AgroBase/AgroBase.csproj
index 981ab4cc2..311794615 100644
--- a/AgroBase/AgroBase/AgroBase.csproj
+++ b/AgroBase/AgroBase/AgroBase.csproj
@@ -240,6 +240,12 @@
frmSenCamera.cs
+
+ Form
+
+
+ frmSenConfig.cs
+
@@ -316,6 +322,9 @@
frmSenCamera.cs
+
+ frmSenConfig.cs
+
ResXFileCodeGenerator
Resources.Designer.cs
diff --git a/AgroBase/AgroBase/Forms/Sensoriamento/frmSenConfig.Designer.cs b/AgroBase/AgroBase/Forms/Sensoriamento/frmSenConfig.Designer.cs
new file mode 100644
index 000000000..50c2ab2dd
--- /dev/null
+++ b/AgroBase/AgroBase/Forms/Sensoriamento/frmSenConfig.Designer.cs
@@ -0,0 +1,114 @@
+namespace AgroBase.Forms.Sensoriamento
+{
+ partial class frmSenConfig
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.gridsTEN = new System.Windows.Forms.DataGridView();
+ this.gridsCOR = new System.Windows.Forms.DataGridView();
+ this.btnSalvar = new System.Windows.Forms.Button();
+ this.lblTensao = new System.Windows.Forms.Label();
+ this.lblCorrente = new System.Windows.Forms.Label();
+ ((System.ComponentModel.ISupportInitialize)(this.gridsTEN)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.gridsCOR)).BeginInit();
+ this.SuspendLayout();
+ //
+ // gridsTEN
+ //
+ this.gridsTEN.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.gridsTEN.Location = new System.Drawing.Point(12, 25);
+ this.gridsTEN.Name = "gridsTEN";
+ this.gridsTEN.Size = new System.Drawing.Size(270, 124);
+ this.gridsTEN.TabIndex = 1;
+ //
+ // gridsCOR
+ //
+ this.gridsCOR.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.gridsCOR.Location = new System.Drawing.Point(288, 25);
+ this.gridsCOR.Name = "gridsCOR";
+ this.gridsCOR.Size = new System.Drawing.Size(270, 124);
+ this.gridsCOR.TabIndex = 1;
+ //
+ // btnSalvar
+ //
+ this.btnSalvar.Location = new System.Drawing.Point(483, 155);
+ this.btnSalvar.Name = "btnSalvar";
+ this.btnSalvar.Size = new System.Drawing.Size(75, 23);
+ this.btnSalvar.TabIndex = 3;
+ this.btnSalvar.Text = "Salvar";
+ this.btnSalvar.UseVisualStyleBackColor = true;
+ this.btnSalvar.Click += new System.EventHandler(this.btnSalvar_Click);
+ //
+ // lblTensao
+ //
+ this.lblTensao.AutoSize = true;
+ this.lblTensao.Location = new System.Drawing.Point(12, 9);
+ this.lblTensao.Name = "lblTensao";
+ this.lblTensao.Size = new System.Drawing.Size(43, 13);
+ this.lblTensao.TabIndex = 4;
+ this.lblTensao.Text = "Tensão";
+ //
+ // lblCorrente
+ //
+ this.lblCorrente.AutoSize = true;
+ this.lblCorrente.Location = new System.Drawing.Point(285, 9);
+ this.lblCorrente.Name = "lblCorrente";
+ this.lblCorrente.Size = new System.Drawing.Size(47, 13);
+ this.lblCorrente.TabIndex = 5;
+ this.lblCorrente.Text = "Corrente";
+ //
+ // frmSenConfig
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(571, 188);
+ this.Controls.Add(this.lblCorrente);
+ this.Controls.Add(this.lblTensao);
+ this.Controls.Add(this.gridsCOR);
+ this.Controls.Add(this.gridsTEN);
+ this.Controls.Add(this.btnSalvar);
+ this.MaximizeBox = false;
+ this.Name = "frmSenConfig";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+ this.Text = "Sensoriamento - Parametrização";
+ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmSenConfig_FormClosing);
+ this.Load += new System.EventHandler(this.frmSenConfig_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.gridsTEN)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.gridsCOR)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+ private System.Windows.Forms.DataGridView gridsTEN;
+ private System.Windows.Forms.DataGridView gridsCOR;
+ private System.Windows.Forms.Button btnSalvar;
+ private System.Windows.Forms.Label lblTensao;
+ private System.Windows.Forms.Label lblCorrente;
+ }
+}
\ No newline at end of file
diff --git a/AgroBase/AgroBase/Forms/Sensoriamento/frmSenConfig.cs b/AgroBase/AgroBase/Forms/Sensoriamento/frmSenConfig.cs
new file mode 100644
index 000000000..d71376bb9
--- /dev/null
+++ b/AgroBase/AgroBase/Forms/Sensoriamento/frmSenConfig.cs
@@ -0,0 +1,88 @@
+using AgroBase.Comum;
+using AgroBase.Models;
+using AgroBase.Models.Modules;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using static AgroBase.Models.Enuns;
+
+namespace AgroBase.Forms.Sensoriamento
+{
+ public partial class frmSenConfig : Form
+ {
+ DispositivosService Disp = (DispositivosService)Variaveis.DispositivosConectados.FirstOrDefault(x => x.Dispositivo == T_Code.Sen);
+
+ public frmSenConfig()
+ {
+ InitializeComponent();
+ }
+
+ private void frmSenConfig_Load(object sender, EventArgs e)
+ {
+ if (Disp == null)
+ {
+ return;
+ }
+
+ foreach (var Sensor in Disp.Dados.Sensores)
+ {
+ string gridName = "grid" + Enum.GetName(typeof(S_Code), Sensor.Componente);
+ DataGridView grid = this.Controls.OfType().ToList().FirstOrDefault(x => x.Name == gridName);
+ if (grid != null)
+ {
+ grid.Rows.Clear();
+ grid.Columns.Clear();
+ grid.Columns.Add("clParametro", "Parâmetro");
+ grid.Columns.Add("clValor", "Valor");
+ foreach (var Parametro in Sensor.Parametros)
+ {
+ grid.Rows.Add(Parametro[0], Parametro[1]);
+ }
+ //grid.Rows.RemoveAt(grid.Rows.Count - 1);
+ }
+
+ }
+
+ }
+
+ private void frmSenConfig_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ e.Cancel = true;
+ this.Visible = false;
+ }
+
+ private void btnSalvar_Click(object sender, EventArgs e)
+ {
+ if (Disp == null)
+ {
+ return;
+ }
+
+ foreach (var Sensor in Disp.Dados.Sensores)
+ {
+ string gridName = "grid" + Enum.GetName(typeof(S_Code), Sensor.Componente);
+ DataGridView grid = this.Controls.OfType().ToList().FirstOrDefault(x => x.Name == gridName);
+ if (grid != null && grid.Rows.Count > 1)
+ {
+ Sensor.Parametros = new List();
+ foreach (DataGridViewRow Row in grid.Rows)
+ {
+ if (Row.Cells[0].Value != null)
+ {
+ Sensor.Parametros.Add(new string[] { Row.Cells[0].Value.ToString(), Row.Cells[1].Value.ToString() });
+ }
+ }
+ }
+ }
+ }
+
+
+ }
+}
diff --git a/AgroBase/AgroBase/Forms/Sensoriamento/frmSenConfig.resx b/AgroBase/AgroBase/Forms/Sensoriamento/frmSenConfig.resx
new file mode 100644
index 000000000..1af7de150
--- /dev/null
+++ b/AgroBase/AgroBase/Forms/Sensoriamento/frmSenConfig.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/AgroBase/AgroBase/Forms/frmAcompanhamento.Designer.cs b/AgroBase/AgroBase/Forms/frmAcompanhamento.Designer.cs
index dc2bb77c4..4a557b677 100644
--- a/AgroBase/AgroBase/Forms/frmAcompanhamento.Designer.cs
+++ b/AgroBase/AgroBase/Forms/frmAcompanhamento.Designer.cs
@@ -124,6 +124,8 @@ namespace AgroBase.Forms
this.btnEFReferenciar = new System.Windows.Forms.Button();
this.lblM1 = new System.Windows.Forms.Label();
this.picEF = new System.Windows.Forms.PictureBox();
+ this.lblCorrente = new System.Windows.Forms.Label();
+ this.lblTensao = new System.Windows.Forms.Label();
this.pnlFundo.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.chartET)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.chartDT)).BeginInit();
@@ -140,6 +142,8 @@ namespace AgroBase.Forms
//
this.pnlFundo.AutoScroll = true;
this.pnlFundo.BackColor = System.Drawing.Color.White;
+ this.pnlFundo.Controls.Add(this.lblCorrente);
+ this.pnlFundo.Controls.Add(this.lblTensao);
this.pnlFundo.Controls.Add(this.lblDistanciaParcial);
this.pnlFundo.Controls.Add(this.lblDistanciaTotal);
this.pnlFundo.Controls.Add(this.lblTempoEmMovimento);
@@ -223,7 +227,7 @@ namespace AgroBase.Forms
this.pnlFundo.Controls.Add(this.picEF);
this.pnlFundo.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlFundo.Location = new System.Drawing.Point(0, 0);
- this.pnlFundo.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.pnlFundo.Margin = new System.Windows.Forms.Padding(2);
this.pnlFundo.Name = "pnlFundo";
this.pnlFundo.Size = new System.Drawing.Size(1484, 749);
this.pnlFundo.TabIndex = 0;
@@ -272,7 +276,7 @@ namespace AgroBase.Forms
//
this.chbDTLivre.AutoSize = true;
this.chbDTLivre.Location = new System.Drawing.Point(784, 725);
- this.chbDTLivre.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.chbDTLivre.Margin = new System.Windows.Forms.Padding(2);
this.chbDTLivre.Name = "chbDTLivre";
this.chbDTLivre.Size = new System.Drawing.Size(49, 17);
this.chbDTLivre.TabIndex = 166;
@@ -283,7 +287,7 @@ namespace AgroBase.Forms
//
this.chbDTControlar.AutoSize = true;
this.chbDTControlar.Location = new System.Drawing.Point(764, 703);
- this.chbDTControlar.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.chbDTControlar.Margin = new System.Windows.Forms.Padding(2);
this.chbDTControlar.Name = "chbDTControlar";
this.chbDTControlar.Size = new System.Drawing.Size(68, 17);
this.chbDTControlar.TabIndex = 165;
@@ -294,7 +298,7 @@ namespace AgroBase.Forms
//
this.chbETLivre.AutoSize = true;
this.chbETLivre.Location = new System.Drawing.Point(639, 725);
- this.chbETLivre.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.chbETLivre.Margin = new System.Windows.Forms.Padding(2);
this.chbETLivre.Name = "chbETLivre";
this.chbETLivre.Size = new System.Drawing.Size(49, 17);
this.chbETLivre.TabIndex = 164;
@@ -305,7 +309,7 @@ namespace AgroBase.Forms
//
this.chbETControlar.AutoSize = true;
this.chbETControlar.Location = new System.Drawing.Point(639, 703);
- this.chbETControlar.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.chbETControlar.Margin = new System.Windows.Forms.Padding(2);
this.chbETControlar.Name = "chbETControlar";
this.chbETControlar.Size = new System.Drawing.Size(68, 17);
this.chbETControlar.TabIndex = 163;
@@ -316,7 +320,7 @@ namespace AgroBase.Forms
//
this.chbDFLivre.AutoSize = true;
this.chbDFLivre.Location = new System.Drawing.Point(784, 86);
- this.chbDFLivre.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.chbDFLivre.Margin = new System.Windows.Forms.Padding(2);
this.chbDFLivre.Name = "chbDFLivre";
this.chbDFLivre.Size = new System.Drawing.Size(49, 17);
this.chbDFLivre.TabIndex = 162;
@@ -327,7 +331,7 @@ namespace AgroBase.Forms
//
this.chbDFControlar.AutoSize = true;
this.chbDFControlar.Location = new System.Drawing.Point(764, 64);
- this.chbDFControlar.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.chbDFControlar.Margin = new System.Windows.Forms.Padding(2);
this.chbDFControlar.Name = "chbDFControlar";
this.chbDFControlar.Size = new System.Drawing.Size(68, 17);
this.chbDFControlar.TabIndex = 161;
@@ -338,7 +342,7 @@ namespace AgroBase.Forms
//
this.chbEFLivre.AutoSize = true;
this.chbEFLivre.Location = new System.Drawing.Point(639, 86);
- this.chbEFLivre.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.chbEFLivre.Margin = new System.Windows.Forms.Padding(2);
this.chbEFLivre.Name = "chbEFLivre";
this.chbEFLivre.Size = new System.Drawing.Size(49, 17);
this.chbEFLivre.TabIndex = 160;
@@ -349,7 +353,7 @@ namespace AgroBase.Forms
//
this.chbEFControlar.AutoSize = true;
this.chbEFControlar.Location = new System.Drawing.Point(639, 64);
- this.chbEFControlar.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.chbEFControlar.Margin = new System.Windows.Forms.Padding(2);
this.chbEFControlar.Name = "chbEFControlar";
this.chbEFControlar.Size = new System.Drawing.Size(68, 17);
this.chbEFControlar.TabIndex = 159;
@@ -363,7 +367,7 @@ namespace AgroBase.Forms
legend1.Name = "Legend1";
this.chartET.Legends.Add(legend1);
this.chartET.Location = new System.Drawing.Point(201, 410);
- this.chartET.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.chartET.Margin = new System.Windows.Forms.Padding(2);
this.chartET.Name = "chartET";
series1.ChartArea = "ChartArea1";
series1.Legend = "Legend1";
@@ -380,7 +384,7 @@ namespace AgroBase.Forms
legend2.Name = "Legend1";
this.chartDT.Legends.Add(legend2);
this.chartDT.Location = new System.Drawing.Point(834, 410);
- this.chartDT.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.chartDT.Margin = new System.Windows.Forms.Padding(2);
this.chartDT.Name = "chartDT";
series2.ChartArea = "ChartArea1";
series2.Legend = "Legend1";
@@ -397,7 +401,7 @@ namespace AgroBase.Forms
legend3.Name = "Legend1";
this.chartDF.Legends.Add(legend3);
this.chartDF.Location = new System.Drawing.Point(834, 4);
- this.chartDF.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.chartDF.Margin = new System.Windows.Forms.Padding(2);
this.chartDF.Name = "chartDF";
series3.ChartArea = "ChartArea1";
series3.Legend = "Legend1";
@@ -414,7 +418,7 @@ namespace AgroBase.Forms
legend4.Name = "Legend1";
this.chartEF.Legends.Add(legend4);
this.chartEF.Location = new System.Drawing.Point(201, 4);
- this.chartEF.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.chartEF.Margin = new System.Windows.Forms.Padding(2);
this.chartEF.Name = "chartEF";
series4.ChartArea = "ChartArea1";
series4.Legend = "Legend1";
@@ -428,7 +432,7 @@ namespace AgroBase.Forms
//
this.picRobo.Image = ((System.Drawing.Image)(resources.GetObject("picRobo.Image")));
this.picRobo.Location = new System.Drawing.Point(602, 206);
- this.picRobo.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.picRobo.Margin = new System.Windows.Forms.Padding(2);
this.picRobo.Name = "picRobo";
this.picRobo.Size = new System.Drawing.Size(265, 395);
this.picRobo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
@@ -758,7 +762,7 @@ namespace AgroBase.Forms
// btnDTReverter
//
this.btnDTReverter.Location = new System.Drawing.Point(736, 774);
- this.btnDTReverter.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.btnDTReverter.Margin = new System.Windows.Forms.Padding(2);
this.btnDTReverter.Name = "btnDTReverter";
this.btnDTReverter.Size = new System.Drawing.Size(93, 23);
this.btnDTReverter.TabIndex = 125;
@@ -768,7 +772,7 @@ namespace AgroBase.Forms
// btnETReverter
//
this.btnETReverter.Location = new System.Drawing.Point(639, 774);
- this.btnETReverter.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.btnETReverter.Margin = new System.Windows.Forms.Padding(2);
this.btnETReverter.Name = "btnETReverter";
this.btnETReverter.Size = new System.Drawing.Size(93, 23);
this.btnETReverter.TabIndex = 124;
@@ -778,7 +782,7 @@ namespace AgroBase.Forms
// btnDFReverter
//
this.btnDFReverter.Location = new System.Drawing.Point(736, 37);
- this.btnDFReverter.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.btnDFReverter.Margin = new System.Windows.Forms.Padding(2);
this.btnDFReverter.Name = "btnDFReverter";
this.btnDFReverter.Size = new System.Drawing.Size(93, 23);
this.btnDFReverter.TabIndex = 123;
@@ -788,7 +792,7 @@ namespace AgroBase.Forms
// btnEFReverter
//
this.btnEFReverter.Location = new System.Drawing.Point(639, 37);
- this.btnEFReverter.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.btnEFReverter.Margin = new System.Windows.Forms.Padding(2);
this.btnEFReverter.Name = "btnEFReverter";
this.btnEFReverter.Size = new System.Drawing.Size(93, 23);
this.btnEFReverter.TabIndex = 122;
@@ -838,7 +842,7 @@ namespace AgroBase.Forms
// btnDTReferenciar
//
this.btnDTReferenciar.Location = new System.Drawing.Point(736, 747);
- this.btnDTReferenciar.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.btnDTReferenciar.Margin = new System.Windows.Forms.Padding(2);
this.btnDTReferenciar.Name = "btnDTReferenciar";
this.btnDTReferenciar.Size = new System.Drawing.Size(93, 23);
this.btnDTReferenciar.TabIndex = 117;
@@ -859,7 +863,7 @@ namespace AgroBase.Forms
// picDT
//
this.picDT.Location = new System.Drawing.Point(1271, 432);
- this.picDT.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.picDT.Margin = new System.Windows.Forms.Padding(2);
this.picDT.Name = "picDT";
this.picDT.Size = new System.Drawing.Size(188, 203);
this.picDT.TabIndex = 115;
@@ -908,7 +912,7 @@ namespace AgroBase.Forms
// btnDFReferenciar
//
this.btnDFReferenciar.Location = new System.Drawing.Point(736, 9);
- this.btnDFReferenciar.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.btnDFReferenciar.Margin = new System.Windows.Forms.Padding(2);
this.btnDFReferenciar.Name = "btnDFReferenciar";
this.btnDFReferenciar.Size = new System.Drawing.Size(93, 23);
this.btnDFReferenciar.TabIndex = 108;
@@ -929,7 +933,7 @@ namespace AgroBase.Forms
// picDF
//
this.picDF.Location = new System.Drawing.Point(1271, 27);
- this.picDF.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.picDF.Margin = new System.Windows.Forms.Padding(2);
this.picDF.Name = "picDF";
this.picDF.Size = new System.Drawing.Size(188, 203);
this.picDF.TabIndex = 106;
@@ -978,7 +982,7 @@ namespace AgroBase.Forms
// btnETReferenciar
//
this.btnETReferenciar.Location = new System.Drawing.Point(639, 747);
- this.btnETReferenciar.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.btnETReferenciar.Margin = new System.Windows.Forms.Padding(2);
this.btnETReferenciar.Name = "btnETReferenciar";
this.btnETReferenciar.Size = new System.Drawing.Size(93, 23);
this.btnETReferenciar.TabIndex = 101;
@@ -999,7 +1003,7 @@ namespace AgroBase.Forms
// picET
//
this.picET.Location = new System.Drawing.Point(9, 432);
- this.picET.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.picET.Margin = new System.Windows.Forms.Padding(2);
this.picET.Name = "picET";
this.picET.Size = new System.Drawing.Size(188, 203);
this.picET.TabIndex = 99;
@@ -1048,7 +1052,7 @@ namespace AgroBase.Forms
// btnEFReferenciar
//
this.btnEFReferenciar.Location = new System.Drawing.Point(639, 9);
- this.btnEFReferenciar.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.btnEFReferenciar.Margin = new System.Windows.Forms.Padding(2);
this.btnEFReferenciar.Name = "btnEFReferenciar";
this.btnEFReferenciar.Size = new System.Drawing.Size(93, 23);
this.btnEFReferenciar.TabIndex = 92;
@@ -1069,19 +1073,41 @@ namespace AgroBase.Forms
// picEF
//
this.picEF.Location = new System.Drawing.Point(9, 27);
- this.picEF.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.picEF.Margin = new System.Windows.Forms.Padding(2);
this.picEF.Name = "picEF";
this.picEF.Size = new System.Drawing.Size(188, 203);
this.picEF.TabIndex = 90;
this.picEF.TabStop = false;
//
+ // lblCorrente
+ //
+ this.lblCorrente.AutoSize = true;
+ this.lblCorrente.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.lblCorrente.Location = new System.Drawing.Point(639, 619);
+ this.lblCorrente.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+ this.lblCorrente.Name = "lblCorrente";
+ this.lblCorrente.Size = new System.Drawing.Size(202, 12);
+ this.lblCorrente.TabIndex = 172;
+ this.lblCorrente.Text = "Corrente atual: 0,00A - Mín: 0,00A - Máx: 0,00A";
+ //
+ // lblTensao
+ //
+ this.lblTensao.AutoSize = true;
+ this.lblTensao.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.lblTensao.Location = new System.Drawing.Point(639, 606);
+ this.lblTensao.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+ this.lblTensao.Name = "lblTensao";
+ this.lblTensao.Size = new System.Drawing.Size(196, 12);
+ this.lblTensao.TabIndex = 171;
+ this.lblTensao.Text = "Tensão atual: 0,00V - Mín: 0,00V - Máx: 0,00V";
+ //
// frmAcompanhamento
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1484, 749);
this.Controls.Add(this.pnlFundo);
- this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.Margin = new System.Windows.Forms.Padding(2);
this.Name = "frmAcompanhamento";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Acompanhamento";
@@ -1187,5 +1213,7 @@ namespace AgroBase.Forms
private System.Windows.Forms.Label lblDistanciaTotal;
private System.Windows.Forms.Label lblTempoEmMovimento;
private System.Windows.Forms.Label lblTempoConectado;
+ public System.Windows.Forms.Label lblCorrente;
+ public System.Windows.Forms.Label lblTensao;
}
}
\ No newline at end of file
diff --git a/AgroBase/AgroBase/Forms/frmAcompanhamento.cs b/AgroBase/AgroBase/Forms/frmAcompanhamento.cs
index 4cb6d7b94..3f7b08058 100644
--- a/AgroBase/AgroBase/Forms/frmAcompanhamento.cs
+++ b/AgroBase/AgroBase/Forms/frmAcompanhamento.cs
@@ -396,6 +396,21 @@ namespace AgroBase.Forms
}
}
-
+
+ delegate void AtualizarSensoresDelegate(string Texto);
+
+ public void AtualizarSensores(string Texto)
+ {
+ Label lbl = Texto.Contains("Corrente") ? lblCorrente : lblTensao;
+ if (lbl.InvokeRequired)
+ {
+ lbl.Invoke(new AtualizarSensoresDelegate(AtualizarSensores), Texto);
+ }
+ else
+ {
+ lbl.Text = Texto;
+ }
+ }
+
}
}
diff --git a/AgroBase/AgroBase/Models/Modules/PinoutModel.cs b/AgroBase/AgroBase/Models/Modules/PinoutModel.cs
index 710cbf91f..66e9f9c8d 100644
--- a/AgroBase/AgroBase/Models/Modules/PinoutModel.cs
+++ b/AgroBase/AgroBase/Models/Modules/PinoutModel.cs
@@ -273,5 +273,7 @@ namespace AgroBase.Models.Modules
Leitura3,
Leitura4,
I2C,
+ Tensao,
+ Corrente,
}
}
diff --git a/AgroBase/AgroBase/Models/Modules/SensoriamentoModel.cs b/AgroBase/AgroBase/Models/Modules/SensoriamentoModel.cs
index 8ed1c614f..e05544de6 100644
--- a/AgroBase/AgroBase/Models/Modules/SensoriamentoModel.cs
+++ b/AgroBase/AgroBase/Models/Modules/SensoriamentoModel.cs
@@ -41,6 +41,7 @@ namespace AgroBase.Models.Modules
FuncoesPinout.TMP,
},
DelayAmostragem = 200,
+ Parametros = new List(),
},
new SensorModel()
{
@@ -56,6 +57,7 @@ namespace AgroBase.Models.Modules
FuncoesPinout.TMP,
},
DelayAmostragem = 200,
+ Parametros = new List(),
},
new SensorModel()
{
@@ -71,6 +73,7 @@ namespace AgroBase.Models.Modules
FuncoesPinout.TMP,
},
DelayAmostragem = 200,
+ Parametros = new List(),
},
new SensorModel()
{
@@ -86,10 +89,11 @@ namespace AgroBase.Models.Modules
FuncoesPinout.TMP,
},
DelayAmostragem = 200,
+ Parametros = new List(),
},
new SensorModel()
{
- ID = "VBAT ",
+ ID = "VBAT",
Descricao = "Tensão da bateria",
Prioridade = 20,
Componente = S_Code.sTEN,
@@ -98,13 +102,19 @@ namespace AgroBase.Models.Modules
Testando = false,
Funcoes = new List()
{
- FuncoesPinout.Leitura1,
+ FuncoesPinout.Tensao,
+ },
+ DelayAmostragem = 500,
+ Parametros = new List()
+ {
+ new string[] { "V offset", "000.85" },
+ new string[] { "R1", "120000" },
+ new string[] { "R2", "010000" },
},
- DelayAmostragem = 1000,
},
new SensorModel()
{
- ID = "ABAT ",
+ ID = "ABAT",
Prioridade = 10,
Descricao = "Corrente da bateria",
Componente = S_Code.sCOR,
@@ -113,9 +123,14 @@ namespace AgroBase.Models.Modules
Testando = false,
Funcoes = new List()
{
- FuncoesPinout.Leitura1,
+ FuncoesPinout.Corrente,
+ },
+ DelayAmostragem = 500,
+ Parametros = new List()
+ {
+ new string[] { "V offset", "00.413" },
+ new string[] { "Sensibilidade", "000.35" },
},
- DelayAmostragem = 950,
},
}
};
@@ -146,7 +161,7 @@ namespace AgroBase.Models.Modules
}
S_Code TipoSensor = (S_Code)(cod);
- SensorModel Sensor = Sensores.FirstOrDefault(x => x.ID == Dados[1]);
+ SensorModel Sensor = Sensores.FirstOrDefault(x => x.ID == Dados[1].Trim());
if (Sensor == null)
{
if (Dados[1] == "MD")
@@ -162,26 +177,60 @@ namespace AgroBase.Models.Modules
switch (TipoSensor)
{
case S_Code.sCOR:
- double l1 = -1;
- double.TryParse(Dados[2], out l1);
- double l2 = -1;
- double.TryParse(Dados[3], out l2);
- double l3 = -1;
- double.TryParse(Dados[4], out l3);
- double l4 = -1;
- double.TryParse(Dados[5], out l4);
-
+ double leitura = -1;
+ double.TryParse(Dados[2].Replace(".", ","), out leitura);
+ double vPin = -1;
+ double.TryParse(Dados[3].Replace(".", ","), out vPin);
+ double corrente = -1;
+ double.TryParse(Dados[4].Replace(".", ","), out corrente);
+
Sensor.Leituras = new List()
{
- l1,
- l2,
- l3,
- l4
+ leitura,
+ vPin,
+ corrente,
};
+ if (corrente > Sensor.ValorMaximo)
+ {
+ Sensor.ValorMaximo = corrente;
+ }
+ else if (corrente < Sensor.ValorMinimo)
+ {
+ Sensor.ValorMinimo = corrente;
+ }
+
+ frmInstancial.frmAcompanhamento.AtualizarSensores("Corrente atual: " + corrente.ToString("0.00") + "A - Mín: " + Sensor.ValorMinimo.ToString("0.00") + "A - Máx: " + Sensor.ValorMaximo.ToString("0.00") + "A");
+
AtualizaGrafico = true;
break;
case S_Code.sTEN:
+ double leituraV = -1;
+ double.TryParse(Dados[2].Replace(".", ","), out leituraV);
+ double vPinV = -1;
+ double.TryParse(Dados[3].Replace(".", ","), out vPinV);
+ double tensao = -1;
+ double.TryParse(Dados[4].Replace(".", ","), out tensao);
+
+ Sensor.Leituras = new List()
+ {
+ leituraV,
+ vPinV,
+ tensao,
+ };
+
+ if (tensao > Sensor.ValorMaximo)
+ {
+ Sensor.ValorMaximo = tensao;
+ }
+ else if (tensao < Sensor.ValorMinimo)
+ {
+ Sensor.ValorMinimo = tensao;
+ }
+
+ frmInstancial.frmAcompanhamento.AtualizarSensores("Tensão atual: " + tensao.ToString("0.00") + "V - Mín: " + Sensor.ValorMinimo.ToString("0.00") + "V - Máx: " + Sensor.ValorMaximo.ToString("0.00") + "V");
+
+ AtualizaGrafico = true;
break;
case S_Code.sCFG:
@@ -189,31 +238,31 @@ namespace AgroBase.Models.Modules
Sensor.Inicializado = Dados[2] == "1";
break;
}
- case S_Code.sTMP: {
- double temp = -1;
- double.TryParse(Dados[2].Replace(".", ","), out temp);
- Sensor.Leituras = new List() { temp };
- if (temp > Sensor.ValorMaximo)
- {
- Sensor.ValorMaximo = temp;
- }
- else if (temp < Sensor.ValorMinimo)
- {
- Sensor.ValorMinimo = temp;
- }
-
- MovSensoriamentoMotor Motor =
- Variaveis.DispositivosConectados.Any(x => x.Dispositivo == T_Code.Mov) ?
- ((MovimentacaoModel)(Variaveis.DispositivosConectados.FirstOrDefault(x => x.Dispositivo == T_Code.Mov).Dados)).Motores.FirstOrDefault(x => Sensor.ID.Contains(x.ID)) :
- null;
- if (Motor != null)
- {
- Motor.Temperatura = temp;
- }
-
- AtualizaGrafico = true;
- break;
+ case S_Code.sTMP: {
+ double temp = -1;
+ double.TryParse(Dados[2].Replace(".", ","), out temp);
+ Sensor.Leituras = new List() { temp };
+ if (temp > Sensor.ValorMaximo)
+ {
+ Sensor.ValorMaximo = temp;
}
+ else if (temp < Sensor.ValorMinimo)
+ {
+ Sensor.ValorMinimo = temp;
+ }
+
+ MovSensoriamentoMotor Motor =
+ Variaveis.DispositivosConectados.Any(x => x.Dispositivo == T_Code.Mov) ?
+ ((MovimentacaoModel)(Variaveis.DispositivosConectados.FirstOrDefault(x => x.Dispositivo == T_Code.Mov).Dados)).Motores.FirstOrDefault(x => Sensor.ID.Contains(x.ID)) :
+ null;
+ if (Motor != null)
+ {
+ Motor.Temperatura = temp;
+ }
+
+ AtualizaGrafico = true;
+ break;
+ }
}
@@ -325,6 +374,7 @@ namespace AgroBase.Models.Modules
public bool Inicializado { get; set; } = false;
public bool Testando { get; set; } = false;
public List Funcoes { get; set; }
+ public List Parametros { get; set;} = new List();
public string UnidadeMedida { get; set; }
public List Leituras { get; set; }
@@ -336,13 +386,17 @@ namespace AgroBase.Models.Modules
{
var _pinout = SensoriamentoModel.Pinout.Where(x => x.ComponenteID == ID).ToList();
string Protocolo = ((int)F_Code.Cfg).ToString() +
- ID + ";" + // 0 ~ 4
+ ID.PadRight(5, ' ') + ";" + // 0 ~ 4
(Conectar ? "1" : "0") + ";" + // 6
((int)Componente).ToString() + ";" + // 8 ~ 10
(Aferir ? "1" : "0") + ";" + // 12
DelayAmostragem.ToString("00000") + ";" + // 14 ~ 18
Prioridade.ToString("00") + ";" + // 20 ~ 21
(_pinout.Any(x => x.Funcao != FuncoesPinout.NaoConectado) ? _pinout.FirstOrDefault(x => x.Funcao != FuncoesPinout.NaoConectado).Pino.ToString("00") : "-1"); // 23 ~ 24
+ foreach (var Parametro in Parametros)
+ {
+ Protocolo += ";" + Parametro[1];
+ }
return Protocolo;
}
}
diff --git a/AgroBase/AgroBase/Services/DispositivosService.cs b/AgroBase/AgroBase/Services/DispositivosService.cs
index 80f4968ba..c88e978ea 100644
--- a/AgroBase/AgroBase/Services/DispositivosService.cs
+++ b/AgroBase/AgroBase/Services/DispositivosService.cs
@@ -1,6 +1,7 @@
using AgroBase.Forms;
using AgroBase.Forms.Direcional;
using AgroBase.Forms.Movimentacao;
+using AgroBase.Forms.Sensoriamento;
using AgroBase.Models;
using AgroBase.Models.Modules;
using AgroBase.Services;
@@ -198,7 +199,7 @@ namespace AgroBase.Comum
break;
case T_Code.Sen:
Dados = CarregarParametros(SensoriamentoModel.CarregarParametrosIniciais());
- //frmConfig = new frmSenConfig2();
+ frmConfig = new frmSenConfig();
break;
case T_Code.Atu:
Dados = CarregarParametros(AtuadorModel.CarregarParametrosIniciais());
diff --git a/AgroBase/AgroBase/bin/Debug/AgroBase.pdb b/AgroBase/AgroBase/bin/Debug/AgroBase.pdb
index 5ab82d987..bc8117a89 100644
Binary files a/AgroBase/AgroBase/bin/Debug/AgroBase.pdb and b/AgroBase/AgroBase/bin/Debug/AgroBase.pdb differ
diff --git a/AgroBase/AgroBase/bin/Debug/parametersSen.par b/AgroBase/AgroBase/bin/Debug/parametersSen.par
index 9b763898a..ab1d39c3d 100644
--- a/AgroBase/AgroBase/bin/Debug/parametersSen.par
+++ b/AgroBase/AgroBase/bin/Debug/parametersSen.par
@@ -1 +1 @@
-{"Conectado":false,"Sensores":[{"LogGrafico":[],"ID":"TMVET","Prioridade":0,"Descricao":"Temperatura Motor Esquerdo Trás","Componente":411,"Aferir":true,"DelayAmostragem":200,"Inicializado":false,"Testando":false,"Funcoes":[12],"UnidadeMedida":null,"Leituras":[33.78],"ValorMinimo":0.0,"ValorMaximo":23935.0},{"LogGrafico":[],"ID":"TMVEF","Prioridade":0,"Descricao":"Temperatura Motor Esquerdo Frente","Componente":411,"Aferir":true,"DelayAmostragem":200,"Inicializado":false,"Testando":false,"Funcoes":[12],"UnidadeMedida":null,"Leituras":[29.35],"ValorMinimo":-27315.0,"ValorMaximo":12833.0},{"LogGrafico":[],"ID":"TMVDT","Prioridade":0,"Descricao":"Temperatura Motor Direito Trás","Componente":411,"Aferir":true,"DelayAmostragem":200,"Inicializado":false,"Testando":false,"Funcoes":[12],"UnidadeMedida":null,"Leituras":[29.69],"ValorMinimo":-27315.0,"ValorMaximo":7745.0},{"LogGrafico":[],"ID":"TMVDF","Prioridade":0,"Descricao":"Temperatura Motor Direito Frente","Componente":411,"Aferir":true,"DelayAmostragem":200,"Inicializado":false,"Testando":false,"Funcoes":[12],"UnidadeMedida":null,"Leituras":[30.38],"ValorMinimo":-27315.0,"ValorMaximo":7936.0},{"LogGrafico":[],"ID":"VBAT ","Prioridade":20,"Descricao":"Tensão da bateria","Componente":112,"Aferir":false,"DelayAmostragem":1000,"Inicializado":false,"Testando":false,"Funcoes":[23],"UnidadeMedida":null,"Leituras":null,"ValorMinimo":0.0,"ValorMaximo":0.0},{"LogGrafico":[],"ID":"ABAT ","Prioridade":10,"Descricao":"Corrente da bateria","Componente":322,"Aferir":false,"DelayAmostragem":950,"Inicializado":false,"Testando":false,"Funcoes":[23],"UnidadeMedida":null,"Leituras":null,"ValorMinimo":0.0,"ValorMaximo":0.0}]}
\ No newline at end of file
+{"Conectado":false,"Sensores":[{"LogGrafico":[],"ID":"TMVET","Prioridade":0,"Descricao":"Temperatura Motor Esquerdo Trás","Componente":411,"Aferir":false,"DelayAmostragem":200,"Inicializado":false,"Testando":false,"Funcoes":[12],"Parametros":[],"UnidadeMedida":null,"Leituras":null,"ValorMinimo":0.0,"ValorMaximo":0.0},{"LogGrafico":[],"ID":"TMVEF","Prioridade":0,"Descricao":"Temperatura Motor Esquerdo Frente","Componente":411,"Aferir":false,"DelayAmostragem":200,"Inicializado":false,"Testando":false,"Funcoes":[12],"Parametros":[],"UnidadeMedida":null,"Leituras":null,"ValorMinimo":0.0,"ValorMaximo":0.0},{"LogGrafico":[],"ID":"TMVDT","Prioridade":0,"Descricao":"Temperatura Motor Direito Trás","Componente":411,"Aferir":false,"DelayAmostragem":200,"Inicializado":false,"Testando":false,"Funcoes":[12],"Parametros":[],"UnidadeMedida":null,"Leituras":null,"ValorMinimo":0.0,"ValorMaximo":0.0},{"LogGrafico":[],"ID":"TMVDF","Prioridade":0,"Descricao":"Temperatura Motor Direito Frente","Componente":411,"Aferir":false,"DelayAmostragem":200,"Inicializado":false,"Testando":false,"Funcoes":[12],"Parametros":[],"UnidadeMedida":null,"Leituras":null,"ValorMinimo":0.0,"ValorMaximo":0.0},{"LogGrafico":[],"ID":"VBAT","Prioridade":20,"Descricao":"Tensão da bateria","Componente":112,"Aferir":true,"DelayAmostragem":500,"Inicializado":false,"Testando":false,"Funcoes":[28],"Parametros":[["V offset","000.85"],["R1","120000"],["R2","010000"]],"UnidadeMedida":null,"Leituras":[711.3,0.64,8.3],"ValorMinimo":0.0,"ValorMaximo":13.73},{"LogGrafico":[],"ID":"ABAT","Prioridade":10,"Descricao":"Corrente da bateria","Componente":322,"Aferir":true,"DelayAmostragem":500,"Inicializado":false,"Testando":false,"Funcoes":[29],"Parametros":[["V offset","00.370"],["Sensibilidade","000.35"]],"UnidadeMedida":null,"Leituras":[482.8,0.39,0.05],"ValorMinimo":-0.87,"ValorMaximo":0.23}]}
\ No newline at end of file
diff --git a/AgroBase/AgroBase/bin/Debug/pinoutSen.pin b/AgroBase/AgroBase/bin/Debug/pinoutSen.pin
index 20fef6a16..2e0806c19 100644
--- a/AgroBase/AgroBase/bin/Debug/pinoutSen.pin
+++ b/AgroBase/AgroBase/bin/Debug/pinoutSen.pin
@@ -1 +1 @@
-[{"Tipo":1,"Pino":99,"Descricao":"1","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":98,"Descricao":"2","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":36,"Descricao":"3","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":39,"Descricao":"4","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":34,"Descricao":"5","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":35,"Descricao":"6","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":32,"Descricao":"7","Funcao":12,"Habilitado":true,"ComponenteID":"TMVET"},{"Tipo":1,"Pino":33,"Descricao":"8","Funcao":12,"Habilitado":true,"ComponenteID":"TMVEF"},{"Tipo":1,"Pino":25,"Descricao":"9","Funcao":12,"Habilitado":true,"ComponenteID":"TMVDT"},{"Tipo":1,"Pino":26,"Descricao":"10","Funcao":12,"Habilitado":true,"ComponenteID":"TMVDF"},{"Tipo":1,"Pino":27,"Descricao":"11","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":14,"Descricao":"12","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":12,"Descricao":"13","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":97,"Descricao":"14","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":13,"Descricao":"15","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":9,"Descricao":"16","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":10,"Descricao":"17","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":11,"Descricao":"18","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":96,"Descricao":"19","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":6,"Descricao":"26","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":7,"Descricao":"27","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":8,"Descricao":"28","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":15,"Descricao":"29","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":2,"Descricao":"30","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":0,"Descricao":"31","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":4,"Descricao":"32","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":16,"Descricao":"33","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":17,"Descricao":"34","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":5,"Descricao":"35","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":18,"Descricao":"36","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":19,"Descricao":"37","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":95,"Descricao":"38","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":21,"Descricao":"39","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":3,"Descricao":"40","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":1,"Descricao":"41","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":22,"Descricao":"42","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":23,"Descricao":"43","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":94,"Descricao":"44","Funcao":0,"Habilitado":true,"ComponenteID":""}]
\ No newline at end of file
+[{"Tipo":1,"Pino":99,"Descricao":"1","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":98,"Descricao":"2","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":36,"Descricao":"3","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":39,"Descricao":"4","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":34,"Descricao":"5","Funcao":12,"Habilitado":true,"ComponenteID":"TMVET"},{"Tipo":1,"Pino":35,"Descricao":"6","Funcao":12,"Habilitado":true,"ComponenteID":"TMVEF"},{"Tipo":1,"Pino":32,"Descricao":"7","Funcao":12,"Habilitado":true,"ComponenteID":"TMVDT"},{"Tipo":1,"Pino":33,"Descricao":"8","Funcao":12,"Habilitado":true,"ComponenteID":"TMVDF"},{"Tipo":1,"Pino":25,"Descricao":"9","Funcao":29,"Habilitado":true,"ComponenteID":"ABAT"},{"Tipo":1,"Pino":26,"Descricao":"10","Funcao":28,"Habilitado":true,"ComponenteID":"VBAT"},{"Tipo":1,"Pino":27,"Descricao":"11","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":14,"Descricao":"12","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":12,"Descricao":"13","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":97,"Descricao":"14","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":13,"Descricao":"15","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":9,"Descricao":"16","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":10,"Descricao":"17","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":11,"Descricao":"18","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":96,"Descricao":"19","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":6,"Descricao":"26","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":7,"Descricao":"27","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":8,"Descricao":"28","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":15,"Descricao":"29","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":2,"Descricao":"30","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":0,"Descricao":"31","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":4,"Descricao":"32","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":16,"Descricao":"33","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":17,"Descricao":"34","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":5,"Descricao":"35","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":18,"Descricao":"36","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":19,"Descricao":"37","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":95,"Descricao":"38","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":21,"Descricao":"39","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":3,"Descricao":"40","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":1,"Descricao":"41","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Tipo":1,"Pino":22,"Descricao":"42","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":23,"Descricao":"43","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Tipo":1,"Pino":94,"Descricao":"44","Funcao":0,"Habilitado":true,"ComponenteID":""}]
\ No newline at end of file
diff --git a/AgroBase/AgroBase/obj/Debug/AgroBase.Forms.Sensoriamento.frmSenConfig.resources b/AgroBase/AgroBase/obj/Debug/AgroBase.Forms.Sensoriamento.frmSenConfig.resources
new file mode 100644
index 000000000..6c05a9776
Binary files /dev/null and b/AgroBase/AgroBase/obj/Debug/AgroBase.Forms.Sensoriamento.frmSenConfig.resources differ
diff --git a/AgroBase/AgroBase/obj/Debug/AgroBase.csproj.CoreCompileInputs.cache b/AgroBase/AgroBase/obj/Debug/AgroBase.csproj.CoreCompileInputs.cache
index 0f711e8ec..05b44e3c8 100644
--- a/AgroBase/AgroBase/obj/Debug/AgroBase.csproj.CoreCompileInputs.cache
+++ b/AgroBase/AgroBase/obj/Debug/AgroBase.csproj.CoreCompileInputs.cache
@@ -1 +1 @@
-5282e2e8323b29ea19e29f87e03985324ecefc8410e637b6614d0e3935fd65df
+522c469433cd27a9bb1c105d2bee798bc5682bc54372eaac60a028a8592b0825
diff --git a/AgroBase/AgroBase/obj/Debug/AgroBase.csproj.FileListAbsolute.txt b/AgroBase/AgroBase/obj/Debug/AgroBase.csproj.FileListAbsolute.txt
index 39801dd37..1eb67f477 100644
--- a/AgroBase/AgroBase/obj/Debug/AgroBase.csproj.FileListAbsolute.txt
+++ b/AgroBase/AgroBase/obj/Debug/AgroBase.csproj.FileListAbsolute.txt
@@ -361,3 +361,4 @@ C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.pdb
C:\ZendionInc\agrobot_base\AgroBase\AgroBase\bin\Debug\Python\Scripts\gps-viewer.py
C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.Forms.frmGPS.resources
C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.Forms.frmPinout.resources
+C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.Forms.Sensoriamento.frmSenConfig.resources
diff --git a/AgroBase/AgroBase/obj/Debug/AgroBase.csproj.GenerateResource.cache b/AgroBase/AgroBase/obj/Debug/AgroBase.csproj.GenerateResource.cache
index b3276ae3c..61ff368db 100644
Binary files a/AgroBase/AgroBase/obj/Debug/AgroBase.csproj.GenerateResource.cache and b/AgroBase/AgroBase/obj/Debug/AgroBase.csproj.GenerateResource.cache differ
diff --git a/AgroBase/AgroBase/obj/Debug/AgroBase.pdb b/AgroBase/AgroBase/obj/Debug/AgroBase.pdb
index 5ab82d987..bc8117a89 100644
Binary files a/AgroBase/AgroBase/obj/Debug/AgroBase.pdb and b/AgroBase/AgroBase/obj/Debug/AgroBase.pdb differ
diff --git a/AgroBase/AgroBase/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/AgroBase/AgroBase/obj/Debug/DesignTimeResolveAssemblyReferences.cache
index d588532f4..31289b2d2 100644
Binary files a/AgroBase/AgroBase/obj/Debug/DesignTimeResolveAssemblyReferences.cache and b/AgroBase/AgroBase/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ
diff --git a/Firmware/Modulos/Atuador/Atuador.ino b/Firmware/Modulos/Atuador/Atuador.ino
index 446caff8c..91db1eddc 100644
--- a/Firmware/Modulos/Atuador/Atuador.ino
+++ b/Firmware/Modulos/Atuador/Atuador.ino
@@ -1,8 +1,8 @@
// Dispositivo: Atuador
// Versão Firmware: 1
-// Ultima atualização: 22/12/2023
+// Ultima atualização: 23/01/2024
-#include "C:\Zendion Inc\agrobot_base\Firmware\Modulos\SerialService.h"
+#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SerialService.h"
#define D_Code Atu
#define _pinoLED RGB_BUILTIN
@@ -14,6 +14,7 @@ bool Conectado = false;
int _TaxaAmostragem = 500;
int BicosAtivos = 10;
+bool BicoLigado = false;
class BicoPulverizador {
public:
@@ -36,7 +37,7 @@ public:
bool StatusBico;
// Entrada de dados
- bool _BicoAtuado = false;
+ bool _BicoAtuado = !BicoLigado;
void Inicializar() {
if (Iniciado) {
@@ -47,9 +48,9 @@ public:
if (_pinoSolenoide > -1) {
pinMode(_pinoSolenoide, OUTPUT);
- digitalWrite(_pinoSolenoide, LOW);
- _BicoAtuado = false;
- StatusBico = digitalRead(_pinoSolenoide) == 1;
+ _BicoAtuado = !BicoLigado;
+ digitalWrite(_pinoSolenoide, _BicoAtuado);
+ StatusBico = digitalRead(_pinoSolenoide) == (BicoLigado ? 1 : 0);
}
if (_pinoSensor > -1) {
pinMode(_pinoSensor, INPUT);
@@ -88,7 +89,7 @@ public:
void AlterarStatusBico() {
digitalWrite(_pinoSolenoide, _BicoAtuado);
- StatusBico = digitalRead(_pinoSolenoide) == 1;
+ StatusBico = digitalRead(_pinoSolenoide) == (BicoLigado ? 1 : 0);
}
@@ -151,9 +152,20 @@ BicoPulverizador* BicoPorID(String ID) {
return _bico;
}
+void ZerarPinos() {
+ const int gpios[] = {2, 4, 5, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 25, 26, 27, 32, 33};
+
+ for (int i = 0; i < sizeof(gpios) / sizeof(gpios[0]); i++) {
+ pinMode(gpios[i], OUTPUT);
+ digitalWrite(gpios[i], !BicoLigado);
+ }
+}
+
void setup() {
Serial.begin(_baudRate);
+ ZerarPinos();
+
if (_pinoReleGeral > -1) {
pinMode(_pinoReleGeral, OUTPUT);
digitalWrite(_pinoReleGeral, LOW);
@@ -231,7 +243,7 @@ void loop() {
BicoPulverizador* _bico = BicoPorID(ID);
- _bico->_BicoAtuado = (String)Protocolo[4] == "1";
+ _bico->_BicoAtuado = (String)Protocolo[4] == (BicoLigado ? "1" : "0");
_bico->AlterarStatusBico();
}
else if (_funcao == Tst) {
diff --git a/Firmware/Modulos/Direcional/Direcional.ino b/Firmware/Modulos/Direcional/Direcional.ino
index 6960ae60e..ca2965597 100644
--- a/Firmware/Modulos/Direcional/Direcional.ino
+++ b/Firmware/Modulos/Direcional/Direcional.ino
@@ -488,6 +488,16 @@ Motor M2("EF");
Motor M3("DT");
Motor M4("DF");
+Motor* MotorPorID(String ID) {
+ Motor* _motor =
+ ID == "ET" ? &M1 :
+ ID == "EF" ? &M2 :
+ ID == "DT" ? &M3 :
+ ID == "DF" ? &M4 :
+ nullptr;
+ return _motor;
+}
+
void setup() {
Serial.begin(_baudRate);
@@ -543,7 +553,7 @@ void loop() {
EnviarDadosSerial(MontarProtocoloSensor(sCFG, "MD", Conectado ? "1" : "0"));
}
else {
- Motor* _motor = ID == "ET" ? &M1 : ID == "EF" ? &M2 : ID == "DT" ? &M3 : &M4;
+ Motor* _motor = MotorPorID(ID);
int canal = ((String)Protocolo[5]).toInt();
bool motor_ativado = ((String)Protocolo[7]) == "1";
@@ -587,7 +597,7 @@ void loop() {
//0;0;000.00
String ID = ((String)Protocolo[0] + (String)Protocolo[1]);
- Motor* _motor = ID == "ET" ? &M1 : ID == "EF" ? &M2 : ID == "DT" ? &M3 : &M4;
+ Motor* _motor = MotorPorID(ID);
Sentido sentido = (Sentido)((String)Protocolo[3]).toInt();
int angulo = ((String)Protocolo[5] + (String)Protocolo[6] + (String)Protocolo[7]).toInt();
@@ -614,7 +624,7 @@ void loop() {
else if (_funcao == Tst) {
String ID = ((String)Protocolo[0] + (String)Protocolo[1]);
- Motor* _motor = ID == "ET" ? &M1 : ID == "EF" ? &M2 : ID == "DT" ? &M3 : &M4;
+ Motor* _motor = MotorPorID(ID);
bool EmTeste = _motor->Testando;
if (!EmTeste) {
diff --git a/Firmware/Modulos/Movimentacao/Movimentacao.ino b/Firmware/Modulos/Movimentacao/Movimentacao.ino
index fc37c693f..a1c949081 100644
--- a/Firmware/Modulos/Movimentacao/Movimentacao.ino
+++ b/Firmware/Modulos/Movimentacao/Movimentacao.ino
@@ -1,12 +1,10 @@
// Dispositivo: Movimentação
-// Versão Firmware: 9
-// Ultima atualização: 21/11/2023
+// Versão Firmware: 14
+// Ultima atualização: 16/01/2024
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SerialService.h"
-#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\MemoryService.h"
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\utils.h"
#include
-#include "DHT.h"
#define D_Code Mov
#define _pinoLED RGB_BUILTIN
@@ -23,17 +21,11 @@ int RampaMin = 0;
int ZeroRampa = 0;
int RampaMax = 1023;
-int M1_US_Addr = 25;
-int M2_US_Addr = 35;
-int M3_US_Addr = 45;
-int M4_US_Addr = 55;
-
class Motor {
public:
// Construtor
- Motor(String desc, int SentidoAddr) {
+ Motor(String desc) {
_ID = desc;
- _US_Addr = SentidoAddr;
}
// Definições
@@ -46,7 +38,6 @@ public:
int _pinoHLA;
int _pinoHLB;
int _pinoHLC;
- int _pinoTMP;
double _Kp;
double _Ki;
@@ -67,12 +58,11 @@ public:
double RPM;
double PotenciaAtual;
volatile int ultimaLeituraHallA = 0;
+ volatile int ultimaLeituraHallB = 0;
+ volatile int ultimaLeituraHallC = 0;
volatile unsigned int tempoAnterior = 0;
volatile float periodo = 0;
- // Sensores
- DHT* dht;
-
// Entrada de dados
bool _MalhaFechada;
int _PotMap;
@@ -103,7 +93,7 @@ public:
pinMode(_pinoDIR, OUTPUT);
digitalWrite(_pinoDIR, LOW);
- _SentidoM = (Sentido)LerMemoria(_US_Addr);
+ _SentidoM = Parado;
}
if (_pinoBRK > -1) {
pinMode(_pinoBRK, OUTPUT);
@@ -131,14 +121,11 @@ public:
}
if (_pinoHLB > -1) {
pinMode(_pinoHLB, INPUT);
+ ultimaLeituraHallB = digitalRead(_pinoHLB);
}
if (_pinoHLC > -1) {
pinMode(_pinoHLC, INPUT);
- }
- if (_pinoTMP > -1) {
- dht = new DHT(_pinoTMP, DHT22);
- dht->begin();
- xTaskCreatePinnedToCore(&Motor::DHT22TaskWrapper, "DHT22Task", 10000, this, 17 - _canal, &DHT22TaskHandle, tskNO_AFFINITY);
+ ultimaLeituraHallC = digitalRead(_pinoHLC);
}
@@ -163,9 +150,6 @@ public:
if (_pinoHLA > -1) {
vTaskDelete(RPMTaskHandle);
}
- if (_pinoTMP > -1) {
- vTaskDelete(DHT22TaskHandle);
- }
// Desanexar o canal PWM
if (_pinoPWM > -1) {
@@ -180,7 +164,6 @@ public:
pinMode(_pinoHLA, INPUT);
pinMode(_pinoHLB, INPUT);
pinMode(_pinoHLC, INPUT);
- pinMode(_pinoTMP, INPUT);
// Outras redefinições de variáveis de estado, se necessário
delete _PID;
@@ -208,7 +191,6 @@ public:
void ReverterSentidoGiro() {
_SentidoM = _SentidoM == Horario ? Antihorario : Horario;
- GravarMemoria(_US_Addr, (int)_SentidoM);
}
private:
@@ -234,7 +216,7 @@ private:
}
// Medir RPM apenas quando ocorrer um pulso no sensor HALL
- int LeituraHa = digitalRead(_pinoHLA);
+ bool LeituraHa = digitalRead(_pinoHLA) == 1;
if (LeituraHa != ultimaLeituraHallA) {
ultimaLeituraHallA = LeituraHa;
pulsos++;
@@ -320,10 +302,10 @@ private:
// Comparação das leituras atuais com as leituras anteriores
if (LeituraHa == LeituraAnteriorHc && LeituraHc == LeituraAnteriorHa) {
- _Sentido = Horario;
+ _Sentido = Antihorario;
}
else if (LeituraHa == LeituraAnteriorHb && LeituraHb == LeituraAnteriorHa) {
- _Sentido = Antihorario;
+ _Sentido = Horario;
}
else {
// Outros casos (não determinados)
@@ -386,7 +368,7 @@ private:
}
void RampaTask() {
- unsigned long previousMillisRampa = millis();
+ unsigned long firstMilis = millis();
while (1)
{
if (!Conectado) {
@@ -416,15 +398,15 @@ private:
Revertendo = _SentidoSP != Parado && _SentidoSP != _SentidoM;
if (Revertendo) {
- digitalWrite(_pinoDIR, HIGH);
- vTaskDelay(1500);
- digitalWrite(_pinoDIR, LOW);
+ ledcWrite(_canal, ZeroRampa);
+ vTaskDelay(400);
_SentidoM = _SentidoSP;
- GravarMemoria(_US_Addr, (int)_SentidoM);
Revertendo = false;
}
+
+ digitalWrite(_pinoDIR, _SentidoSP == Horario);
}
if (_pinoBRK > -1) {
@@ -444,62 +426,27 @@ private:
}
}
-
- // TEMPERATURA E UMIDADE
- TaskHandle_t DHT22TaskHandle = NULL;
- static void DHT22TaskWrapper(void *pvParameters) {
- Motor *motor = static_cast(pvParameters);
- motor->DHT22Task();
- }
-
- void DHT22Task() {
- unsigned long firstMilis = millis();
- while (1)
- {
- if (!Conectado) {
- vTaskDelay(1000);
- continue;
- }
-
- long intMillis = (millis() - firstMilis);
-
- if (intMillis >= _TaxaAmostragem + 2000) {
-
- float t = dht->readTemperature();
- yield();
- vTaskDelay(500);
- float h = dht->readHumidity();
- yield();
- vTaskDelay(500);
- float hic = dht->computeHeatIndex(t, h, false);
- yield();
- vTaskDelay(500);
-
- EnviarDadosSerial(MontarProtocoloSensor(sTMP, _ID, MontarDadosProtocoloDHT22(t, h, hic)));
- firstMilis = millis();
- }
-
- vTaskDelay(100);
- }
- }
-
};
-Motor M1("ET", M1_US_Addr);
-Motor M2("EF", M2_US_Addr);
-Motor M3("DT", M3_US_Addr);
-Motor M4("DF", M4_US_Addr);
+Motor M1("ET");
+Motor M2("EF");
+Motor M3("DT");
+Motor M4("DF");
+
+Motor* MotorPorID(String ID) {
+ Motor* _motor =
+ ID == "ET" ? &M1 :
+ ID == "EF" ? &M2 :
+ ID == "DT" ? &M3 :
+ ID == "DF" ? &M4 :
+ nullptr;
+ return _motor;
+}
void setup() {
Serial.begin(_baudRate);
- IniciarMemoria();
delay(10);
- /*LimparMemoria();
- GravarMemoria(M1_US_Addr, (int)Horario);
- GravarMemoria(M2_US_Addr, (int)Antihorario);
- GravarMemoria(M3_US_Addr, (int)Antihorario);
- GravarMemoria(M4_US_Addr, (int)Horario);*/
if (_pinoReleGeral > -1) {
pinMode(_pinoReleGeral, OUTPUT);
@@ -569,9 +516,8 @@ void loop() {
int hallA = ((String)Protocolo[41] + (String)Protocolo[42]).toInt();
int hallB = ((String)Protocolo[44] + (String)Protocolo[45]).toInt();
int hallC = ((String)Protocolo[47] + (String)Protocolo[48]).toInt();
- int tmp = ((String)Protocolo[50] + (String)Protocolo[51]).toInt();
- Motor* _motor = ID == "ET" ? &M1 : ID == "EF" ? &M2 : ID == "DT" ? &M3 : &M4;
+ Motor* _motor = MotorPorID(ID);
if (motor_ativado) {
if (Conectar) {
_motor->_canal = canal;
@@ -582,7 +528,6 @@ void loop() {
_motor->_pinoHLA = hallA;
_motor->_pinoHLB = hallB;
_motor->_pinoHLC = hallC;
- _motor->_pinoTMP = tmp;
_motor->_MalhaFechada = _foc;
_motor->_Kp = _Kp;
_motor->_Ki = _Ki;
@@ -602,7 +547,7 @@ void loop() {
//0;000;0;000;000;000
String ID = ((String)Protocolo[0] + (String)Protocolo[1]);
- Motor* _motor = ID == "ET" ? &M1 : ID == "EF" ? &M2 : ID == "DT" ? &M3 : &M4;
+ Motor* _motor = MotorPorID(ID);
_motor->_SentidoSP = (Sentido)((String)Protocolo[3]).toInt();
_motor->_RPM_SP = ((String)Protocolo[5] + (String)Protocolo[6] + (String)Protocolo[7]).toInt();
@@ -617,7 +562,7 @@ void loop() {
else if (_funcao == Tst) {
String ID = ((String)Protocolo[0] +(String)Protocolo[1]);
- Motor* _motor = ID == "ET" ? &M1 : ID == "EF" ? &M2 : ID == "DT" ? &M3 : &M4;
+ Motor* _motor = MotorPorID(ID);
bool EmTeste = _motor->Testando;
if (!EmTeste) {
diff --git a/Firmware/Modulos/Sensoriamento/Sensoriamento.ino b/Firmware/Modulos/Sensoriamento/Sensoriamento.ino
index e6c83eea0..48249e3c8 100644
--- a/Firmware/Modulos/Sensoriamento/Sensoriamento.ino
+++ b/Firmware/Modulos/Sensoriamento/Sensoriamento.ino
@@ -1,8 +1,11 @@
// Dispositivo: Sensoriamento
-// Versão Firmware: 1
-// Ultima atualização: 28/11/2023
+// Versão Firmware: 3
+// Ultima atualização: 23/01/2024
+
+#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SerialService.h"
+
+#include
-#include "C:\Zendion Inc\agrobot_base\Firmware\Modulos\SerialService.h"
#define D_Code Sen
#define _pinoLED RGB_BUILTIN
@@ -15,140 +18,369 @@ int _TaxaAmostragem;
int FrequenciaMaxima = 10000;
-class Sensor {
-public:
- // Construtor
- Sensor(String desc) {
- _ID = desc;
- }
-
- // Definições
- String _ID;
- S_Code _componente;
- int _prioridade;
- int _delayAmostragem;
- bool _I2C;
- int _pinoLeitura1;
- int _pinoLeitura2;
- int _pinoLeitura3;
- int _pinoLeitura4;
-
- bool Iniciado = false;
- bool Testando = false;
-
- // Consumo
-
- // Entrada de dados
-
-
- void Inicializar() {
- if (Iniciado) {
- EnviarDadosSerial(_ID + " ja inicializado");
- EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
- return;
+class SensorTemperatura {
+ public:
+ SensorTemperatura(String desc) {
+ _ID = desc;
}
- if (_pinoLeitura1 > -1) {
- pinMode(_pinoLeitura1, INPUT);
- }
- if (_pinoLeitura2 > -1) {
- pinMode(_pinoLeitura2, INPUT);
- }
- if (_pinoLeitura3 > -1) {
- pinMode(_pinoLeitura3, INPUT);
- }
- if (_pinoLeitura4 > -1) {
- pinMode(_pinoLeitura4, INPUT);
- }
-
+ // Definições
+ String _ID;
+ S_Code _componente = sTMP;
+ int _pino;
+ int _delayAmostragem;
+ int _prioridade;
- xTaskCreatePinnedToCore(&Sensor::LeituraTaskWrapper, "LeituraTask", 5000, this, _prioridade, &LeituraTaskHandle, tskNO_AFFINITY);
+ bool Iniciado = false;
-
- Iniciado = true;
-
- EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
- }
-
- void Desligar() {
- if (!Iniciado) {
- EnviarDadosSerial(_ID + " nao esta inicializado");
- EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
- return;
- }
-
- // Parar a execução das tarefas
- vTaskDelete(LeituraTaskHandle);
-
- // Redefinir as configurações para os valores iniciais
- if (_pinoLeitura1 > -1) {
- pinMode(_pinoLeitura1, INPUT);
- }
- if (_pinoLeitura2 > -1) {
- pinMode(_pinoLeitura2, INPUT);
- }
- if (_pinoLeitura3 > -1) {
- pinMode(_pinoLeitura3, INPUT);
- }
- if (_pinoLeitura4 > -1) {
- pinMode(_pinoLeitura4, INPUT);
- }
-
-
- EnviarDadosSerial(_ID + " Desligado");
-
- Iniciado = false;
-
- EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
- }
-
- void Testar() {
- Testando = true;
-
- Testando = false;
- }
-
-
-
-private:
-
- TaskHandle_t LeituraTaskHandle = NULL;
- static void LeituraTaskWrapper(void *pvParameters) {
- Sensor *sensor = static_cast(pvParameters);
- sensor->LeituraTask();
- }
-
- void LeituraTask() {
- unsigned long previousMillisLeitura = millis();
-
- while (1)
- {
- if (!Conectado) {
- // Caso não esteja conectado, aguarda 1 segundo até a próxima verificação, liberando uso de CPU
- vTaskDelay(1000);
- continue;
+ void Inicializar() {
+ if (Iniciado) {
+ EnviarDadosSerial(_ID + " ja inicializado");
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
+ return;
}
- // LEITURA AQUI
-
- unsigned long currentMillis = millis();
- if ((currentMillis - previousMillisLeitura) >= (_TaxaAmostragem + _delayAmostragem)) {
- previousMillisLeitura = currentMillis;
-
- EnviarDadosSerial(MontarProtocoloSensor(_componente, _ID, MontarDadosProtocoloSensorGenerico("")));
+ if (_pino > -1) {
+ pinMode(_pino, INPUT);
}
- vTaskDelay(1);
+ xTaskCreatePinnedToCore(&SensorTemperatura::STTaskWrapper, "STTask", 5000, this, _prioridade, &STTaskHandle, tskNO_AFFINITY);
+ EnviarDadosSerial(_ID + " Iniciado");
+
+ Iniciado = true;
+
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
}
- }
+ void Desligar() {
+ if (!Iniciado) {
+ EnviarDadosSerial(_ID + " nao esta inicializado");
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
+ return;
+ }
+
+ // Parar a execução das tarefas
+ vTaskDelete(STTaskHandle);
+
+ // Redefinir as configurações para os valores iniciais
+ pinMode(_pino, INPUT);
+
+ EnviarDadosSerial(_ID + " Desligado");
+
+ Iniciado = false;
+
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
+ }
+
+ private:
+
+ // Variáveis
+ double Vs = 3.3; // TENSÃO DE SAIDA DO ESP32
+ double R1 = 10000; //RESISTOR UTILIZADO NO DIVISOR DE TENSÃO
+ double Beta = 3950; // VALOR DE BETA
+ double To = 298.15; // VALOR EM KELVIN REFERENTE A 25° CELSIUS
+ double Ro = 10000;
+ double adcMax = 4095.0;
+
+ TaskHandle_t STTaskHandle = NULL;
+ static void STTaskWrapper(void *pvParameters) {
+ SensorTemperatura *sensor = static_cast(pvParameters);
+ sensor->STTask();
+ }
+
+ void STTask() {
+ unsigned long firstMilis = millis();
+ while (1)
+ {
+ if (!Conectado) {
+ // Caso não esteja conectado, aguarda 1 segundo até a próxima verificação, liberando uso de CPU
+ vTaskDelay(1000);
+ continue;
+ }
+
+ long intMillis = (millis() - firstMilis);
+
+ // A cada _TaxaAmostragem, enviar os dados para o software
+ if (intMillis >= (_TaxaAmostragem + _delayAmostragem)) {
+ AferirTemperatura();
+
+ firstMilis = millis();
+ }
+
+ // Aguarda metade do menor período possível entre leituras
+ vTaskDelay(1);
+ }
+ }
+
+ void AferirTemperatura() {
+ double Vout, Rt = 0;
+ double T, Tc, Tf, adc = 0;
+ adc = analogRead(_pino); // VARIÁVEL QUE RECEBE A LEITURA DO NTC10K
+ //float adcValue = tempKalman->updateEstimate(adc);
+ float adcValue = adc;
+ //CALCULOS PARA CONVERSÃO DA LEITURA RECEBIDA PELO ESP32 EM TEMPERATURA EM °C
+ Vout = adcValue * Vs / adcMax;
+ Rt = R1 * Vout / (Vs - Vout);
+ T = 1 / (1 / To + log(Rt / Ro) / Beta);
+ Tc = T - 273.15;
+ Tf = Tc * 9 / 5 + 32;
+
+ EnviarDadosSerial(MontarProtocoloSensor(sTMP, _ID, MontarDadosProtocoloNTC10K(Tc)));
+ }
+};
+
+class SensorTensao {
+ public:
+ SensorTensao(String desc) {
+ _ID = desc;
+ }
+
+ // Variáveis
+ const float Vcc = 3.3; // Tensão de alimentação
+ float Voffset = 0.85;
+ int R1 = 47000;
+ int R2 = 10000;
+
+ // Definições
+ String _ID;
+ S_Code _componente = sTEN;
+ int _pino;
+ int _delayAmostragem;
+ int _prioridade;
+
+ SimpleKalmanFilter* kalmanTEN;
+
+ bool Iniciado = false;
+
+ void Inicializar() {
+ if (Iniciado) {
+ EnviarDadosSerial(_ID + " ja inicializado");
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
+ return;
+ }
+
+ if (_pino > -1) {
+ pinMode(_pino, INPUT);
+ }
+
+ kalmanTEN = new SimpleKalmanFilter(2, 2, 0.01);
+
+ xTaskCreatePinnedToCore(&SensorTensao::SVTaskWrapper, "SVTask", 5000, this, _prioridade, &SVTaskHandle, tskNO_AFFINITY);
+
+ EnviarDadosSerial(_ID + " Iniciado");
+
+ Iniciado = true;
+
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
+ }
+
+ void Desligar() {
+ if (!Iniciado) {
+ EnviarDadosSerial(_ID + " nao esta inicializado");
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
+ return;
+ }
+
+ // Parar a execução das tarefas
+ vTaskDelete(SVTaskHandle);
+
+ // Redefinir as configurações para os valores iniciais
+ pinMode(_pino, INPUT);
+
+ delete kalmanTEN;
+
+ EnviarDadosSerial(_ID + " Desligado");
+
+ Iniciado = false;
+
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
+ }
+
+ private:
+ TaskHandle_t SVTaskHandle = NULL;
+ static void SVTaskWrapper(void *pvParameters) {
+ SensorTensao *sensor = static_cast(pvParameters);
+ sensor->SVTask();
+ }
+
+ void SVTask() {
+ unsigned long firstMilis = millis();
+ while (1)
+ {
+ if (!Conectado) {
+ // Caso não esteja conectado, aguarda 1 segundo até a próxima verificação, liberando uso de CPU
+ vTaskDelay(1000);
+ continue;
+ }
+
+ long intMillis = (millis() - firstMilis);
+
+ // A cada _TaxaAmostragem, enviar os dados para o software
+ if (intMillis >= (_TaxaAmostragem + _delayAmostragem)) {
+ AferirTensao();
+
+ firstMilis = millis();
+ }
+
+ // Aguarda metade do menor período possível entre leituras
+ vTaskDelay(1);
+ }
+ }
+
+ void AferirTensao() {
+ float Razao = (R1 + R2) / (float)R2;
+ int adcV = analogRead(_pino);
+ float adcValueV = kalmanTEN->updateEstimate(adcV);
+
+ float voltageV = (adcValueV * (Vcc / 4095.0)) + (Voffset / Razao); // Convertendo o valor ADC para tensão
+ float realVoltage = voltageV * Razao;
+
+ EnviarDadosSerial(MontarProtocoloSensor(sTEN, _ID, MontarDadosProtocoloTensao(adcValueV, voltageV, realVoltage)));
+ }
};
-Sensor sVBAT("VBAT");
-Sensor sABAT("ABAT");
+class SensorCorrente {
+ public:
+ SensorCorrente(String desc) {
+ _ID = desc;
+ }
+ // Variáveis
+ const float Vcc = 3.3; // Tensão de alimentação
+ float Voffset = 0.413;
+ float sensibilidade = 0.35;
+
+ // Definições
+ String _ID;
+ S_Code _componente = sCOR;
+ int _pino;
+ int _delayAmostragem;
+ int _prioridade;
+
+ SimpleKalmanFilter* kalmanCOR;
+
+ bool Iniciado = false;
+
+ void Inicializar() {
+ if (Iniciado) {
+ EnviarDadosSerial(_ID + " ja inicializado");
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
+ return;
+ }
+
+ if (_pino > -1) {
+ pinMode(_pino, INPUT);
+ }
+
+ kalmanCOR = new SimpleKalmanFilter(2, 2, 0.01);
+
+ xTaskCreatePinnedToCore(&SensorCorrente::SATaskWrapper, "SATask", 5000, this, _prioridade, &SATaskHandle, tskNO_AFFINITY);
+
+ EnviarDadosSerial(_ID + " Iniciado");
+
+ Iniciado = true;
+
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
+ }
+
+ void Desligar() {
+ if (!Iniciado) {
+ EnviarDadosSerial(_ID + " nao esta inicializado");
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
+ return;
+ }
+
+ // Parar a execução das tarefas
+ vTaskDelete(SATaskHandle);
+
+ // Redefinir as configurações para os valores iniciais
+ pinMode(_pino, INPUT);
+
+ delete kalmanCOR;
+
+ EnviarDadosSerial(_ID + " Desligado");
+
+ Iniciado = false;
+
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
+ }
+
+ private:
+ TaskHandle_t SATaskHandle = NULL;
+ static void SATaskWrapper(void *pvParameters) {
+ SensorCorrente *sensor = static_cast(pvParameters);
+ sensor->SATask();
+ }
+
+ void SATask() {
+ unsigned long firstMilis = millis();
+ while (1)
+ {
+ if (!Conectado) {
+ // Caso não esteja conectado, aguarda 1 segundo até a próxima verificação, liberando uso de CPU
+ vTaskDelay(1000);
+ continue;
+ }
+
+ long intMillis = (millis() - firstMilis);
+
+ // A cada _TaxaAmostragem, enviar os dados para o software
+ if (intMillis >= (_TaxaAmostragem + _delayAmostragem)) {
+ AferirCorrente();
+
+ firstMilis = millis();
+ }
+
+ // Aguarda metade do menor período possível entre leituras
+ vTaskDelay(1);
+ }
+ }
+
+ void AferirCorrente() {
+ int adcV = analogRead(_pino);
+ float adcValue = kalmanCOR->updateEstimate(adcV);
+
+ float voltage = adcValue * (Vcc / 4095.0); // Convertendo o valor ADC para tensão
+ float current = (voltage - Voffset) / sensibilidade; // Calculando a corrente em A
+
+ EnviarDadosSerial(MontarProtocoloSensor(sCOR, _ID, MontarDadosProtocoloCorrente(adcValue, voltage, current)));
+ }
+
+};
+
+SensorTemperatura TM1("TMVET");
+SensorTemperatura TM2("TMVEF");
+SensorTemperatura TM3("TMVDT");
+SensorTemperatura TM4("TMVDF");
+SensorTensao VBAT("VBAT ");
+SensorCorrente ABAT("ABAT ");
+
+
+SensorTemperatura* STPorID(String ID) {
+ SensorTemperatura* _sensor =
+ ID == "TMVET" ? &TM1 :
+ ID == "TMVEF" ? &TM2 :
+ ID == "TMVDT" ? &TM3 :
+ ID == "TMVDF" ? &TM4 :
+ nullptr;
+ return _sensor;
+}
+
+SensorTensao* SVPorID(String ID) {
+ SensorTensao* _sensor =
+ ID == "VBAT " ? &VBAT :
+ nullptr;
+ return _sensor;
+}
+
+SensorCorrente* SAPorID(String ID) {
+ SensorCorrente* _sensor =
+ ID == "ABAT " ? &ABAT :
+ nullptr;
+ return _sensor;
+}
void setup() {
Serial.begin(_baudRate);
@@ -176,59 +408,91 @@ void loop() {
if (_funcao == Chk) {
EnviarDadosSerial(MontarProtocoloVerificacao(D_Code));
- }
- else if (_funcao == Cfg) {
- String ID = ((String)Protocolo[0] + (String)Protocolo[1]);
- bool Conectar = (String)Protocolo[3] == "1";
- if (ID == "MD") {
- _TaxaAmostragem = ((String)Protocolo[5] + (String)Protocolo[6] + (String)Protocolo[7] + (String)Protocolo[8] + (String)Protocolo[9]).toInt();
+ } else if (_funcao == Cfg) {
+ String ID = ((String)Protocolo[0] + (String)Protocolo[1] + (String)Protocolo[2] + (String)Protocolo[3] + (String)Protocolo[4]);
+ bool Conectar = (String)Protocolo[6] == "1";
+ if (ID == "MD ") {
+ _TaxaAmostragem = ((String)Protocolo[8] + (String)Protocolo[9] + (String)Protocolo[10] + (String)Protocolo[11] + (String)Protocolo[12]).toInt();
vTaskDelay(pdMS_TO_TICKS(100));
Conectado = Conectar;
-
EnviarDadosSerial(MontarProtocoloSensor(sCFG, "MD", Conectado ? "1" : "0"));
}
else {
- Sensor* _sensor = ID == "VBAT" ? &sVBAT : ID == "ABAT" ? &sABAT : nullptr;
+ S_Code componente = (S_Code)((String)Protocolo[8] + (String)Protocolo[9] + (String)Protocolo[10]).toInt();
+ bool sensor_ativado = (String)Protocolo[12] == "1";
+ int delayAmostragem = ((String)Protocolo[14] + (String)Protocolo[15] + (String)Protocolo[16] + (String)Protocolo[17] + (String)Protocolo[18]).toInt();
+ int prioridade = ((String)Protocolo[20] + (String)Protocolo[21]).toInt();
+ int pino = ((String)Protocolo[23] + (String)Protocolo[24]).toInt();
+
+ switch (componente) {
+ case sTMP: {
+ SensorTemperatura* _sensor = STPorID(ID);
+ if (sensor_ativado) {
+ if (Conectar) {
+ _sensor->_pino = pino;
+ _sensor->_prioridade = prioridade;
+ _sensor->_delayAmostragem = delayAmostragem;
+
+ _sensor->Inicializar();
+ }
+ else {
+ _sensor->Desligar();
+ }
+ }
+ break;
+ }
+ case sTEN: {
+ SensorTensao* _sensor = SVPorID(ID);
+ if (sensor_ativado) {
+ double _voffset = ((String)Protocolo[26] + (String)Protocolo[27] + (String)Protocolo[28] + (String)Protocolo[29] + (String)Protocolo[30] + (String)Protocolo[31]).toDouble();
+ double _r1 = ((String)Protocolo[33] + (String)Protocolo[34] + (String)Protocolo[35] + (String)Protocolo[36] + (String)Protocolo[37] + (String)Protocolo[38]).toDouble();
+ double _r2 = ((String)Protocolo[40] + (String)Protocolo[41] + (String)Protocolo[42] + (String)Protocolo[43] + (String)Protocolo[44] + (String)Protocolo[45]).toDouble();
+ _sensor->Voffset = (float)_voffset;
+ _sensor->R1 = (int)_r1;
+ _sensor->R2 = (int)_r2;
+ if (Conectar) {
+ _sensor->_pino = pino;
+ _sensor->_prioridade = prioridade;
+ _sensor->_delayAmostragem = delayAmostragem;
+
+ _sensor->Inicializar();
+ }
+ else {
+ _sensor->Desligar();
+ }
+ }
+ break;
+ }
+ case sCOR: {
+ SensorCorrente* _sensor = SAPorID(ID);
+ if (sensor_ativado) {
+ double _voffset = ((String)Protocolo[26] + (String)Protocolo[27] + (String)Protocolo[28] + (String)Protocolo[29] + (String)Protocolo[30] + (String)Protocolo[31]).toDouble();
+ double _sensibilidade = ((String)Protocolo[33] + (String)Protocolo[34] + (String)Protocolo[35] + (String)Protocolo[36] + (String)Protocolo[37] + (String)Protocolo[38]).toDouble();
+ _sensor->Voffset = (float)_voffset;
+ _sensor->sensibilidade = (float)_sensibilidade;
+ if (Conectar) {
+ _sensor->_pino = pino;
+ _sensor->_prioridade = prioridade;
+ _sensor->_delayAmostragem = delayAmostragem;
+
+ _sensor->Inicializar();
+ }
+ else {
+ _sensor->Desligar();
+ }
+ }
+ break;
+ }
- if (_sensor == nullptr) {
- return;
}
- S_Code componente = (S_Code)((String)Protocolo[5]).toInt();
- int prioridade = ((String)Protocolo[7] + (String)Protocolo[8]).toInt();
- int delayAmostragem = ((String)Protocolo[10] + (String)Protocolo[11] + (String)Protocolo[12] + (String)Protocolo[13] + (String)Protocolo[14]).toInt();
- bool aferir = ((String)Protocolo[16]) == "1";
- bool i2c = ((String)Protocolo[18]) == "1";
- int lei_1 = ((String)Protocolo[20] + (String)Protocolo[21]).toInt();
- int lei_2 = ((String)Protocolo[23] + (String)Protocolo[24]).toInt();
- int lei_3 = ((String)Protocolo[26] + (String)Protocolo[27]).toInt();
- int lei_4 = ((String)Protocolo[29] + (String)Protocolo[30]).toInt();
-
- if (aferir) {
- if (Conectar) {
- _sensor->_prioridade = prioridade;
- _sensor->_delayAmostragem = delayAmostragem;
- _sensor->_I2C = i2c;
- _sensor->_pinoLeitura1 = lei_1;
- _sensor->_pinoLeitura2 = lei_2;
- _sensor->_pinoLeitura3 = lei_3;
- _sensor->_pinoLeitura4 = lei_4;
- _sensor->Inicializar();
- }
- else {
- _sensor->Desligar();
- }
- vTaskDelay(pdMS_TO_TICKS(500));
- }
+
}
- }
- else if (_funcao == Cmd) {
-
- }
- else if (_funcao == Tst) {
-
- }
+ } else if (_funcao == Cmd) {
+
+ } else if (_funcao == Tst) {
+ }
}
}
diff --git a/Firmware/Modulos/SerialService.h b/Firmware/Modulos/SerialService.h
index d9ab27fa2..beaf0fe31 100644
--- a/Firmware/Modulos/SerialService.h
+++ b/Firmware/Modulos/SerialService.h
@@ -93,4 +93,20 @@ String MontarDadosProtocoloNTC10K(float temperatura) {
return Protocolo;
}
+String MontarDadosProtocoloTensao(float leitura, float vPin, float vReal) {
+ String Protocolo =
+ (String)leitura + ";" +
+ (String)vPin + ";" +
+ (String)vReal;
+ return Protocolo;
+}
+
+String MontarDadosProtocoloCorrente(float leitura, float vPin, float corrente) {
+ String Protocolo =
+ (String)leitura + ";" +
+ (String)vPin + ";" +
+ (String)corrente;
+ return Protocolo;
+}
+
#endif
\ No newline at end of file
diff --git a/Firmware/Movimentação/Movimentacao_v14/Movimentacao_v14.ino b/Firmware/Movimentação/Movimentacao_v14/Movimentacao_v14.ino
index d27a31223..4873cc254 100644
--- a/Firmware/Movimentação/Movimentacao_v14/Movimentacao_v14.ino
+++ b/Firmware/Movimentação/Movimentacao_v14/Movimentacao_v14.ino
@@ -429,6 +429,16 @@ Motor M2("EF");
Motor M3("DT");
Motor M4("DF");
+Motor* MotorPorID(String ID) {
+ Motor* _motor =
+ ID == "ET" ? &M1 :
+ ID == "EF" ? &M2 :
+ ID == "DT" ? &M3 :
+ ID == "DF" ? &M4 :
+ nullptr;
+ return _motor;
+}
+
void setup() {
Serial.begin(_baudRate);
@@ -503,7 +513,7 @@ void loop() {
int hallB = ((String)Protocolo[44] + (String)Protocolo[45]).toInt();
int hallC = ((String)Protocolo[47] + (String)Protocolo[48]).toInt();
- Motor* _motor = ID == "ET" ? &M1 : ID == "EF" ? &M2 : ID == "DT" ? &M3 : &M4;
+ Motor* _motor = MotorPorID(ID);
if (motor_ativado) {
if (Conectar) {
_motor->_canal = canal;
@@ -533,7 +543,7 @@ void loop() {
//0;000;0;000;000;000
String ID = ((String)Protocolo[0] + (String)Protocolo[1]);
- Motor* _motor = ID == "ET" ? &M1 : ID == "EF" ? &M2 : ID == "DT" ? &M3 : &M4;
+ Motor* _motor = MotorPorID(ID);
_motor->_SentidoSP = (Sentido)((String)Protocolo[3]).toInt();
_motor->_RPM_SP = ((String)Protocolo[5] + (String)Protocolo[6] + (String)Protocolo[7]).toInt();
@@ -548,7 +558,7 @@ void loop() {
else if (_funcao == Tst) {
String ID = ((String)Protocolo[0] +(String)Protocolo[1]);
- Motor* _motor = ID == "ET" ? &M1 : ID == "EF" ? &M2 : ID == "DT" ? &M3 : &M4;
+ Motor* _motor = MotorPorID(ID);
bool EmTeste = _motor->Testando;
if (!EmTeste) {
diff --git a/Firmware/Movimentação/Movimentacao_v9/Movimentacao_v9.ino b/Firmware/Movimentação/Movimentacao_v9/Movimentacao_v9.ino
index 615115bce..fc37c693f 100644
--- a/Firmware/Movimentação/Movimentacao_v9/Movimentacao_v9.ino
+++ b/Firmware/Movimentação/Movimentacao_v9/Movimentacao_v9.ino
@@ -1,6 +1,10 @@
-#include "C:\Zendion Inc\agrobot_base\Firmware\Modulos\SerialService.h"
-#include "C:\Zendion Inc\agrobot_base\Firmware\Modulos\MemoryService.h"
-#include "C:\Zendion Inc\agrobot_base\Firmware\Modulos\utils.h"
+// Dispositivo: Movimentação
+// Versão Firmware: 9
+// Ultima atualização: 21/11/2023
+
+#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SerialService.h"
+#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\MemoryService.h"
+#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\utils.h"
#include
#include "DHT.h"
#define D_Code Mov
diff --git a/Firmware/Sensoriamento/Sensoriamento_v3/Sensoriamento_v3.ino b/Firmware/Sensoriamento/Sensoriamento_v3/Sensoriamento_v3.ino
new file mode 100644
index 000000000..ae2821b25
--- /dev/null
+++ b/Firmware/Sensoriamento/Sensoriamento_v3/Sensoriamento_v3.ino
@@ -0,0 +1,494 @@
+#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SerialService.h"
+
+#include
+
+#define D_Code Sen
+
+#define _pinoLED RGB_BUILTIN
+
+long _baudRate = 115200;
+
+bool Conectado = false;
+
+int _TaxaAmostragem;
+int FrequenciaMaxima = 10000;
+
+
+class SensorTemperatura {
+ public:
+ SensorTemperatura(String desc) {
+ _ID = desc;
+ }
+
+ // Definições
+ String _ID;
+ S_Code _componente = sTMP;
+ int _pino;
+ int _delayAmostragem;
+ int _prioridade;
+
+ bool Iniciado = false;
+
+ void Inicializar() {
+ if (Iniciado) {
+ EnviarDadosSerial(_ID + " ja inicializado");
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
+ return;
+ }
+
+ if (_pino > -1) {
+ pinMode(_pino, INPUT);
+ }
+
+ xTaskCreatePinnedToCore(&SensorTemperatura::STTaskWrapper, "STTask", 5000, this, _prioridade, &STTaskHandle, tskNO_AFFINITY);
+
+ EnviarDadosSerial(_ID + " Iniciado");
+
+ Iniciado = true;
+
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
+ }
+
+ void Desligar() {
+ if (!Iniciado) {
+ EnviarDadosSerial(_ID + " nao esta inicializado");
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
+ return;
+ }
+
+ // Parar a execução das tarefas
+ vTaskDelete(STTaskHandle);
+
+ // Redefinir as configurações para os valores iniciais
+ pinMode(_pino, INPUT);
+
+ EnviarDadosSerial(_ID + " Desligado");
+
+ Iniciado = false;
+
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
+ }
+
+ private:
+
+ // Variáveis
+ double Vs = 3.3; // TENSÃO DE SAIDA DO ESP32
+ double R1 = 10000; //RESISTOR UTILIZADO NO DIVISOR DE TENSÃO
+ double Beta = 3950; // VALOR DE BETA
+ double To = 298.15; // VALOR EM KELVIN REFERENTE A 25° CELSIUS
+ double Ro = 10000;
+ double adcMax = 4095.0;
+
+ TaskHandle_t STTaskHandle = NULL;
+ static void STTaskWrapper(void *pvParameters) {
+ SensorTemperatura *sensor = static_cast(pvParameters);
+ sensor->STTask();
+ }
+
+ void STTask() {
+ unsigned long firstMilis = millis();
+ while (1)
+ {
+ if (!Conectado) {
+ // Caso não esteja conectado, aguarda 1 segundo até a próxima verificação, liberando uso de CPU
+ vTaskDelay(1000);
+ continue;
+ }
+
+ long intMillis = (millis() - firstMilis);
+
+ // A cada _TaxaAmostragem, enviar os dados para o software
+ if (intMillis >= (_TaxaAmostragem + _delayAmostragem)) {
+ AferirTemperatura();
+
+ firstMilis = millis();
+ }
+
+ // Aguarda metade do menor período possível entre leituras
+ vTaskDelay(1);
+ }
+ }
+
+ void AferirTemperatura() {
+ double Vout, Rt = 0;
+ double T, Tc, Tf, adc = 0;
+ adc = analogRead(_pino); // VARIÁVEL QUE RECEBE A LEITURA DO NTC10K
+ //float adcValue = tempKalman->updateEstimate(adc);
+ float adcValue = adc;
+ //CALCULOS PARA CONVERSÃO DA LEITURA RECEBIDA PELO ESP32 EM TEMPERATURA EM °C
+ Vout = adcValue * Vs / adcMax;
+ Rt = R1 * Vout / (Vs - Vout);
+ T = 1 / (1 / To + log(Rt / Ro) / Beta);
+ Tc = T - 273.15;
+ Tf = Tc * 9 / 5 + 32;
+
+ EnviarDadosSerial(MontarProtocoloSensor(sTMP, _ID, MontarDadosProtocoloNTC10K(Tc)));
+ }
+};
+
+class SensorTensao {
+ public:
+ SensorTensao(String desc) {
+ _ID = desc;
+ }
+
+ // Variáveis
+ const float Vcc = 3.3; // Tensão de alimentação
+ float Voffset = 0.85;
+ int R1 = 47000;
+ int R2 = 10000;
+
+ // Definições
+ String _ID;
+ S_Code _componente = sTEN;
+ int _pino;
+ int _delayAmostragem;
+ int _prioridade;
+
+ SimpleKalmanFilter* kalmanTEN;
+
+ bool Iniciado = false;
+
+ void Inicializar() {
+ if (Iniciado) {
+ EnviarDadosSerial(_ID + " ja inicializado");
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
+ return;
+ }
+
+ if (_pino > -1) {
+ pinMode(_pino, INPUT);
+ }
+
+ kalmanTEN = new SimpleKalmanFilter(2, 2, 0.01);
+
+ xTaskCreatePinnedToCore(&SensorTensao::SVTaskWrapper, "SVTask", 5000, this, _prioridade, &SVTaskHandle, tskNO_AFFINITY);
+
+ EnviarDadosSerial(_ID + " Iniciado");
+
+ Iniciado = true;
+
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
+ }
+
+ void Desligar() {
+ if (!Iniciado) {
+ EnviarDadosSerial(_ID + " nao esta inicializado");
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
+ return;
+ }
+
+ // Parar a execução das tarefas
+ vTaskDelete(SVTaskHandle);
+
+ // Redefinir as configurações para os valores iniciais
+ pinMode(_pino, INPUT);
+
+ delete kalmanTEN;
+
+ EnviarDadosSerial(_ID + " Desligado");
+
+ Iniciado = false;
+
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
+ }
+
+ private:
+ TaskHandle_t SVTaskHandle = NULL;
+ static void SVTaskWrapper(void *pvParameters) {
+ SensorTensao *sensor = static_cast(pvParameters);
+ sensor->SVTask();
+ }
+
+ void SVTask() {
+ unsigned long firstMilis = millis();
+ while (1)
+ {
+ if (!Conectado) {
+ // Caso não esteja conectado, aguarda 1 segundo até a próxima verificação, liberando uso de CPU
+ vTaskDelay(1000);
+ continue;
+ }
+
+ long intMillis = (millis() - firstMilis);
+
+ // A cada _TaxaAmostragem, enviar os dados para o software
+ if (intMillis >= (_TaxaAmostragem + _delayAmostragem)) {
+ AferirTensao();
+
+ firstMilis = millis();
+ }
+
+ // Aguarda metade do menor período possível entre leituras
+ vTaskDelay(1);
+ }
+ }
+
+ void AferirTensao() {
+ float Razao = (R1 + R2) / (float)R2;
+ int adcV = analogRead(_pino);
+ float adcValueV = kalmanTEN->updateEstimate(adcV);
+
+ float voltageV = (adcValueV * (Vcc / 4095.0)) + (Voffset / Razao); // Convertendo o valor ADC para tensão
+ float realVoltage = voltageV * Razao;
+
+ EnviarDadosSerial(MontarProtocoloSensor(sTEN, _ID, MontarDadosProtocoloTensao(adcValueV, voltageV, realVoltage)));
+ }
+
+};
+
+class SensorCorrente {
+ public:
+ SensorCorrente(String desc) {
+ _ID = desc;
+ }
+
+ // Variáveis
+ const float Vcc = 3.3; // Tensão de alimentação
+ float Voffset = 0.413;
+ float sensibilidade = 0.35;
+
+ // Definições
+ String _ID;
+ S_Code _componente = sCOR;
+ int _pino;
+ int _delayAmostragem;
+ int _prioridade;
+
+ SimpleKalmanFilter* kalmanCOR;
+
+ bool Iniciado = false;
+
+ void Inicializar() {
+ if (Iniciado) {
+ EnviarDadosSerial(_ID + " ja inicializado");
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
+ return;
+ }
+
+ if (_pino > -1) {
+ pinMode(_pino, INPUT);
+ }
+
+ kalmanCOR = new SimpleKalmanFilter(2, 2, 0.01);
+
+ xTaskCreatePinnedToCore(&SensorCorrente::SATaskWrapper, "SATask", 5000, this, _prioridade, &SATaskHandle, tskNO_AFFINITY);
+
+ EnviarDadosSerial(_ID + " Iniciado");
+
+ Iniciado = true;
+
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
+ }
+
+ void Desligar() {
+ if (!Iniciado) {
+ EnviarDadosSerial(_ID + " nao esta inicializado");
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
+ return;
+ }
+
+ // Parar a execução das tarefas
+ vTaskDelete(SATaskHandle);
+
+ // Redefinir as configurações para os valores iniciais
+ pinMode(_pino, INPUT);
+
+ delete kalmanCOR;
+
+ EnviarDadosSerial(_ID + " Desligado");
+
+ Iniciado = false;
+
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
+ }
+
+ private:
+ TaskHandle_t SATaskHandle = NULL;
+ static void SATaskWrapper(void *pvParameters) {
+ SensorCorrente *sensor = static_cast(pvParameters);
+ sensor->SATask();
+ }
+
+ void SATask() {
+ unsigned long firstMilis = millis();
+ while (1)
+ {
+ if (!Conectado) {
+ // Caso não esteja conectado, aguarda 1 segundo até a próxima verificação, liberando uso de CPU
+ vTaskDelay(1000);
+ continue;
+ }
+
+ long intMillis = (millis() - firstMilis);
+
+ // A cada _TaxaAmostragem, enviar os dados para o software
+ if (intMillis >= (_TaxaAmostragem + _delayAmostragem)) {
+ AferirCorrente();
+
+ firstMilis = millis();
+ }
+
+ // Aguarda metade do menor período possível entre leituras
+ vTaskDelay(1);
+ }
+ }
+
+ void AferirCorrente() {
+ int adcV = analogRead(_pino);
+ float adcValue = kalmanCOR->updateEstimate(adcV);
+
+ float voltage = adcValue * (Vcc / 4095.0); // Convertendo o valor ADC para tensão
+ float current = (voltage - Voffset) / sensibilidade; // Calculando a corrente em A
+
+ EnviarDadosSerial(MontarProtocoloSensor(sCOR, _ID, MontarDadosProtocoloCorrente(adcValue, voltage, current)));
+ }
+
+};
+
+SensorTemperatura TM1("TMVET");
+SensorTemperatura TM2("TMVEF");
+SensorTemperatura TM3("TMVDT");
+SensorTemperatura TM4("TMVDF");
+SensorTensao VBAT("VBAT ");
+SensorCorrente ABAT("ABAT ");
+
+
+SensorTemperatura* STPorID(String ID) {
+ SensorTemperatura* _sensor =
+ ID == "TMVET" ? &TM1 :
+ ID == "TMVEF" ? &TM2 :
+ ID == "TMVDT" ? &TM3 :
+ ID == "TMVDF" ? &TM4 :
+ nullptr;
+ return _sensor;
+}
+
+SensorTensao* SVPorID(String ID) {
+ SensorTensao* _sensor =
+ ID == "VBAT " ? &VBAT :
+ nullptr;
+ return _sensor;
+}
+
+SensorCorrente* SAPorID(String ID) {
+ SensorCorrente* _sensor =
+ ID == "ABAT " ? &ABAT :
+ nullptr;
+ return _sensor;
+}
+
+void setup() {
+ Serial.begin(_baudRate);
+}
+
+void loop() {
+ if (Serial.available() > 3) {
+ String Protocolo = "";
+ F_Code _funcao = Nda;
+ while (Serial.available()) {
+ char Entrada = (char)Serial.read();
+ if (Entrada == EndLine) {
+ break;
+ }
+ Protocolo += Entrada;
+ if (Protocolo.length() == 3) {
+ if (_funcao == Nda) {
+ _funcao = (F_Code)((String)Protocolo[0] + (String)Protocolo[1] + (String)Protocolo[2]).toInt();
+ Protocolo = "";
+ }
+ }
+ }
+
+ EnviarDadosSerial("OK");
+
+ if (_funcao == Chk) {
+ EnviarDadosSerial(MontarProtocoloVerificacao(D_Code));
+ } else if (_funcao == Cfg) {
+ String ID = ((String)Protocolo[0] + (String)Protocolo[1] + (String)Protocolo[2] + (String)Protocolo[3] + (String)Protocolo[4]);
+ bool Conectar = (String)Protocolo[6] == "1";
+ if (ID == "MD ") {
+ _TaxaAmostragem = ((String)Protocolo[8] + (String)Protocolo[9] + (String)Protocolo[10] + (String)Protocolo[11] + (String)Protocolo[12]).toInt();
+
+ vTaskDelay(pdMS_TO_TICKS(100));
+ Conectado = Conectar;
+ EnviarDadosSerial(MontarProtocoloSensor(sCFG, "MD", Conectado ? "1" : "0"));
+ }
+ else {
+ S_Code componente = (S_Code)((String)Protocolo[8] + (String)Protocolo[9] + (String)Protocolo[10]).toInt();
+ bool sensor_ativado = (String)Protocolo[12] == "1";
+ int delayAmostragem = ((String)Protocolo[14] + (String)Protocolo[15] + (String)Protocolo[16] + (String)Protocolo[17] + (String)Protocolo[18]).toInt();
+ int prioridade = ((String)Protocolo[20] + (String)Protocolo[21]).toInt();
+ int pino = ((String)Protocolo[23] + (String)Protocolo[24]).toInt();
+
+ switch (componente) {
+ case sTMP: {
+ SensorTemperatura* _sensor = STPorID(ID);
+ if (sensor_ativado) {
+ if (Conectar) {
+ _sensor->_pino = pino;
+ _sensor->_prioridade = prioridade;
+ _sensor->_delayAmostragem = delayAmostragem;
+
+ _sensor->Inicializar();
+ }
+ else {
+ _sensor->Desligar();
+ }
+ }
+ break;
+ }
+ case sTEN: {
+ SensorTensao* _sensor = SVPorID(ID);
+ if (sensor_ativado) {
+ double _voffset = ((String)Protocolo[26] + (String)Protocolo[27] + (String)Protocolo[28] + (String)Protocolo[29] + (String)Protocolo[30] + (String)Protocolo[31]).toDouble();
+ double _r1 = ((String)Protocolo[33] + (String)Protocolo[34] + (String)Protocolo[35] + (String)Protocolo[36] + (String)Protocolo[37] + (String)Protocolo[38]).toDouble();
+ double _r2 = ((String)Protocolo[40] + (String)Protocolo[41] + (String)Protocolo[42] + (String)Protocolo[43] + (String)Protocolo[44] + (String)Protocolo[45]).toDouble();
+ _sensor->Voffset = (float)_voffset;
+ _sensor->R1 = (int)_r1;
+ _sensor->R2 = (int)_r2;
+ if (Conectar) {
+ _sensor->_pino = pino;
+ _sensor->_prioridade = prioridade;
+ _sensor->_delayAmostragem = delayAmostragem;
+
+ _sensor->Inicializar();
+ }
+ else {
+ _sensor->Desligar();
+ }
+ }
+ break;
+ }
+ case sCOR: {
+ SensorCorrente* _sensor = SAPorID(ID);
+ if (sensor_ativado) {
+ double _voffset = ((String)Protocolo[26] + (String)Protocolo[27] + (String)Protocolo[28] + (String)Protocolo[29] + (String)Protocolo[30] + (String)Protocolo[31]).toDouble();
+ double _sensibilidade = ((String)Protocolo[33] + (String)Protocolo[34] + (String)Protocolo[35] + (String)Protocolo[36] + (String)Protocolo[37] + (String)Protocolo[38]).toDouble();
+ _sensor->Voffset = (float)_voffset;
+ _sensor->sensibilidade = (float)_sensibilidade;
+ if (Conectar) {
+ _sensor->_pino = pino;
+ _sensor->_prioridade = prioridade;
+ _sensor->_delayAmostragem = delayAmostragem;
+
+ _sensor->Inicializar();
+ }
+ else {
+ _sensor->Desligar();
+ }
+ }
+ break;
+ }
+
+ }
+
+
+ }
+
+ } else if (_funcao == Cmd) {
+
+ } else if (_funcao == Tst) {
+ }
+ }
+}
diff --git a/Firmware/Sensoriamento/corrente/corrente.ino b/Firmware/Sensoriamento/corrente/corrente.ino
index a2fbcea6e..148efa52b 100644
--- a/Firmware/Sensoriamento/corrente/corrente.ino
+++ b/Firmware/Sensoriamento/corrente/corrente.ino
@@ -3,11 +3,8 @@
SimpleKalmanFilter kalmanCOR(2, 2, 0.01);
SimpleKalmanFilter kalmanTEN(2, 2, 0.01);
-#define _pinoCOR 4
-#define _pinoTEN 34
-const float Vcc = 4.16; // Tensão de alimentação do ACS758
-const float Voffset = 0.502; // Tensão de offset do ACS758
-const float sensibilidade = 0.17; // Sensibilidade do ACS758 em V/A (40mV/A para este exemplo)
+#define _pinoCOR 25
+#define _pinoTEN 26
void setup() {
Serial.begin(115200);
@@ -16,6 +13,17 @@ void setup() {
}
void loop() {
+ AferirCorrente();
+ AferirTensao();
+
+ delay(100);
+}
+
+void AferirCorrente() {
+ const float Vcc = 3.3; // Tensão de alimentação do ACS758
+ const float Voffset = 0.413; // Tensão de offset do ACS758
+ const float sensibilidade = 0.35; // Sensibilidade do ACS758 em V/A (40mV/A para este exemplo)
+
int adcValueO = analogRead(_pinoCOR);
float adcValue = kalmanCOR.updateEstimate(adcValueO);
@@ -28,16 +36,24 @@ void loop() {
Serial.print(voltage, 3); // Mostra a tensão com 3 casas decimais
Serial.print(" Current: ");
Serial.println(current, 3); // Mostra a corrente com 3 casas decimais
-
- delay(100);
+}
+void AferirTensao() {
+ const float Vcc = 3.3; // Tensão de alimentação
+ const float Voffset = 0.85;
+ int R1 = 47000;
+ int R2 = 10000;
+ float Razao = (R1 + R2) / (float)R2;
int adcV = analogRead(_pinoTEN);
float adcValueV = kalmanTEN.updateEstimate(adcV);
- float voltageV = adcValueV * (Vcc / 4095.0); // Convertendo o valor ADC para tensão
+ float voltageV = (adcValueV * (Vcc / 4095.0)) + (Voffset / Razao); // Convertendo o valor ADC para tensão
+ float realVoltage = voltageV * Razao;
Serial.print("Leitura: ");
Serial.print(adcValueV);
- Serial.print(" - Tensao: ");
- Serial.println(voltageV);
+ Serial.print(" - Tensao pino: ");
+ Serial.print(voltageV);
+ Serial.print(" - Tensão: ");
+ Serial.println(realVoltage);
}
\ No newline at end of file