/// <summary>
 /// Move the motor to a specific position
 /// </summary>
 /// <param name="pos">Position where the motor needs to go to</param> <!-- need to explain more about the value and if there is a max? -->
 public bool SetPosition(int pos)
 {
     if (ticController.get_variables())
     {
         if (ticController.status_vars.energized)
         {
             // Check if the pos is less than 0 as the motors home value should always be 0
             if (pos <= 0)
             {
                 pos = 0;
             }
             ticController.set_target_position(pos);
             while (ticController.get_variables())
             {
                 if (ticController.vars.current_position == pos)
                 {
                     break;
                 }
             }                                                                                                //
         }
         else
         {
             return(false);
         }
     }
     return(true);
 }
예제 #2
0
 private void buttonGoto_Click(object sender, EventArgs e)
 {
     if (m_moving == false)
     {
         m_tic.set_max_speed((int)numericUpDownSpeed.Value);
         m_tic.set_target_position((int)numericUpDownPosition.Value);
         m_moving        = true;
         buttonGoto.Text = "STOP";
     }
     else
     {
         m_tic.halt_and_hold();
         buttonGoto.Text = "GOTO";
         m_moving        = true;
     }
     buttonHome.Enabled       = !m_moving;
     checkBoxJogLeft.Enabled  = !m_moving;
     checkBoxJogRigth.Enabled = !m_moving;
 }