set order of multiple extern function block

Nico_21802
Nico_21802 Altair Community Member
edited July 2023 in Community Q&A

Hello, I would like to implement the below C code from the Arduino IDE in Altair Embed for research purposes.
Two questions:

Is it possible to specify the order of calls for multiple external function blocks in embed? 

The order of the function calls is in the c code.

How can I implement the delay function from the Arduino IDE in Embed?

 

Thanks for the help

volatile float z=0;  //////functions////////////////// void Schleife(void){   for(unsigned int a=0;a<500;a++){      z=z+1;  } }  void zNull(void){   z=0; }   //////////////////////////////////  void setup() {}    void loop()  {    digitalWrite(49, HIGH);           Schleife();     zNull();      digitalWrite(49, LOW);         delay(1); }   

Attachment: vsm file

Tagged:

Answers

  • Sreeram Mohan_20368
    Sreeram Mohan_20368
    Altair Employee
    edited June 2023

    Hi Nico,

    There are couple of ways to get what you want. Here is one method if you still want to write code in extern blocks as you do in this case. I however recommend that you consider modelling the c based logic in embed natively itself . Let me know if you need help there. 

    Now back to your question. You could schedule a collection of blocks which is a compound block on various ways. Either at regular time intervals like what you need here or via an interrupt ..etc. 

    Here are the steps : 

    * Select the blocks that you would want to combine into a compound and right click and create a compound . 

    image

    * This will create a compound block and then you could CTRL + RIGHT CLICK  to bring up the dialog as below. Please note the Local Time step (sec) where you could input the value 1 . This means the compound block would be called at every 1 second. 

     

    image

     

    Also attached is the diagram that is modified. 

    hope this helps,

    --sreeram 

  • Nico_21802
    Nico_21802 Altair Community Member
    edited July 2023

    Hello Sreeram Mohan,

    Thanks for your help.

    How can I program the c based logic in embed natively with the c code shown?

    Is there an easier way without the external blocks?

    Thank you and best regards Nico

  • Sreeram Mohan_20368
    Sreeram Mohan_20368
    Altair Employee
    edited July 2023

    Hi Nico, 

    Please see if the attached diagram provides some help ?

    --sreeram