Questions on SCICOS Pack

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

Moderator: paolo.gai

Locked
kailup
Newbie
Posts: 14
Joined: Thu Apr 23, 2009 10:16 am

Questions on SCICOS Pack

Post by kailup » Wed Apr 29, 2009 8:17 am

Hi,

A few question on the SCICOS PACK:

1. I have no problem to implement the PD controller by simply using the gain and a gain + derivative block. However, when I tried using the PID (either the PID block or integrator block), i get following error.
***********
obj/dspic_main.o(.text+0x700): In function `CL3simblk_\':
d:\\Users\\chinluh.S4U\\CL3_scig\\dspic_main.c:1519: undefined reference to `dset_\'
make: *** [pic30.cof] Error 1
***********

2. is there any way to make the Analog output range at +-5 or +- 10V?

Thanks

Regards,
Chin Luh

simone.mannori
Newbie
Posts: 4
Joined: Sun Mar 22, 2009 8:22 pm

Re:Questions on SCICOS Pack

Post by simone.mannori » Wed Apr 29, 2009 9:22 am

Hi,

1. the \"safe\" way to use the FLEX code generator is to use ONLY
discrete block e.g. the blocks present inside the FLEX /dspic
specific palettes. In effect, some Scicos blocks are not (yet)
fully supported by the available FLEX version.

2. If you looking for bipolar outputs the answer is no :(
In order to simplify the hardware, the FLEX board has
only unipolar outputs (0 to 3.3 or 0 to 5V). You need some
external level translator/adapter

Do not hesitate to ask for more support :)

Regards

Simone Mannori - INRIA Rocquencourt

kailup
Newbie
Posts: 14
Joined: Thu Apr 23, 2009 10:16 am

Re:Questions on SCICOS Pack

Post by kailup » Wed Apr 29, 2009 9:32 am

Hi Simone,

Thanks for your prompt reply.

1. I was using the PID block under MCHP16-linear. Does it means this one is not supported yet? If so, is there any workaround?

2. Ok, then I shall use the pwm with the H bridge

Thanks

Regards,
Chin Luh

simone.mannori
Newbie
Posts: 4
Joined: Sun Mar 22, 2009 8:22 pm

Re:Questions on SCICOS Pack

Post by simone.mannori » Wed Apr 29, 2009 9:57 am

Hi,

thanks for the quick and detailed answer.

1. Hmm.. looks like a bug. Probably we have forgot to move some
Scilab/Scicos internal functions used inside the PID block.
Be careful because PID is a CONTINOUS block, so is is called
may times (default 10 times) inside a single sample interval
Ts. For the moment, my suggestion is to use \"discrete\" blocks
like gain, adder and (1/z) blocks in order to realize a
discrete PID;

2. I agree with you: I made the very same choice for my demo
board.

Simone Mannori - INRIA Rocquencourt

kailup
Newbie
Posts: 14
Joined: Thu Apr 23, 2009 10:16 am

Re:Questions on SCICOS Pack

Post by kailup » Wed Apr 29, 2009 10:07 am

Hi,

Thanks again.

1. OK, will check it out.

