Adding blocks

Forum related to the FLEX boards

Moderator: paolo.gai

Locked
bbonsen
Newbie
Posts: 3
Joined: Tue Aug 28, 2007 1:43 pm

Adding blocks

Post by bbonsen » Wed Oct 24, 2007 10:46 am

Is it possible to create new Scicos blocks for the flex board?
If so, what do I need to compile these?

What I want to make is a frequency counter.

Regards,

Bram

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

Re:Adding blocks

Post by paolo.gai » Tue Oct 30, 2007 9:12 pm

Hi!

sorry for the late response... I was out of town from last wednesday...

yes, it is possible to add new Scicos blocks... You can take as an examnple the existing blocks...

Basically each block is made of two separate parts:

- one part which is the Scicos implementation, that is the graphical description used in Scicos. It is written in the Scilab language, and we usually got it already made from Roberto...

- the second part is the C implementation of the block, that is the code executed when running the particular block instance. In that case, you can find it into the contrib directory of the ERIKA Enterprise installation

How many inputs/outputs do you need?

And... what kind of application are you developing (if you can disclose that info...)?

bye

PJ

bbonsen
Newbie
Posts: 3
Joined: Tue Aug 28, 2007 1:43 pm

Re:Adding blocks

Post by bbonsen » Wed Oct 31, 2007 1:53 pm

Thanks for the information, what I need is a frequency counter (I am building a transmission control unit, therefore I need to measure engine RPM from a TTL signal) The dsPic has a Input Capture function that I want to use for this, and I would like to use the FLEX software/hardware, but the frequency counter is missing.


Bram

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

Re:Adding blocks

Post by paolo.gai » Wed Oct 31, 2007 2:17 pm

Hi Bram,

Ok...

let\'s say there are two phases:

the first one is to build a block in Scicos which can be used as a frequency counter. What we need to know in this phase is how many:
- inputs ports
- output ports
- internal parameters
you will need.

I guess the following:
- 0 input ports (the input comes from the hardware, like in the GPIN module)
- 1 output port (the frequency output)
- 1 internal parameter (a number to address the hardware pin,like in the GPIN block)

I talked to Roberto, What we culd do is that we could build a block with the needed pins, to be integrated into the scicos pack

Then, the second part is writing the code. There are already examples for that in the blocks existing for the Scicos FLEX.

The only thing I have to ask in this case is about the license of the software you\'ll produce. If it is going to be a contribution to the project, then we\'ll need your license to be able to both include the software in the free version as well as the possibility to use it inside commercial applications (I hope this will not be a problem)

Then, once done, we\'ll release an enhanced version of the Scicos Pack with your contribution, plus other things we are adding (notably, there is already a buzzer block we will be using in the demo at the EU MASTERS next tuesday in Munich :-) )

bye

PJ

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

Re:Adding blocks

Post by paolo.gai » Fri Nov 02, 2007 9:13 am

Hi Bram,

here is a step by step guide on how to add a new block to the Scicos-Flex palette. They are just notes taken while I was doing it, and are a result of a few mail exchanges tonight with Roberto.

Of course, all the thanks goes to Roberto Bucher for all this, not to me :-)

The steps
-------------------------------

0) Preface
0.a) Directory names are the directory names of my laptop...
0.b) Use the zip file attached. for each step, there are a few files to look at :-)
0.c) I had to edit the post to substitute backslash with slashes :-(

1) NMake
1.a) install NMake from
http://support.microsoft.com/default.as ... us;Q132084
1.b) rename the executable file in nmake.exe and copy it into C:/Windows

2) Update the files
2.a) copy dspic_getfreq.sci into
C:/Programmi/scilab-4.1.1/contrib/dspic/macros
2.b) add into the C:/Programmi/scilab-4.1.1/contrib/dspic/macros/name
one line with the file name
2.c) in C:/Programmi/scilab-4.1.1/contrib/dspic/bulder.sce , we have to
comment a few lines, because we are not going to compile the .c files
distributed with the package. in particular, comment from the line
\"cd(ROUTINES)\"
to the one but last line (leave only the \"cd(\'..\')\"

3) Compile
3.a) open scilab 4.1.1
3.b) from the scilab console, \"cd c:/Programmi/scilab-4.1.1/contrib/dspic\"
3.c) from the scilab console, \"exec builder.sce\"
3.d) you get the following output

--------------------------------------------------------------------
___________________________________________
scilab-4.1.1

Copyright (c) 1989-2007
Consortium Scilab (INRIA, ENPC)
___________________________________________


Startup execution:
loading initial environment
shared archive loaded
Link done

Scicos-FLEX Ready

-->cd c:/Programmi/scilab-4.1.1/contrib/dspic
ans =

c:/Programmi/scilab-4.1.1/contrib/dspic

-->exec builder.sce

-->mode(-1);

-->

--------------------------------------------------------------------


4) Add the block to the scicos Palette
4.a) \"cd macros\"
4.b) open scicos by typing \"scicos();\"
4.c) Menu \"Diagram/Load\", load the file \"dspic.cosf\"
4.d) Menu \"Edit/Add New block\", specify the file name \"dspic_getfreq\", press ok and place the block inside the palette where you want
4.e) menu \"Diagram/Save As\", and give the name \"dspic.cosf\" - with the final \"f\"!!!
4.f) close Scicos and Scilab
4.g) now if you open again scicos, the dspic palette should have the dspic_getfreq block.

5) Configuring Erika Enterprise
5.a) copy the getfreq.c file inside \"C:/Programmi/Evidence/ee/contrib/scicos/src/pic30\"
5.b) add getfreq.c inside \"C:/Programmi/Evidence/ee/contrib/scicos/cfg/cfg.mk\" (see file attached for an example)

6) Create a scicos example
6.a) Follow the Scicos tutorial, but use the getfreq instead of the Sine (see files in the zip)
6.b) compile and enjoy :-)

--------------------------------------------------

Enjoy :-)

PJ
Attachments
getfreq_block_instructions.zip
(20 KiB) Downloaded 381 times

bbonsen
Newbie
Posts: 3
Joined: Tue Aug 28, 2007 1:43 pm

Re:Adding blocks

Post by bbonsen » Mon Nov 05, 2007 4:00 pm

Thanks, everything seems to be working, I\'ll let you know when the code is finished.

Bram

Locked