Does Altair Embed suitable for programing robot?

Phan Truong
Phan Truong Altair Community Member
edited May 2021 in Community Q&A

Hi Community, I have a project relate about robot arm. In Arduino code, i have a matrix, with rows to represent state of robot, columns to represent angle of joints. This is 2D matrix. I can controller my stepper motor easily and sweep state of robot with for loop. But in Embed, I find it very complicated. I don't know how to control the motors in turn when i give it step.

Can someone help with a solution ??

 

Answers

  • Mayank  Das
    Mayank Das New Altair Community Member
    edited May 2021

    Hello Phan,

     

    I am sure we can help you run those stepper motors very easily. It should not be complicated at all. 

    Can you please share some more details as to what motor are you using and how are you expecting it to run. What are the signals you provide for control?

    If possible please attach any .vsm file here that you may have been working on and we will help you solve your problems.

     

    Regards,

    Mayank

  • Phan Truong
    Phan Truong Altair Community Member
    edited May 2021

    Hello Phan,

     

    I am sure we can help you run those stepper motors very easily. It should not be complicated at all. 

    Can you please share some more details as to what motor are you using and how are you expecting it to run. What are the signals you provide for control?

    If possible please attach any .vsm file here that you may have been working on and we will help you solve your problems.

     

    Regards,

    Mayank

    Thanks for your reply.

    First, I want control position of stepper motor using Embed. In arduino code. I have a for loop, with each loop is a pulse. For instance:

    for (int k = 0; k < b; k++){
      digitalWrite(stepPin[j],HIGH);
      delayMicroseconds(500);
      digitalWrite(stepPin[j],LOW);
      delayMicroseconds(500);
      }
     
     
    But in Embed, i don't know how to create a for loop to do this. I intend create square wave and count it to control motor. Does it feasible?
  • Mayank  Das
    Mayank Das New Altair Community Member
    edited May 2021

    1. Make sure to select 'Arduino' from supported target while installing Embed.

    2. Find 'Arduino Config' block under Embedded>>Arduino>>Arduino Config... 

    image

    3. Find 'Digital Output' block under Embedded>>Arduino>Digital I/O>>Digital Output. Right click on the block to select your I/O pin.

    image

    4. Create a diagram using 'square wave' block. Right click on it to change the pulse time.

    image

    5. Go to Tools>>Code Gen. Select your Target as Arduino. Click on 'Compile...' and then click on 'Download...'

    This should get you started with a simple example.

    PS - You can change start and end time in System>System Properties... 

    Try different examples for PWM, Blinking LED etc under Examples>>Embedded>>Arduino>>

  • Phan Truong
    Phan Truong Altair Community Member
    edited May 2021
    Yep. I know that but i have 2 stepper motor and each motor have different step. How can i solve that problem?
  • Sreejith_21826
    Sreejith_21826 New Altair Community Member
    edited May 2021

    Hello Phan,

    Are you using an external library to control the stepper motor.

    If so, please refer our External library import example and make use of "Extern" blocks under Arduino.

    Examples located in Examples->Embedded->Arduino->External Library Import->

    Or Can you please share your code, we can create a .vsm diagram for you.

    Will share you a simple stepper motor control diagram shortly.

  • Phan Truong
    Phan Truong Altair Community Member
    edited May 2021

    Hi Sreejith,

     

    Thank you for your response. Here is my arduino code:

    https://github.com/pductruong/Arm_project/blob/master/single_step/single_step.ino

    My hardware include arduino, stepper motor Nema 17, driver TB6600 and servo MG996R.