2. I am looking into the usage of PWM block. Fromt he forum, I undertand that the PWM is fixed at 1ms. So what should I input to the scicos block in order to get 25%,50%, 75% Duty Cycle? (sorry i might have miss out some documentation but seems like I can\'t find it)

Thanks in advance.

Regards,
Chin Luh

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

Re:Questions on SCICOS Pack

Post by paolo.gai » Wed Apr 29, 2009 10:17 am

If I remember well the PWM accepts numbers from 0 to 1 which are the duty cycle.

Unfortunately, currently the documentation can be found either in the Wiki (I\'m trying to track all the details for each block), or in the source code (on erika 1.4.3, inside c:/Evidence/Evidence/ee/contrib/scicos/src/pic30).

We\'ll try to add better documentation in the wiki asap (if anyone wants to contribute please feel free to update the wiki with your comments...)

Ciao,

PJ

kailup
Newbie
Posts: 14
Joined: Thu Apr 23, 2009 10:16 am

Re:Questions on SCICOS Pack

Post by kailup » Wed Apr 29, 2009 10:19 am

Great,
Thanks. trying now.

kailup
Newbie
Posts: 14
Joined: Thu Apr 23, 2009 10:16 am

Re:Questions on SCICOS Pack

Post by kailup » Thu Apr 30, 2009 3:38 am

Hi,

I tried using the PWM_DMB channel 1-4, with value 0-1 and probe the PWM 1L - Gnd,PWM 1 H- Gnd ...PWM 4 H- Gnd and there are no signals detected.

I took a look into the source: flex_dmb_pwm.c, and there are lines :

**************
if ((pin 2))
return; //** refuse not supported PWM
EE_pwm_set_duty( *duty, pin );
**************

p/s: above first line code might not displayed correctly in forum, basically it should read (if pin smaller than 1 or pin greater than 2)

looks like there only allow 2 channels, and tracing the EE_pwm_set_duty in ee_board.h I found:

**************
switch (chan) {
case 1: /** Set PWM 1 **/
/* Set OC8 as output */

TRISDbits.TRISD7 = 0;

/* Set the initial duty cycle */
OC8R = 0;
/* Set the duty cycle */
OC8RS = 0;
/* Set OC8 module: PWM, no fault check, Timer2 */
OC8CON = 0x0006;
break;

case 2: /** Set PWM 2 **/
/* Set OC3 as output */
TRISDbits.TRISD2 = 0;

/* Set the initial duty cycle */
OC3R = 0;

/* Set the duty cycle */
OC3RS = 0;

/* Set OC3 module: PWM, no fault check, Timer2 */
OC3CON = 0x0006;

break;
}
**************

and hence, I probe pin OC8 and OC3 (to ground), I got the signals, which is correspond to the SCICOS PWM DMB PWM out 1 and PWM out 2.

Is it designed this way or did I miss out some code which override when using the SCICOS?

Thanks again for the help.

Regards,
Chin Luh

simone.mannori
Newbie
Posts: 4
Joined: Sun Mar 22, 2009 8:22 pm

Re:Questions on SCICOS Pack

Post by simone.mannori » Thu Apr 30, 2009 4:28 am

Hi:

\"and hence, I probe pin OC8 and OC3 (to ground), I got the signals, which is correspond to the SCICOS PWM DMB PWM out 1 and PWM out 2.\"

For the moment the DSPic I/O configuration is \"static\".
In other words, \"hard liked\" in the code:
- only PWM 1 and 2 are supported, allocated in the pins that you have found.

As you have previously noted, we need to improve the documentation: not all our users are capable to resolve their problems looking inside the code ;).

A more \"FLEXible\" way to manage the I/O pins assignements and resources is in the development road map.

Regards

Simone Mannori - INRIA Rocquencourt

kailup
Newbie
Posts: 14
Joined: Thu Apr 23, 2009 10:16 am

Re:Questions on SCICOS Pack

Post by kailup » Thu Apr 30, 2009 11:03 am

Hi,

Finally I am able to make simple DC servo position control works.
A few more questions:
1. As there are some blocks under SCICOS Pack Blocks (such as PID or Intergrator), do you have a list of the supported blocks?
2. As for the PWM, with just 2 channels, only 1 motor could be driven, do you have any roadmap for the supported IO updates?
3. I am thinking of build up a simple inverted pendulum which use 2 encoder, would it be possible adding another encoder?
4. What is the max sampling could archieved?
5. For the USB example, the data exchage rate is 0.05sec. What is the fastest could archieve?
6. If the USB transfer rate is slower than the control loop sampling rate, how could I retreive the data without lost for data analysis and system identification?

Thanks again.

Regards,
CHin Luh

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

Re:Questions on SCICOS Pack

Post by paolo.gai » Thu Apr 30, 2009 2:17 pm

1. As there are some blocks under SCICOS Pack Blocks (such as PID or Intergrator), do you have a list of the supported blocks?
The current list of supported blocks is on the wiki! basically they are all the blocks which are under the FLEX and MCHP palettes...
2. As for the PWM, with just 2 channels, only 1 motor could be driven, do you have any roadmap for the supported IO updates?
When we made the blocks for the demo board we tried as much as possible to cover almost all the pins... choosing the specific function of each pin is always a trade-off... and I guess probably not -all- the pins of the board have been supported.

What we are currently doing is to add a set of additional pins for the communication and USB, as well as for the balancing ball demo.
3. I am thinking of build up a simple inverted pendulum which use 2 encoder, would it be possible adding another encoder?
You should either use a set of GPIO or the SPI port which is available on the additional connector near the IR on the demo board. Then you should create a new Scicos block, and create the additional code for the block. If you need support in doing that just ask on the forum...
4. What is the max sampling could archieved?
The setup which is distributed has frequencies which are multiple of 1ms (we had to choose a number at some point, and we chose that one :-) ).

