Code generation for non-flex boards

A forum useful to discuss the details of the ScicosLab code generator.

Moderator: paolo.gai

Locked
harini
Newbie
Posts: 9
Joined: Mon Apr 09, 2012 8:23 pm

Code generation for non-flex boards

Post by harini » Mon Apr 09, 2012 11:52 pm

Hello,

I am new to SCICOS. I wanted to model and develop control algorithms for dsPIC. I do not have a FLEX board with me. The dsPIC30f/33f is on a breadboard which is interfaced with the necessary peripherals. I have the following installed on my windows 7 64 bit machine.

1. MPLAB IDE 8.63 with MPLAB C30 compiler lite version. (I have an ICD3 device).
2. Microsoft Visual studio 2010 vc++ express
3. SCICOSLAB 4.4.1
4. JRE and JAVA with versions.
(java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b05)
Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01, mixed mode))
5. Cygwin (eeCygwin_1_7_9)
6. RT Druid (EE_RT-Druid-1.6.1-indigo-SR2-win32)
I am able to generate code for dsPIC for the FLEX board and compile them.

Since I do not have the FLEX board, I wanted to generate code that can be downloaded to the target (dspic30f or dspic33f) on my breadboard. Could you please let me know if this is possible and the ways to do it?
I referred to the document "http://erika.tuxfamily.org/wiki/index.p ... LEX_boards" and I did not quite understand the point "change the code to reflect your board configuration".
I tried changing the template as mentioned. I restarted SCICOSLAB and I opened an example model. I did not get the option "myboard" while setting the target. Please forgive me if I am asking a lot of questions.
I am also planning to use my own kernel developed for dsPIC. Since SCICOS is open-source, I thought I could test my kernel for real time control applications which can be developed faster in SCICOS. Please share any documents that can be used by developers.

Thanks for your time.

Regards,
Harini

erikadds
Newbie
Posts: 45
Joined: Wed May 12, 2010 9:41 am

Re: Code generation for non-flex boards

Post by erikadds » Tue Apr 10, 2012 10:15 am

Hi,
to create a new template just follow the steps at:

http://erika.tuxfamily.org/wiki/index.p ... LEX_boards

The point "change the code to reflect your board configuration" means that you will need
to edit two files "conf_scicos.oil" and "dspic_main.c", so that they are compatible with the new board.
To see the name of your board in the target settings you must add the board name in the list of templates.
I apologize if this step is not described in the web page. It will be added as soon as possible.
To add the template you have just to edit the file

SCI + / contrib / scicos_ee / scicos_flex / dsPIC / macros / codegen / SetTarget_.sci

and change the string templates as follows:

lab_template = ['board_flex', 'board_easylab', 'myboard'];

At this point you need to recompile all the files by running "builder.sce".
These steps should make it possible to compile an EE application based on a custom board.

Using the code generator for applications that not use Erika but use your kernel, is a more difficult problem at the moment
because you must also modify the scripts that launch the compilation and you must use your own makefile.
To understand the compilation chain you can refer to the file

SCi + / contrib / scicos_ee / scicos_flex / dsPIC / compile.sh

To simplify all these steps, we are now developing a new code generator for Scicos, more optimized and flexible.
We are currently following a completely new approach, and we are going to release something soon.
Le us know if you need more information ...

Regards,
DDS

harini
Newbie
Posts: 9
Joined: Mon Apr 09, 2012 8:23 pm

Re: Code generation for non-flex boards

Post by harini » Tue Apr 10, 2012 5:12 pm

Hello,

Thanks for your reply.

I tried the following.
1. I modified the template.xml to have ID = "myboard"
2. I modified the corresponding dspic_main.c and conf.oil files in the same directory. (C:\Program Files\scicoslab-4.4.1\contrib\scicos_ee\RT-Druid\plugins\com.eu.evidence.ee.templates.dspic_1.6.0.20120209_1832\examples\pic30\myboard)
3. I modified the SetTarget_.sci to include the "myboard" template.
3. I compiled all the files by exec('builder.sce') in scicos prompt.
4. Then I opened an example model for FLEX and specified the target as "myboard".
5. I generated the code with the following error.

