Control Motor with Scicoslab

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

Moderator: paolo.gai

Locked
jkng9
Newbie
Posts: 3
Joined: Wed Aug 06, 2014 7:45 am

Control Motor with Scicoslab

Post by jkng9 » Wed Aug 06, 2014 7:51 am

Hi, I'm trying to control a Servo as an output for wide range of angular movement but at the moment I'm having problems with generating such a task for the microcontroller using the blocks. Currently, I can only generate one pulse which then cause the servo to rotate once and remains at one position while making a high pitch sound. Any ideas on how this can be overcomed or in general, a more efficient approach to control the servo?

Thanks,
Jo Ng

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

Re: Control Motor with Scicoslab

Post by paolo.gai » Wed Aug 06, 2014 7:56 am

Hi,

As long as we know, the Servo are typically programmed with a 20ms period, and a variable duty cycle that when 50% means the servo in me zero position. That is how we controlled it. Maybe a higher frequency should be tried? in that case you need to modify the PWM driver in the scicos block drivers for the servo...

Ciao,

Paolo

jkng9
Newbie
Posts: 3
Joined: Wed Aug 06, 2014 7:45 am

Re: Control Motor with Scicoslab

Post by jkng9 » Wed Aug 06, 2014 8:12 am

Hi, I gave your advice a shot by altering the frequency on the PWM blocks and it allowed the servo some degree of movement but not to the extent of allowing it to control a desired movement. For example allowing bi-directional step movement as easily done in Arduino. Any ideas on how I could provide an input to the block to enable the pulse to be able to be controlled automatically? Or it seems that that can only be done manually through changing the c++ codes generated?

Thanks and Regards,
Jo

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

Re: Control Motor with Scicoslab

Post by paolo.gai » Wed Aug 06, 2014 12:24 pm

Sorry but I do not understand... We control the servomotors from scicosLab attaching the PWM to the servomotor control.

The Amazing Ball (http://www.evidence.eu.com/products/amazing-ball.html) is using the servo motors and they work quite fine. We send the positioning and the servo moves there. The diagram we use to control the servos is available as one of the examples with the Scicos Pack.

If you see the diagram, the servo is controlled by imposing the duty cycle and the servo keeps the position set in the PWM.

Maybe you connected the servo ina wrong way? Are you using an Amazing Ball hardware or other hardware you made?

Ciao,

Paolo

jkng9
Newbie
Posts: 3
Joined: Wed Aug 06, 2014 7:45 am

Re: Control Motor with Scicoslab

Post by jkng9 » Thu Aug 07, 2014 2:22 am

Hi,
Sorry for not explaining things rather efficiently. I'm using the easylab microcontroller to control the servo to some relative degree of movement depending on an input. For that I need to vary the width of pulses outputted from the PWM pin block. However, I'm finding difficulty in sorting out a way to produce a varying output pulse because the block only seems to be able to produce a constant width of pulse as stated or pre-set at the block properties. Hope this clears things up. (:

Thanks and Regards,
Jo

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

Re: Control Motor with Scicoslab

Post by paolo.gai » Thu Aug 07, 2014 8:02 am

I'm still probably missing something...

The Easylab PWM block, at the end, calls the function

EE_easylab_pwm_set_duty(pwm_ch, (EE_UINT32)(duty * EE_PWM_DUTY_MAX));

(see contrib/scicos/src/pic30/easylab_pwm.c)

That is, you need to give a PWM value for the duty cycle, which varies from 0.0 to 1.0 .

Typically 0.0 moves the motor on one side, whereas 1.0 to the other side.

Ciao,

PJ

Locked