But you can set of course higher frequencies. To do that, you need to:
- create a new template example from the examples directory
- give a new ID to the template in the template.xml which is present in the example directory
- change the periodicity of the timer and the scaling. everything is basically specified in the dspic_mail.c file.

In any case, please note that the system is basically a single task activated periodically by a timer. That is, the sum of execution time taken by the blocks cannot be greater than the period. If you have an oscilloscope, you can visually measure it by putting a GPIO pin to 1 when the block functions start, and to 0 when they finish. Again, this modification have to be done directly into the template.
5. For the USB example, the data exchage rate is 0.05sec. What is the fastest could archieve?
6. If the USB transfer rate is slower than the control loop sampling rate, how could I retreive the data without lost for data analysis and system identification?

The idea is the following: the dsPIC --> PIC18 connection is done using SPI, and the dsPIC uses DMA to transfer things to the PIC18.

That is, since the memory on the dsPIC is very limited, it is difficult (if not impossible) to get all data from the system at a higher throughput than the one of the communication medium.

If you do have a logic analyzer, you may write data directly to the GPIO, so that there is no buffering to do on the dsPIC...

How many data do you need to extract from your model?

Happy 1st may,

Paolo

kailup
Newbie
Posts: 14
Joined: Thu Apr 23, 2009 10:16 am

Re:Questions on SCICOS Pack

Post by kailup » Thu Apr 30, 2009 2:47 pm

1. The current list of supported blocks is on the wiki! basically they are all the blocks which are under the FLEX and MCHP palettes...

>> OK, I\'ve overlook simone\'s post saying the PID might be a bugs.

2. When we made the blocks for the demo board we tried as much as possible to cover almost all the pins... choosing the specific function of each pin is always a trade-off... and I guess probably not -all- the pins of the board have been supported.

What we are currently doing is to add a set of additional pins for the communication and USB, as well as for the balancing ball demo.

>> OK, noted

3. You should either use a set of GPIO or the SPI port which is available on the additional connector near the IR on the demo board. Then you should create a new Scicos block, and create the additional code for the block. If you need support in doing that just ask on the forum...

>> Thanks for the suggestion, will try it.

4. OK

5 & 6. As i am using default sampling, 1ms, so I am thinking of getting all the data back, which is 1000 per sec. Could it be archieveable?

Thanks again

Happy 1st May too. :)

rgds,

Chin Luh

Adriano
Newbie
Posts: 2
Joined: Tue Sep 22, 2009 9:30 am

Re:Questions on SCICOS Pack

Post by Adriano » Wed Oct 14, 2009 9:45 am

Hallo,

does somebody know if PID and other CONTINOUS blocks work in the new EE 1.5.0.1 ?

br Adriano

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

Re:Questions on SCICOS Pack

Post by paolo.gai » Wed Oct 14, 2009 11:04 am

Dear Adriano,

I\'ll forward this question to Simone and Roberto...

PJ

Adriano
Newbie
Posts: 2
Joined: Tue Sep 22, 2009 9:30 am

Re:Questions on SCICOS Pack

Post by Adriano » Wed Oct 14, 2009 11:06 am

Thank you.

Locked