[EXAMPLE WRITER Search Template (ID = myboard) ..
[ ... FOUND]
[TEMPLATE pic30/Empty - myboard]
[COPY .\conf.oil]
[COPY .\dspic_main.c]
cat: conf_scicos.oil: No such file or directory

Could you please tell me if I am going wrong somewhere?
Thanks for your help
Harini

erikadds
Newbie
Posts: 45
Joined: Wed May 12, 2010 9:41 am

Re: Code generation for non-flex boards

Post by erikadds » Thu Apr 12, 2012 9:32 am

As you can see in the file 'compile.sh', the compilation chain needs the 'conf_scicos.oil' file to start the parsing using the preprocessor of the compiler.
You probably don't need to change the file compile.sh, you can rename your 'conf.oil' file with the name 'conf_scicos.oil'.
Note: you can't use the FLEX blocks if you use a custom board. You can use instead the blocks of MCHP16-* palettes or custom blocks.

I hope this helps.
Regards,
Dario

paolo.gai
Administrator
Posts: 858
Joined: Thu Dec 07, 2006 12:11 pm

Re: Code generation for non-flex boards

Post by paolo.gai » Fri Apr 13, 2012 3:17 pm

You ave probably removed the conf_scicos.oil rom the template directory. if you did so, you also need to modify the template.xml file on the same directory to list the files which need to be copied.

PJ

harini
Newbie
Posts: 9
Joined: Mon Apr 09, 2012 8:23 pm

Re: Code generation for non-flex boards

Post by harini » Thu Apr 26, 2012 10:49 pm

Hello,

I created new blocks for ADC and UART_TX. I used them in the scicos diagram. I tried generating code for my custom "dspic_board". These are the steps I followed and I get the error as specified in the attached image.

1. I wrote the ADC.sci and UART_TX.sci and placed it in "C:\Evidence\scicoslab-4.4.1\contrib\scicos_ee\scicos_flex\dspic\macros\flex_blocks\DSPIC_TGT_BLK"
2. I placed the corresponding ADC.c and UART_TX.c files in "C:\Evidence\scicoslab-4.4.1\contrib\scicos_ee\ee\contrib\scicos\src\pic30"
3. I modified the SetTarget_.sci file to include the "dspic_board".

I have a scicos diagram which includes these new blocks. I generate code for the custom board and I get the error as given in the attachment.

Please let me know if anything needs to be done. I can send the source files if needed.

Thanks a lot for all your timely help.
Regards,
Harini
Attachments
Code_generation_error_document
Code_generation_error_document
code_generation_error.PNG (107.43 KiB) Viewed 4199 times

erikadds
Newbie
Posts: 45
Joined: Wed May 12, 2010 9:41 am

Re: Code generation for non-flex boards

Post by erikadds » Fri Apr 27, 2012 5:27 pm

Hi,
could you send me a zip of the project using a private message?
I need to replicate the error to understand the cause.

DDS

paolo.gai
Administrator
Posts: 858
Joined: Thu Dec 07, 2006 12:11 pm

Re: Code generation for non-flex boards

Post by paolo.gai » Sat Apr 28, 2012 7:38 am

As Dario said, you can integrate the code generator with your own kernel... it's just a matter of integrating the various files all together, and write all the C files for the blocks yo will use in the diagram.

About the error you had: it must be something strange I guess in the OIL file. I see the name of the template is "DSPIC empty"... hmmm... maybe you should start from the "board_flex" template under .../examples/pic30/pic30_scicos . Does that one works? (it should...)

Ciao,

PJ

harini
Newbie
Posts: 9
Joined: Mon Apr 09, 2012 8:23 pm

Re: Code generation for non-flex boards

Post by harini » Tue May 01, 2012 11:19 pm

Hello,

I followed the steps to generate and compile the code for my custom dspic application. I could not get to compile it without the error. This is how the app.mk file looks like once I start generating the code.

EEOPT += __NO_MALLOC__
EEOPT += MODELNAME=SuperBlock
EEOPT += __USE_DSPIC_BOARD__ \
__USE_TGT_BLK_UART_TX__ \
__USE_TGT_BLK_ADC__
EE_SRCS_SCICOS := dspic_tgt_blk_uart_tx.c \
dspic_tgt_blk_adc.c \
gainblk.c \
dmmul.c
APP_SRCS += SuperBlock.c

But, the C source files listed in the app.mk does not get compiled at all. Due to this, I get the linker error for all the functions implemented in these files.
I also modified the cfg.mk file to include the files that I added for the blocks. Please let me know if anything else has to be done. I am also surprised that the gainblk.c does not get compiled in the process.
To prevent this error for the time being, I included the EE_SRCS_SCICOS files for compilation in the conf_scicos.oil. This works for the time being.
I wanted to know the permanent fix for the problem. Please help me in this regard.
Thanks,
Harini

paolo.gai
Administrator
Posts: 858
Joined: Thu Dec 07, 2006 12:11 pm

Re: Code generation for non-flex boards

Post by paolo.gai » Fri May 04, 2012 11:21 am

The last screenshot you sent is related to an error in the counter data structures. this is quite strange, maybe it is due to hand changing the files generated by RT-Druid.

To understand the problem, we need to get the OIL file you are trying to compile.

Another option could be that you could just modify the gain blocks we ship with the distribution.

Ciao,

Paolo

harini
Newbie
Posts: 9
Joined: Mon Apr 09, 2012 8:23 pm

Re: Code generation for non-flex boards

Post by harini » Fri May 04, 2012 6:57 pm

Hello,

Here is the conf_scicos.oil file that I have to generate the code for dsPIC application.


/* This is the new OIL file for the dsPIC custom board */
CPU mySystem {
OS myOS {
EE_OPT = "DEBUG";
EE_OPT = "NODEPS";
EE_OPT = "__ADD_LIBS__";
EE_OPT = "__C30__";
EE_OPT = "__dsPIC30F__";
EE_OPT = "__USE_DSPIC_BOARD__";
CFLAGS = "-I $(PIC30_GCCDIR)/support/h";
#ifdef __USE_DSPIC_BOARD__
LIB = ENABLE {
NAME = "DSPIC_TGT_BLK";
};
#endif
CPU_DATA = PIC30{
APP_SRC = "dspic_main.c";
APP_SRC = "common.c";
APP_SRC = "dspic_tgt_blk_uart_tx.c"; /* I am including this since this does not get compiled even if the app.mk file lists this. */
APP_SRC = "dspic_tgt_blk_adc.c"; /* I am including this since this does not get compiled even if the app.mk file lists this. */
MULTI_STACK = FALSE;
ICD2 = TRUE;
};
MCU_DATA = PIC30 {
MODEL = PIC30F4012;
};

BOARD_DATA = NO_BOARD;
LIB = ENABLE {
NAME = "SCICOS";
};
KERNEL_TYPE = FP;
};
};

Please let me know if anything is wrong.
Thanks,
Harini

harini
Newbie
Posts: 9
Joined: Mon Apr 09, 2012 8:23 pm

Re: Code generation for non-flex boards

Post by harini » Sat May 05, 2012 4:21 am

Hello,

I am able to generate code now. I had a wrong cfg.mk file. Thank you all for the timely help.

Thanks,
Harini

paolo.gai
Administrator
Posts: 858
Joined: Thu Dec 07, 2006 12:11 pm

Re: Code generation for non-flex boards

Post by paolo.gai » Mon May 07, 2012 9:52 am

Good!

PJ

Locked