diff --git a/.gitignore b/.gitignore index 3dcb6d58a..d3b51453f 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,10 @@ src/external_pkgs/ src/mapping_urc/multi_resolution_graph /.project phidgetlog.log + +# arm firmware ignores + +src/firmware/arm_firmware/SerialCom1/.vs/ +src/firmware/arm_firmware/SerialCom1/SerialCom/bin +src/firmware/arm_firmware/SerialCom1/SerialCom/obj +src/firmware/arm_firmware/SerialCom1/SerialCom/Form1.resx \ No newline at end of file diff --git a/src/firmware/arm_firmware/SerialCom1/SerialCom.sln b/src/firmware/arm_firmware/SerialCom1/SerialCom.sln new file mode 100644 index 000000000..cf0f6d67e --- /dev/null +++ b/src/firmware/arm_firmware/SerialCom1/SerialCom.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31624.102 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SerialCom", "SerialCom\SerialCom.csproj", "{293C7DFD-2AF8-4E61-927A-46072A9F6182}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {293C7DFD-2AF8-4E61-927A-46072A9F6182}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {293C7DFD-2AF8-4E61-927A-46072A9F6182}.Debug|Any CPU.Build.0 = Debug|Any CPU + {293C7DFD-2AF8-4E61-927A-46072A9F6182}.Release|Any CPU.ActiveCfg = Release|Any CPU + {293C7DFD-2AF8-4E61-927A-46072A9F6182}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D52D6B80-3854-499E-8028-35CA40DD7D18} + EndGlobalSection +EndGlobal diff --git a/src/firmware/arm_firmware/SerialCom1/SerialCom/Form1.Designer.cs b/src/firmware/arm_firmware/SerialCom1/SerialCom/Form1.Designer.cs new file mode 100644 index 000000000..4c639e29f --- /dev/null +++ b/src/firmware/arm_firmware/SerialCom1/SerialCom/Form1.Designer.cs @@ -0,0 +1,649 @@ + +namespace SerialCom +{ + partial class Form1 + { + /// + /// 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.components = new System.ComponentModel.Container(); + this.webBrowser1 = new System.Windows.Forms.WebBrowser(); + this.btnCLOSE = new System.Windows.Forms.Button(); + this.btnSENDDATA = new System.Windows.Forms.Button(); + this.cBoxPARITYBITS = new System.Windows.Forms.ComboBox(); + this.cBoxSTOPBITS = new System.Windows.Forms.ComboBox(); + this.cBoxDATABITS = new System.Windows.Forms.ComboBox(); + this.cBoxBAUDRATE = new System.Windows.Forms.ComboBox(); + this.cBoxCOMPORT = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.progressBar1 = new System.Windows.Forms.ProgressBar(); + this.tBoxDATAOUT = new System.Windows.Forms.TextBox(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.groupBox4 = new System.Windows.Forms.GroupBox(); + this.btnMOVE = new System.Windows.Forms.Button(); + this.btnHOME = new System.Windows.Forms.Button(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.label18 = new System.Windows.Forms.Label(); + this.label19 = new System.Windows.Forms.Label(); + this.label11 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.label20 = new System.Windows.Forms.Label(); + this.label12 = new System.Windows.Forms.Label(); + this.label21 = new System.Windows.Forms.Label(); + this.label13 = new System.Windows.Forms.Label(); + this.label22 = new System.Windows.Forms.Label(); + this.label14 = new System.Windows.Forms.Label(); + this.label17 = new System.Windows.Forms.Label(); + this.label15 = new System.Windows.Forms.Label(); + this.label16 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.btnOPEN = new System.Windows.Forms.Button(); + this.label5 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.serialPort1 = new System.IO.Ports.SerialPort(this.components); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.btnINC = new System.Windows.Forms.RadioButton(); + this.btnABS = new System.Windows.Forms.RadioButton(); + this.groubox5 = new System.Windows.Forms.GroupBox(); + this.a1prog = new System.Windows.Forms.ProgressBar(); + this.a2prog = new System.Windows.Forms.ProgressBar(); + this.a5prog = new System.Windows.Forms.ProgressBar(); + this.a4prog = new System.Windows.Forms.ProgressBar(); + this.a3prog = new System.Windows.Forms.ProgressBar(); + this.a6prog = new System.Windows.Forms.ProgressBar(); + this.groupBox1.SuspendLayout(); + this.groupBox4.SuspendLayout(); + this.groupBox3.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.groubox5.SuspendLayout(); + this.SuspendLayout(); + // + // webBrowser1 + // + this.webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill; + this.webBrowser1.Location = new System.Drawing.Point(0, 0); + this.webBrowser1.MinimumSize = new System.Drawing.Size(20, 20); + this.webBrowser1.Name = "webBrowser1"; + this.webBrowser1.Size = new System.Drawing.Size(1050, 712); + this.webBrowser1.TabIndex = 0; + this.webBrowser1.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.webBrowser1_DocumentCompleted); + // + // btnCLOSE + // + this.btnCLOSE.Location = new System.Drawing.Point(146, 25); + this.btnCLOSE.Name = "btnCLOSE"; + this.btnCLOSE.Size = new System.Drawing.Size(107, 47); + this.btnCLOSE.TabIndex = 2; + this.btnCLOSE.Text = "CLOSE"; + this.btnCLOSE.UseVisualStyleBackColor = true; + this.btnCLOSE.Click += new System.EventHandler(this.button2_Click); + // + // btnSENDDATA + // + this.btnSENDDATA.Location = new System.Drawing.Point(310, 263); + this.btnSENDDATA.Name = "btnSENDDATA"; + this.btnSENDDATA.Size = new System.Drawing.Size(86, 102); + this.btnSENDDATA.TabIndex = 3; + this.btnSENDDATA.Text = "SEND DATA"; + this.btnSENDDATA.UseVisualStyleBackColor = true; + this.btnSENDDATA.Click += new System.EventHandler(this.button3_Click); + // + // cBoxPARITYBITS + // + this.cBoxPARITYBITS.FormattingEnabled = true; + this.cBoxPARITYBITS.Items.AddRange(new object[] { + "None", + "Odd", + "Even"}); + this.cBoxPARITYBITS.Location = new System.Drawing.Point(133, 183); + this.cBoxPARITYBITS.Name = "cBoxPARITYBITS"; + this.cBoxPARITYBITS.Size = new System.Drawing.Size(272, 28); + this.cBoxPARITYBITS.TabIndex = 4; + this.cBoxPARITYBITS.Text = "None"; + // + // cBoxSTOPBITS + // + this.cBoxSTOPBITS.FormattingEnabled = true; + this.cBoxSTOPBITS.Items.AddRange(new object[] { + "One", + "Two"}); + this.cBoxSTOPBITS.Location = new System.Drawing.Point(133, 147); + this.cBoxSTOPBITS.Name = "cBoxSTOPBITS"; + this.cBoxSTOPBITS.Size = new System.Drawing.Size(272, 28); + this.cBoxSTOPBITS.TabIndex = 5; + this.cBoxSTOPBITS.Text = "One"; + // + // cBoxDATABITS + // + this.cBoxDATABITS.FormattingEnabled = true; + this.cBoxDATABITS.Items.AddRange(new object[] { + "5", + "6", + "7", + "8"}); + this.cBoxDATABITS.Location = new System.Drawing.Point(133, 110); + this.cBoxDATABITS.Name = "cBoxDATABITS"; + this.cBoxDATABITS.Size = new System.Drawing.Size(272, 28); + this.cBoxDATABITS.TabIndex = 6; + this.cBoxDATABITS.Text = "8"; + // + // cBoxBAUDRATE + // + this.cBoxBAUDRATE.FormattingEnabled = true; + this.cBoxBAUDRATE.Items.AddRange(new object[] { + "2400", + "4800", + "9600"}); + this.cBoxBAUDRATE.Location = new System.Drawing.Point(133, 73); + this.cBoxBAUDRATE.Name = "cBoxBAUDRATE"; + this.cBoxBAUDRATE.Size = new System.Drawing.Size(272, 28); + this.cBoxBAUDRATE.TabIndex = 7; + this.cBoxBAUDRATE.Text = "9600"; + // + // cBoxCOMPORT + // + this.cBoxCOMPORT.FormattingEnabled = true; + this.cBoxCOMPORT.Location = new System.Drawing.Point(133, 36); + this.cBoxCOMPORT.Name = "cBoxCOMPORT"; + this.cBoxCOMPORT.Size = new System.Drawing.Size(272, 28); + this.cBoxCOMPORT.TabIndex = 8; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(35, 40); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(92, 20); + this.label1.TabIndex = 9; + this.label1.Text = "COM PORT"; + this.label1.Click += new System.EventHandler(this.label1_Click); + // + // progressBar1 + // + this.progressBar1.Location = new System.Drawing.Point(16, 91); + this.progressBar1.Name = "progressBar1"; + this.progressBar1.Size = new System.Drawing.Size(237, 36); + this.progressBar1.TabIndex = 10; + this.progressBar1.Click += new System.EventHandler(this.progressBar1_Click); + // + // tBoxDATAOUT + // + this.tBoxDATAOUT.Location = new System.Drawing.Point(445, 131); + this.tBoxDATAOUT.Multiline = true; + this.tBoxDATAOUT.Name = "tBoxDATAOUT"; + this.tBoxDATAOUT.Size = new System.Drawing.Size(558, 411); + this.tBoxDATAOUT.TabIndex = 11; + this.tBoxDATAOUT.TextChanged += new System.EventHandler(this.tBoxDATAOUT_TextChanged); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.groubox5); + this.groupBox1.Controls.Add(this.groupBox4); + this.groupBox1.Controls.Add(this.groupBox3); + this.groupBox1.Controls.Add(this.label7); + this.groupBox1.Controls.Add(this.groupBox2); + this.groupBox1.Controls.Add(this.label5); + this.groupBox1.Controls.Add(this.btnSENDDATA); + this.groupBox1.Controls.Add(this.label4); + this.groupBox1.Controls.Add(this.label3); + this.groupBox1.Controls.Add(this.label2); + this.groupBox1.Controls.Add(this.cBoxCOMPORT); + this.groupBox1.Controls.Add(this.tBoxDATAOUT); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Controls.Add(this.cBoxPARITYBITS); + this.groupBox1.Controls.Add(this.cBoxSTOPBITS); + this.groupBox1.Controls.Add(this.cBoxDATABITS); + this.groupBox1.Controls.Add(this.cBoxBAUDRATE); + this.groupBox1.Location = new System.Drawing.Point(1, 6); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(1039, 705); + this.groupBox1.TabIndex = 12; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Com Port Control"; + this.groupBox1.Enter += new System.EventHandler(this.groupBox1_Enter); + // + // groupBox4 + // + this.groupBox4.Controls.Add(this.btnMOVE); + this.groupBox4.Controls.Add(this.btnHOME); + this.groupBox4.Location = new System.Drawing.Point(540, 556); + this.groupBox4.Name = "groupBox4"; + this.groupBox4.Size = new System.Drawing.Size(358, 132); + this.groupBox4.TabIndex = 22; + this.groupBox4.TabStop = false; + // + // btnMOVE + // + this.btnMOVE.Location = new System.Drawing.Point(184, 34); + this.btnMOVE.Name = "btnMOVE"; + this.btnMOVE.Size = new System.Drawing.Size(162, 68); + this.btnMOVE.TabIndex = 23; + this.btnMOVE.Text = "MOTION DEMO"; + this.btnMOVE.UseVisualStyleBackColor = true; + this.btnMOVE.Click += new System.EventHandler(this.btnMOVE_Click); + // + // btnHOME + // + this.btnHOME.Location = new System.Drawing.Point(10, 35); + this.btnHOME.Name = "btnHOME"; + this.btnHOME.Size = new System.Drawing.Size(162, 68); + this.btnHOME.TabIndex = 22; + this.btnHOME.Text = "HOME ARM"; + this.btnHOME.UseVisualStyleBackColor = true; + this.btnHOME.Click += new System.EventHandler(this.button1_Click_3); + // + // groupBox3 + // + this.groupBox3.Controls.Add(this.a6prog); + this.groupBox3.Controls.Add(this.a3prog); + this.groupBox3.Controls.Add(this.a4prog); + this.groupBox3.Controls.Add(this.a5prog); + this.groupBox3.Controls.Add(this.a2prog); + this.groupBox3.Controls.Add(this.a1prog); + this.groupBox3.Controls.Add(this.label18); + this.groupBox3.Controls.Add(this.label19); + this.groupBox3.Controls.Add(this.label11); + this.groupBox3.Controls.Add(this.label6); + this.groupBox3.Controls.Add(this.label20); + this.groupBox3.Controls.Add(this.label12); + this.groupBox3.Controls.Add(this.label21); + this.groupBox3.Controls.Add(this.label13); + this.groupBox3.Controls.Add(this.label22); + this.groupBox3.Controls.Add(this.label14); + this.groupBox3.Controls.Add(this.label17); + this.groupBox3.Controls.Add(this.label15); + this.groupBox3.Controls.Add(this.label16); + this.groupBox3.Location = new System.Drawing.Point(23, 411); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(400, 278); + this.groupBox3.TabIndex = 13; + this.groupBox3.TabStop = false; + // + // label18 + // + this.label18.AutoSize = true; + this.label18.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label18.Location = new System.Drawing.Point(75, 223); + this.label18.Name = "label18"; + this.label18.Size = new System.Drawing.Size(45, 25); + this.label18.TabIndex = 34; + this.label18.Text = "000"; + // + // label19 + // + this.label19.AutoSize = true; + this.label19.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label19.Location = new System.Drawing.Point(27, 223); + this.label19.Name = "label19"; + this.label19.Size = new System.Drawing.Size(43, 25); + this.label19.TabIndex = 33; + this.label19.Text = "A6:"; + // + // label11 + // + this.label11.AutoSize = true; + this.label11.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label11.Location = new System.Drawing.Point(75, 75); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(45, 25); + this.label11.TabIndex = 23; + this.label11.Text = "000"; + this.label11.Click += new System.EventHandler(this.label11_Click); + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label6.Location = new System.Drawing.Point(49, 22); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(294, 25); + this.label6.TabIndex = 18; + this.label6.Text = "Absolute Arm Position (degrees)"; + this.label6.Click += new System.EventHandler(this.label6_Click); + // + // label20 + // + this.label20.AutoSize = true; + this.label20.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label20.Location = new System.Drawing.Point(75, 194); + this.label20.Name = "label20"; + this.label20.Size = new System.Drawing.Size(45, 25); + this.label20.TabIndex = 32; + this.label20.Text = "000"; + // + // label12 + // + this.label12.AutoSize = true; + this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label12.Location = new System.Drawing.Point(26, 75); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(43, 25); + this.label12.TabIndex = 24; + this.label12.Text = "A1:"; + // + // label21 + // + this.label21.AutoSize = true; + this.label21.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label21.Location = new System.Drawing.Point(27, 194); + this.label21.Name = "label21"; + this.label21.Size = new System.Drawing.Size(43, 25); + this.label21.TabIndex = 31; + this.label21.Text = "A5:"; + // + // label13 + // + this.label13.AutoSize = true; + this.label13.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label13.Location = new System.Drawing.Point(27, 106); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(43, 25); + this.label13.TabIndex = 25; + this.label13.Text = "A2:"; + // + // label22 + // + this.label22.AutoSize = true; + this.label22.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label22.Location = new System.Drawing.Point(75, 166); + this.label22.Name = "label22"; + this.label22.Size = new System.Drawing.Size(45, 25); + this.label22.TabIndex = 30; + this.label22.Text = "000"; + // + // label14 + // + this.label14.AutoSize = true; + this.label14.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label14.Location = new System.Drawing.Point(75, 106); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(45, 25); + this.label14.TabIndex = 26; + this.label14.Text = "000"; + // + // label17 + // + this.label17.AutoSize = true; + this.label17.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label17.Location = new System.Drawing.Point(27, 166); + this.label17.Name = "label17"; + this.label17.Size = new System.Drawing.Size(43, 25); + this.label17.TabIndex = 29; + this.label17.Text = "A4:"; + // + // label15 + // + this.label15.AutoSize = true; + this.label15.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label15.Location = new System.Drawing.Point(27, 137); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(43, 25); + this.label15.TabIndex = 27; + this.label15.Text = "A3:"; + this.label15.Click += new System.EventHandler(this.label15_Click); + // + // label16 + // + this.label16.AutoSize = true; + this.label16.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label16.Location = new System.Drawing.Point(75, 136); + this.label16.Name = "label16"; + this.label16.Size = new System.Drawing.Size(45, 25); + this.label16.TabIndex = 28; + this.label16.Text = "000"; + this.label16.Click += new System.EventHandler(this.label16_Click); + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label7.Location = new System.Drawing.Point(438, 50); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(235, 37); + this.label7.TabIndex = 19; + this.label7.Text = "Command Line"; + this.label7.Click += new System.EventHandler(this.label7_Click); + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.btnOPEN); + this.groupBox2.Controls.Add(this.progressBar1); + this.groupBox2.Controls.Add(this.btnCLOSE); + this.groupBox2.Location = new System.Drawing.Point(23, 238); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(271, 144); + this.groupBox2.TabIndex = 16; + this.groupBox2.TabStop = false; + // + // btnOPEN + // + this.btnOPEN.Location = new System.Drawing.Point(16, 25); + this.btnOPEN.Name = "btnOPEN"; + this.btnOPEN.Size = new System.Drawing.Size(107, 47); + this.btnOPEN.TabIndex = 3; + this.btnOPEN.Text = "OPEN"; + this.btnOPEN.UseVisualStyleBackColor = true; + this.btnOPEN.Click += new System.EventHandler(this.btnOPEN_Click); + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(27, 76); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(102, 20); + this.label5.TabIndex = 15; + this.label5.Text = "BAUD RATE"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(35, 114); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(92, 20); + this.label4.TabIndex = 14; + this.label4.Text = "DATA BITS"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(35, 151); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(91, 20); + this.label3.TabIndex = 13; + this.label3.Text = "STOP BITS"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(19, 187); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(107, 20); + this.label2.TabIndex = 12; + this.label2.Text = "PARITY BITS"; + // + // serialPort1 + // + this.serialPort1.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(this.serialPort1_DataReceived); + // + // timer1 + // + this.timer1.Enabled = true; + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // + // btnINC + // + this.btnINC.AutoSize = true; + this.btnINC.Location = new System.Drawing.Point(15, 25); + this.btnINC.Name = "btnINC"; + this.btnINC.Size = new System.Drawing.Size(118, 24); + this.btnINC.TabIndex = 23; + this.btnINC.TabStop = true; + this.btnINC.Text = "Incremental"; + this.btnINC.UseVisualStyleBackColor = true; + this.btnINC.CheckedChanged += new System.EventHandler(this.btnINC_CheckedChanged); + // + // btnABS + // + this.btnABS.AutoSize = true; + this.btnABS.Location = new System.Drawing.Point(15, 55); + this.btnABS.Name = "btnABS"; + this.btnABS.Size = new System.Drawing.Size(97, 24); + this.btnABS.TabIndex = 24; + this.btnABS.TabStop = true; + this.btnABS.Text = "Absolute"; + this.btnABS.UseVisualStyleBackColor = true; + this.btnABS.CheckedChanged += new System.EventHandler(this.btnABS_CheckedChanged); + // + // groubox5 + // + this.groubox5.Controls.Add(this.btnINC); + this.groubox5.Controls.Add(this.btnABS); + this.groubox5.Location = new System.Drawing.Point(686, 25); + this.groubox5.Name = "groubox5"; + this.groubox5.Size = new System.Drawing.Size(200, 100); + this.groubox5.TabIndex = 25; + this.groubox5.TabStop = false; + this.groubox5.Text = "Mode"; + // + // a1prog + // + this.a1prog.Location = new System.Drawing.Point(159, 77); + this.a1prog.Name = "a1prog"; + this.a1prog.Size = new System.Drawing.Size(193, 23); + this.a1prog.TabIndex = 35; + // + // a2prog + // + this.a2prog.Location = new System.Drawing.Point(159, 108); + this.a2prog.Name = "a2prog"; + this.a2prog.Size = new System.Drawing.Size(193, 23); + this.a2prog.TabIndex = 36; + // + // a5prog + // + this.a5prog.Location = new System.Drawing.Point(159, 195); + this.a5prog.Name = "a5prog"; + this.a5prog.Size = new System.Drawing.Size(193, 23); + this.a5prog.TabIndex = 37; + // + // a4prog + // + this.a4prog.Location = new System.Drawing.Point(159, 166); + this.a4prog.Name = "a4prog"; + this.a4prog.Size = new System.Drawing.Size(193, 23); + this.a4prog.TabIndex = 38; + // + // a3prog + // + this.a3prog.Location = new System.Drawing.Point(159, 137); + this.a3prog.Name = "a3prog"; + this.a3prog.Size = new System.Drawing.Size(193, 23); + this.a3prog.TabIndex = 39; + // + // a6prog + // + this.a6prog.Location = new System.Drawing.Point(159, 225); + this.a6prog.Name = "a6prog"; + this.a6prog.Size = new System.Drawing.Size(193, 23); + this.a6prog.TabIndex = 40; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1050, 712); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.webBrowser1); + this.Name = "Form1"; + this.Text = " "; + this.Load += new System.EventHandler(this.Form1_Load_1); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBox4.ResumeLayout(false); + this.groupBox3.ResumeLayout(false); + this.groupBox3.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.groubox5.ResumeLayout(false); + this.groubox5.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.WebBrowser webBrowser1; + private System.Windows.Forms.Button btnCLOSE; + private System.Windows.Forms.Button btnSENDDATA; + private System.Windows.Forms.ComboBox cBoxPARITYBITS; + private System.Windows.Forms.ComboBox cBoxSTOPBITS; + private System.Windows.Forms.ComboBox cBoxDATABITS; + private System.Windows.Forms.ComboBox cBoxBAUDRATE; + private System.Windows.Forms.ComboBox cBoxCOMPORT; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ProgressBar progressBar1; + private System.Windows.Forms.TextBox tBoxDATAOUT; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.Button btnOPEN; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label2; + private System.IO.Ports.SerialPort serialPort1; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.Label label18; + private System.Windows.Forms.Label label19; + private System.Windows.Forms.Label label20; + private System.Windows.Forms.Label label21; + private System.Windows.Forms.Label label22; + private System.Windows.Forms.Label label17; + private System.Windows.Forms.Label label16; + private System.Windows.Forms.Label label15; + private System.Windows.Forms.Label label14; + private System.Windows.Forms.Label label13; + private System.Windows.Forms.Label label12; + private System.Windows.Forms.GroupBox groupBox3; + private System.Windows.Forms.Button btnHOME; + private System.Windows.Forms.GroupBox groupBox4; + private System.Windows.Forms.Button btnMOVE; + private System.Windows.Forms.GroupBox groubox5; + private System.Windows.Forms.RadioButton btnINC; + private System.Windows.Forms.RadioButton btnABS; + private System.Windows.Forms.ProgressBar a6prog; + private System.Windows.Forms.ProgressBar a3prog; + private System.Windows.Forms.ProgressBar a4prog; + private System.Windows.Forms.ProgressBar a5prog; + private System.Windows.Forms.ProgressBar a2prog; + private System.Windows.Forms.ProgressBar a1prog; + } +} + diff --git a/src/firmware/arm_firmware/SerialCom1/SerialCom/Form1.cs b/src/firmware/arm_firmware/SerialCom1/SerialCom/Form1.cs new file mode 100644 index 000000000..ee959d010 --- /dev/null +++ b/src/firmware/arm_firmware/SerialCom1/SerialCom/Form1.cs @@ -0,0 +1,257 @@ +#define CRT_SECURE_NO_WARNINGS +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using System.IO.Ports; +using System.IO; + + + + +namespace SerialCom +{ + + public partial class Form1 : Form + { + + bool inc_flag; + bool abs_flag; + + const int a1_max = 360; + const int a2_max = 360; + const int a3_max = 90; + const int a4_max = 90; + const int a5_max = 90; + const int a6_max = 90; + + string dataOUT; + string homeOUT = "H"; + string moveOUT = "M"; + string inc = "I"; + string abs = "A"; + string dataIN; + + string A1; //angles + string A2; + string A3; + string A4; + string A5; + string A6; + + public Form1() + { + InitializeComponent(); + } + + private void label1_Click(object sender, EventArgs e) + { + + } + + private void progressBar1_Click(object sender, EventArgs e) + { + + } + + + + private void button1_Click(object sender, EventArgs e) + { + + } + + + private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) + { + + } + + private void groupBox1_Enter(object sender, EventArgs e) + { + + } + + private void tBoxDATAOUT_TextChanged(object sender, EventArgs e) + { + + } + + private void Form1_Load_1(object sender, EventArgs e) + { + string[] ports = SerialPort.GetPortNames(); + cBoxCOMPORT.Items.AddRange(ports); + } + + private void btnOPEN_Click(object sender, EventArgs e) + { + + try + { + serialPort1.PortName = cBoxCOMPORT.Text; + serialPort1.BaudRate = Convert.ToInt32(cBoxBAUDRATE.Text); + serialPort1.DataBits = Convert.ToInt32(cBoxDATABITS.Text); + serialPort1.StopBits = (StopBits)Enum.Parse(typeof(StopBits), cBoxSTOPBITS.Text); + serialPort1.Parity = (Parity)Enum.Parse(typeof(Parity), cBoxPARITYBITS.Text); + + serialPort1.Open(); + progressBar1.Value = 100; + } + catch (Exception err) + { + MessageBox.Show(err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void button2_Click(object sender, EventArgs e) /* Close button */ + { + if(serialPort1.IsOpen) + { + serialPort1.Close(); + progressBar1.Value = 0; + } + } + + + private void button3_Click(object sender, EventArgs e) /* send data button*/ + { + if (serialPort1.IsOpen) + { + dataOUT = tBoxDATAOUT.Text; + + if (abs_flag) + { + dataOUT = abs + dataOUT; + } + + else if(inc_flag) + { + dataOUT = inc + dataOUT; + } + + serialPort1.WriteLine(inc+dataOUT); + tBoxDATAOUT.Text = ""; + } + } + + private void label7_Click(object sender, EventArgs e) + { + + } + + private void label6_Click(object sender, EventArgs e) + { + + } + + private void absPosition_TextChanged(object sender, EventArgs e) + { + + } + + + + private void label10_Click(object sender, EventArgs e) + { + + } + + private void label11_Click(object sender, EventArgs e) + { + + } + + private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e) + { + if (serialPort1.ReadLine().Contains('r')) + { + A1 = serialPort1.ReadLine(); + A2 = serialPort1.ReadLine(); + A3 = serialPort1.ReadLine(); + A4 = serialPort1.ReadLine(); + A5 = serialPort1.ReadLine(); + A6 = serialPort1.ReadLine(); + } + } + + private void timer1_Tick(object sender, EventArgs e) + { + label11.Text = A1; + label14.Text = A2; + label16.Text = A3; + label22.Text = A4; + label20.Text = A5; + label18.Text = A6; + + if (A1 != null) + { + a1prog.Value = (int)((100 * Int64.Parse(A1)) / a1_max); + } + if (A2 != null) + { + a2prog.Value = (int)((100 * Int64.Parse(A2)) / a2_max); + } + if (A3 != null) + { + a3prog.Value = (int)((100 * Int64.Parse(A3)) / a3_max); + } + if (A4 != null) + { + a4prog.Value = (int)((100 * Int64.Parse(A4)) / a4_max); + } + if (A5 != null) + { + a5prog.Value = (int)((100 * Int64.Parse(A5)) / a5_max); + } + if (A6 != null) + { + a6prog.Value = (int)((100 * Int64.Parse(A6)) / a6_max); + } + + } + + private void button1_Click_1(object sender, EventArgs e) + { + + } + + private void button1_Click_2(object sender, EventArgs e) + { + + } + + private void label15_Click(object sender, EventArgs e) + { + + } + + private void label16_Click(object sender, EventArgs e) + { + + } + + private void button1_Click_3(object sender, EventArgs e) // HOME BUTTON // + { + serialPort1.WriteLine(homeOUT); + } + + private void btnMOVE_Click(object sender, EventArgs e) // MOTION DEMO BUTTON // + { + serialPort1.WriteLine(moveOUT); + } + + private void btnINC_CheckedChanged(object sender, EventArgs e) + { + inc_flag = !inc_flag; + } + + private void btnABS_CheckedChanged(object sender, EventArgs e) + { + abs_flag = !abs_flag; + } + } +} diff --git a/src/firmware/arm_firmware/SerialCom1/SerialCom/Program.cs b/src/firmware/arm_firmware/SerialCom1/SerialCom/Program.cs new file mode 100644 index 000000000..0eb571675 --- /dev/null +++ b/src/firmware/arm_firmware/SerialCom1/SerialCom/Program.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; + +namespace SerialCom +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/src/firmware/arm_firmware/SerialCom1/SerialCom/Properties/AssemblyInfo.cs b/src/firmware/arm_firmware/SerialCom1/SerialCom/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..7f06b7041 --- /dev/null +++ b/src/firmware/arm_firmware/SerialCom1/SerialCom/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SerialCom")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("SerialCom")] +[assembly: AssemblyCopyright("Copyright © HP Inc. 2021")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("293c7dfd-2af8-4e61-927a-46072a9f6182")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/firmware/arm_firmware/SerialCom1/SerialCom/Properties/Resources.Designer.cs b/src/firmware/arm_firmware/SerialCom1/SerialCom/Properties/Resources.Designer.cs new file mode 100644 index 000000000..001897ce9 --- /dev/null +++ b/src/firmware/arm_firmware/SerialCom1/SerialCom/Properties/Resources.Designer.cs @@ -0,0 +1,70 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +namespace SerialCom.Properties +{ + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SerialCom.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/src/firmware/arm_firmware/SerialCom1/SerialCom/Properties/Resources.resx b/src/firmware/arm_firmware/SerialCom1/SerialCom/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/src/firmware/arm_firmware/SerialCom1/SerialCom/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/firmware/arm_firmware/SerialCom1/SerialCom/Properties/Settings.Designer.cs b/src/firmware/arm_firmware/SerialCom1/SerialCom/Properties/Settings.Designer.cs new file mode 100644 index 000000000..7b0b7a545 --- /dev/null +++ b/src/firmware/arm_firmware/SerialCom1/SerialCom/Properties/Settings.Designer.cs @@ -0,0 +1,29 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +namespace SerialCom.Properties +{ + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/src/firmware/arm_firmware/SerialCom1/SerialCom/Properties/Settings.settings b/src/firmware/arm_firmware/SerialCom1/SerialCom/Properties/Settings.settings new file mode 100644 index 000000000..39645652a --- /dev/null +++ b/src/firmware/arm_firmware/SerialCom1/SerialCom/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/firmware/arm_firmware/SerialCom1/SerialCom/SerialCom.csproj b/src/firmware/arm_firmware/SerialCom1/SerialCom/SerialCom.csproj new file mode 100644 index 000000000..77021c8c6 --- /dev/null +++ b/src/firmware/arm_firmware/SerialCom1/SerialCom/SerialCom.csproj @@ -0,0 +1,78 @@ + + + + + Debug + AnyCPU + {293C7DFD-2AF8-4E61-927A-46072A9F6182} + WinExe + SerialCom + SerialCom + v4.0 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + \ No newline at end of file diff --git a/src/firmware/arm_firmware/switchInterfaceSketch/switchInterfaceSketch.ino b/src/firmware/arm_firmware/switchInterfaceSketch/switchInterfaceSketch.ino new file mode 100644 index 000000000..e5f3a19c0 --- /dev/null +++ b/src/firmware/arm_firmware/switchInterfaceSketch/switchInterfaceSketch.ino @@ -0,0 +1,482 @@ +/* +Created By: Tate Kolton, Rowan Zawadzki +Created On: December 21, 2021 +Updated: April 27, 2022 +Description: Main code for driving 6 axis robotic arm using Nintendo Switch pro (or any XInput type) Controller +*/ + +#include + +// general parameters +#define NUM_AXES 6 +#define NUM_AXES_EX_WRIST 4 +#define NUM_AXES_EFF 8 +#define NUM_PARAMS 7 +#define ON 0 +#define OFF 1 +#define SW_ON 0 +#define SW_OFF 1 +#define FWD 1 +#define REV 0 + +// motor pins +// **NOTE** axis 3 and 4 are switched and axis 5 and 6 are switched. i.e. stepPins[3] is not axis 4, it is axis 3 +int stepPins[8] = {11, 9, 5, 7, 1, 3, 1, 3}; +int dirPins[8] = {10, 8, 4, 6, 0, 2, 0, 2}; + +// limit switch pins +int limPins[6] = {23, 22, 20, 21, 18, 19}; + +// pulses per revolution for motors +long ppr[6] = {400, 400, 400, 400, 400, 400}; + +// Gear Reduction Ratios +float red[6] = {30.0, 161.0, 44.8, 100, 57.34, 57.34}; + +// Encoder pulses per revolution +long pprEnc = 512; + +// Motor speeds and accelerations +int maxSpeed[8] = {1200, 1800, 3000, 2500, 2200, 2200, 2200, 2200}; +int maxAccel[8] = {900, 3000, 4000, 3000, 5000, 5000, 5000, 5000}; +int homeSpeed[8] = {500, 1200, 600, 400, 2000, 2000, 2000, 2000}; // {500, 1500, 700, 1200, 1200, 1200, 1200, 1200}; +int homeAccel[8] = {500, 2000, 1500, 1000, 1500, 1500, 1500, 1500}; //{500, 2000, 1000, 1500, 1500, 1500, 1500, 1500}; + +// Range of motion (degrees) for each axis +int maxAngles[6] = {180, 70, 180, 120, 140, 100}; + +const unsigned long readInterval = 10; +unsigned long currentTime; +unsigned long previousTime = 0; + +// stepper motor objects for AccelStepper library +AccelStepper steppers[8]; + +// variable declarations +long max_steps[] = {red[0]*maxAngles[0]/360.0*ppr[0], red[1]*maxAngles[1]/360.0*ppr[1], red[2]*maxAngles[2]/360.0*ppr[2], red[3]*maxAngles[3]/360.0*ppr[3], red[4]*maxAngles[4]/360.0*ppr[4], red[5]*maxAngles[5]/360.0*ppr[5]}; +int axisDir[8] = {1, -1, 1, -1, 1, 1, -1, 1}; +int currentAxis = 1; +int runFlags[] = {0, 0, 0, 0, 0, 0}; +int i; +static const char fwdValues[] = {'a', 'b'}; +static const char revValues[] = {'c', 'd'}; +static const char fwdWrist[] = {'f', 'g'}; +static const char revWrist[] = {'h', 'i'}; +static const char axisSelect[] = {'m', 'm', 'n', 'n'}; +static const char releaseChars[] = {'q', 'r', 'q', 'r'}; +static const char wristRelease[] = {'j', 'k'}; +static const char homeVal = 'z'; +char garbage; +bool initFlag = false; + +// variables for homing / arm calibration +long homePosConst = -99000; +long homePos[] = {axisDir[0]*homePosConst, axisDir[1]*homePosConst, axisDir[2]*homePosConst, axisDir[3]*homePosConst, axisDir[4]*homePosConst, axisDir[5]*homePosConst, axisDir[6]*homePosConst, axisDir[7]*homePosConst}; +long homeCompAngles[] = {axisDir[0]*90, axisDir[1]*5, axisDir[2]*93, axisDir[3]*12, axisDir[4]*102, axisDir[5]*102, axisDir[6]*80, axisDir[7]*80}; +long homeCompConst[] = {2000, 2000, 1000, 500, 500, 500, 500, 500}; +long homeComp[] = {axisDir[0]*homeCompConst[0], axisDir[1]*homeCompConst[1], axisDir[2]*homeCompConst[2], axisDir[3]*homeCompConst[3], axisDir[4]*homeCompConst[4], axisDir[5]*homeCompConst[5], axisDir[6]*homeCompConst[6], axisDir[7]*homeCompConst[7]}; +long homeCompSteps[] = {homeCompAngles[0]*red[0]*ppr[0]/360.0, homeCompAngles[1]*red[1]*ppr[1]/360.0, homeCompAngles[2]*red[2]*ppr[2]/360.0, homeCompAngles[3]*red[3]*ppr[3]/360.0, homeCompAngles[4]*red[4]*ppr[4]/360.0, homeCompAngles[5]*red[5]*ppr[5]/360.0, homeCompAngles[6]*red[4]*ppr[4]/360.0, homeCompAngles[7]*red[5]*ppr[5]/360.0}; +char value; + +// values for changing speed +const int maxSpeedIndex = 2; +int speedVals[maxSpeedIndex+1][NUM_AXES_EFF] = {{600, 900, 1500, 1250, 1050, 1050, 1050, 1050}, {900, 1200, 2000, 1665, 1460, 1460, 1460, 1460}, {1200, 1800, 3000, 2500, 2200, 2200, 2200, 2200}}; +int speedIndex = maxSpeedIndex; +char faster = 'l'; +char slower = 's'; + +void setup() { // setup function to initialize pins and provide initial homing to the arm + + Serial.begin(9600); + + // initializes step pins, direction pins, limit switch pins, and stepper motor objects for accelStepper library + for(i = 0; i readInterval) { + if(Serial.available() > 0){ + + value = Serial.read(); + controllerParse(value); + } + + previousTime = currentTime; + } + + runSteppers(); +} + +void controllerParse(char data) { // parses incoming serial data to control arm motion based on user input + + // left joystick forward + if(data == 'a') { + runAxes(FWD, currentAxis); + } + // left joystick reverse + else if(data == 'b') { + runAxes(REV, currentAxis); + } + // right joystick forward + else if(data == 'c') { + runAxes(FWD, currentAxis+1); + } + // right joystick reverse + else if(data == 'd') { + runAxes(REV, currentAxis+1); + } + // wrist pitch forward + else if(data == 'f') { + runWrist(FWD, 5); + } + // wrist pitch reverse + else if(data == 'h') { + runWrist(REV, 5); + } + // wrist roll forward + else if(data == 'g') { + runWrist(FWD, 6); + } + // wrist roll reverse + else if(data == 'i') { + runWrist(REV, 6); + } + else if(data == 'z') { + homeArm(); + } + else { + releaseEvent(data); + changeAxis(data, currentAxis); + changeSpeed(data); + } +} + +void runAxes(int dir, int axis) { // assigns run flags to indicate forward / reverse motion and sets target position + + if(axis == 3) { + dir = !dir; + } + + if(runFlags[axis-1] == 1 && dir == FWD) { + } + + else if(runFlags[axis-1] == -1 && dir == REV) { + } + + else if(dir == FWD) { + steppers[axis-1].moveTo(max_steps[axis-1]*axisDir[axis-1]); + runFlags[axis-1] = 1; + } + + else { + steppers[axis-1].moveTo(0); + runFlags[axis-1] = -1; + } +} + +void runWrist(int dir, int axis) { // assigns target position for selected axis based on user input. + + if(axis == 5) { // axis 5 motion -> both wrist motors spin in opposite directions + if(runFlags[5] == 1 && dir == FWD) { + } + + else if(runFlags[5] == -1 && dir == REV) { + } + + else if(dir == FWD) { + steppers[6].moveTo(axisDir[6]*max_steps[5]); + steppers[7].moveTo(axisDir[7]*max_steps[5]); + runFlags[5] = 1; + } + + else { + steppers[6].moveTo(0); + steppers[7].moveTo(0); + runFlags[5] = -1; + } + } + + else if(axis == 6) { // axis 6 motion -> both wrist motors spin in same direction + dir = !dir; + if(runFlags[4] == 1 && dir == FWD) { + } + + else if(runFlags[4] == -1 && dir == REV) { + } + + else if(dir == FWD) { + steppers[4].moveTo(axisDir[4]*max_steps[4]); + steppers[5].moveTo(axisDir[5]*max_steps[4]); + runFlags[4] = 1; + } + + else { + steppers[4].moveTo(0); + steppers[5].moveTo(0); + runFlags[4] = -1; + } + } +} + +void changeAxis(char value, int axis) { // when user hits specified button, axis targets change + + for(i=0; i 0) { + speedIndex--; + for(i=0;i0){ + char init = Serial.read(); + if(init == 'z') { + initFlag = true; + homeArm(); + } + } + delay(readInterval); + } +} + + + + diff --git a/src/firmware/arm_firmware/testingInterfaceSketch/testingInterfaceSketch.ino b/src/firmware/arm_firmware/testingInterfaceSketch/testingInterfaceSketch.ino new file mode 100644 index 000000000..bdcfbd2f7 --- /dev/null +++ b/src/firmware/arm_firmware/testingInterfaceSketch/testingInterfaceSketch.ino @@ -0,0 +1,328 @@ +/* +Created By: Tate Kolton, Rowan Zawadzki +Created On: December 21, 2021 +Description: Main code for testing 6-axis stepper motor driven arm functionality. Interfaces with windows form through serial communication. Intended for use with Teensy 4.1 +Warning: May run into errors if attempting to use with Arduino Mega, Uno, or Nano. Insufficient DRAM / Flash, and clock speed. +*/ + +#include + +// general parameters +#define NUM_AXES 6 +#define NUM_PARAMS 7 +#define ON 0 +#define OFF 1 +#define SW_ON 0 +#define SW_OFF 1 + +// motor pins +int stepPins[6] = {3, 5, 6, 8, 10, 12}; +int dirPins[6] = {4, 7, 9, 11, 13, 14}; + +// limit switch pins +int limPins[6] = {15, 16, 17, 18, 19, 20}; + +// pulses per revolution for motors +long ppr[6] = {400, 400, 400, 400, 400, 400}; + +// Gear Reduction Ratios +long red[6] = {40, 161, 150, 70, 45, 45}; + +// Encoder pulses per revolution +long pprEnc = 512; + +// Motor speeds and accelerations +int maxSpeed[6] = {3000, 3000, 3000, 3000, 3000, 3000}; +int maxAccel[6] = {4000, 4000, 4000, 4000, 4000, 4000}; +int homeSpeed[6] = {1000, 1000, 1000, 1000, 1000, 1000}; +int homeAccel[6] = {2000, 2000, 2000, 2000, 2000, 2000}; + +// Range of motion (degrees) for each axis +long maxAngles[6] = {180, 120, 120, 120, 120, 120}; + +// stepper motor objects for AccelStepper library +AccelStepper steppers[6]; + +// variable declarations +int i, count, axis, temp, flag, sign,int_ang; +long angle; +char axisC, garbage, mode, serialBit; +String char_angle; +long angles[] = {0, 0, 0, 0, 0, 0}; +long max_steps[] = {red[0]*maxAngles[0]/360.0*ppr[0], red[1]*maxAngles[1]/360.0*ppr[1], red[2]*maxAngles[2]/360.0*ppr[2], red[3]*maxAngles[3]/360.0*ppr[3], red[4]*maxAngles[4]/360.0*ppr[4], red[5]*maxAngles[5]/360.0*ppr[5]}; +int axisDir[6] = {1, 1, 1, 1, 1, 1}; + +// variables for homing / arm calibration +long homePosConst = -100000; +long homeCompConst = 500; +long homePos[] = {axisDir[0]*homePosConst, axisDir[1]*homePosConst, axisDir[2]*homePosConst, axisDir[3]*homePosConst, axisDir[4]*homePosConst, axisDir[5]*homePosConst}; +long homeComp[] = {axisDir[0]*homeCompConst, axisDir[1]*homeCompConst, axisDir[2]*homeCompConst, axisDir[3]*homeCompConst, axisDir[4]*homeCompConst, axisDir[5]*homeCompConst}; +long homeCompAngles[] = {axisDir[0]*25, axisDir[1]*25, axisDir[2]*25, axisDir[3]*25, axisDir[4]*25, axisDir[5]*25}; +long homeCompSteps[] = {homeCompAngles[0]*red[0]*ppr[0]/360.0, homeCompAngles[1]*red[1]*ppr[1]/360.0, homeCompAngles[2]*red[2]*ppr[2]/360.0, homeCompAngles[3]*red[3]*ppr[3]/360.0, homeCompAngles[4]*red[4]*ppr[4]/360.0, homeCompAngles[5]*red[5]*ppr[5]/360.0}; + +// setup function to initialize pins and provide initial homing to the arm +void setup() { + + Serial.begin(9600); + flag = 0; + + // initializing steppers + for(int i=0; i 0) { // parsing of incoming serial data + char first = Serial.read(); + + if (first == 'H') { + home_arm(); + } + + else { + flag = 1; + mode = Serial.read(); + delay(10); + garbage = Serial.read(); + delay(10); + axisC = Serial.read(); + axis = axisC - '0'; + delay(10); + char_angle = Serial.readStringUntil('\n'); + int_ang = char_angle.toInt(); + angle = (long)int_ang; + + while (Serial.available() > 0) { + char bufferGarbage = Serial.read(); + } + } + } + + if (flag == 1) { + step_angle(axis, angle, red[axis-1], ppr[axis-1], maxAngles[axis-1]); + flag = 0; + } + + delay(100); +} + +// functions for arm motion +void step_angle(int axis, long ang, long red, long ppr, long max_ang) { + + long step_in; + + if (mode == 'I') { + step_in = red*ppr*(ang / 360.0); + + if(ang == 0) { + } + + else if(ang + angles[axis-1] < max_ang && ang + angles[axis-1]>0) { + angles[axis - 1] += ang; + } + + else { + if(ang>0) { + step_in = (red*ppr/360.0)*(max_ang - angles[axis-1]); + angles[axis-1] = max_ang; + } + + else { + step_in = -(red*ppr/360.0)*angles[axis-1]; + angles[axis-1] = 0; + } + } + + step_in = step_in*axisDir[axis-1]; + incMove(axis, step_in); + } + + else if (mode == 'A') { + + if(ang<=0) { + step_in = 0; + angles[axis-1] = 0; + } + + else if(ang>=max_ang) { + step_in = red*ppr/360.0*max_ang; + angles[axis-1] = max_ang; + } + + else { + step_in = red*ppr*ang/360.0; + angles[axis - 1] = ang; + } + + step_in = step_in*axisDir[axis-1]; + absMove(axis, step_in); + } + + limTrig(axis); + sendAngles(); +} + +// Function for homing of full arm +void home_arm() { + + bool stopFlags[6] = {false, false, false, false, false, false}; + bool finishFlags[6] = {false, false, false, false, false, false}; + bool completeFlag = false; + int count = 0; + initializeHomingMotion(); + + while(!completeFlag) { + + for(i = 0; i