Shop OBEX P1 Docs P2 Docs Learn Events
Control servo using propeller GCC IDE — Parallax Forums

Control servo using propeller GCC IDE

bhaskarghsh4bhaskarghsh4 Posts: 20
edited 2013-06-09 21:34 in Learn with BlocklyProp
Hello every body,
I am new in this forum. Without taking any time in formalities I would like to share the problem with me.
I am new in propeller micro controller also. My basic aim is to rotate servo with propeller BOE. I did it with spin using the objects related to servo that is required. But now I want to do the same task with propeller GCC ID using simple C program.

I used the program which follows:
#include "simpletools.h"
int main()
{
int servo = 19,inc=700;
/*servo_setramp(servo,100);*/
servo_angle(servo,900);
/* servo_speed(servo,100);*/
while(1)
{
servo_set(servo,inc++);/*To run continuously in manner instead of an instantaneous degree*/
}
return 0;
}
......
But the problem that the IDE is showing is that "Undefined reference to the function" (like servo_angle & servo_set) ...
I am in deep frustration. I tried different ways but couldn't sort out any way.

My another problem is to control the servo not by the propeller BOE pins itself but by using an intermediate PSCU controlled by propeller BOE through the 3 serial in pin using spin or C for propeller.

Thank you in advance for every one to give an effort to sort a way out to help me .....

:)

Comments

  • SRLMSRLM Posts: 5,045
    edited 2013-05-29 23:11
    Have you tried
    #include "servo.h"
    

    To control the PSCU you can use a serial library, and follow the command set that's found in the PSCU documentation.
  • jazzedjazzed Posts: 11,803
    edited 2013-05-30 00:42
    1) Please press the blue books icon as shown in the example below to Add Simple Library.
    2) Open the folder Motor
    3) Click libservo and click Select Folder button.
    4) You should have #include "servo.h" in your main program now.
    5) Click hammer to compile.

    Best Regards,
    --Steve


    welcome-side.png
  • bhaskarghsh4bhaskarghsh4 Posts: 20
    edited 2013-05-30 03:26
    Thank u Thank u Thank u Thank u very very much brothers for ur valuable suggestions. Earlier I tried the servo.h also but I wasn't completely aware about the library..
    Any way I got one of my answer. Thanks once again for that.

    But my second query was about to control the servos through an intermediate PSCU from propeller BOE using this IDE or spin anything?
    :)
    :)
  • bhaskarghsh4bhaskarghsh4 Posts: 20
    edited 2013-05-30 03:30
    Thank u Soooooo much

    Best Regards,
    --Bhaskar


    welcome-side.png[/QUOTE]
  • Jen J.Jen J. Posts: 649
    edited 2013-05-30 11:59
    Moving this thread to the Learn Forum.
  • bhaskarghsh4bhaskarghsh4 Posts: 20
    edited 2013-05-30 22:20
    Hello every one ...
    I still am not able to control servos through PSCU controlled by propeller BOE using serial in pins of PSCU. So kindly help my dear friends.
    :(
  • kwinnkwinn Posts: 8,697
    edited 2013-05-31 09:14
    Hello every one ...
    I still am not able to control servos through PSCU controlled by propeller BOE using serial in pins of PSCU. So kindly help my dear friends.
    :(
    You need to send the serial data to the PSCU in the correct format using one of the serial objects. By correct format I mean both the correct command/data format as well as the serial baud rate, etc.
  • Steph LindsaySteph Lindsay Posts: 767
    edited 2013-05-31 09:40
    In your first post, you mentioned that using Spin with the PSCU would be okay, There is a Spin example posted here:

    https://code.google.com/p/propsource/source/browse/Development/PSCU_test.spin?r=ee93adc619f0b19ddee6e262b17878417db9081f
  • bhaskarghsh4bhaskarghsh4 Posts: 20
    edited 2013-06-04 23:55
    Thanks but I am not getting the appropriate result. Instead servo is vibrating continuously.
    & the most irritating thing is that I am using P19 of BOE to control but when I am connecting PSCU to any other pins also then same outcome occurs.
    Even I tried a code in my way after studying the class servocontrollerserial but no fruitful result :(
    The code is :
    {
    Want to rotate my servo through PSCU & propeller BOE using PSCU's serial in connection pin
    }
    CON


    _clkmode = xtal1 + pll16x
    _clkfreq = 80_000_000


    PSCU_PIN = 0 'the pin on the host propeller that the PSCU is connected to.
    PSCU_BAUD = 2_400
    P19=19 ' Want to communicate through P19 of propeller BOE with PSCU


    OBJ
    servo: "ServoControllerSerial"
    time: "timing"


    PUB pscu_servo | P19_pos, P19_ramp


    servo.start(PSCU_PIN,PSCU_BAUD)
    P19_pos := 600
    P19_ramp := 20
    repeat 10
    servo.setpos(P19,P19_ramp,P19_pos)
    time.pause(2000)
    P19_pos := 1600
    servo.setpos(P19,P19_ramp,P19_pos)
    time.pause(2000)
    P19_pos := 600
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-06-05 18:30
    Did you try the link Steph referred to? Also, Are you using fresh batteries or a wall wart power supply?
  • bhaskarghsh4bhaskarghsh4 Posts: 20
    edited 2013-06-05 21:32
    Yes. I tried the link my friend. & I am using A variable voltage source for 5V dc in PSCU.
  • bhaskarghsh4bhaskarghsh4 Posts: 20
    edited 2013-06-09 21:34
    :(
    Hello friends...
    I still don't get answer.
    Is there any other alternative way for solving my issue with PSCU?
    Please help me to eradicate this problem from my mind ...
Sign In or Register to comment.