Shop OBEX P1 Docs P2 Docs Learn Events
Servos Propeller GCC - Need to Drive 8 servos — Parallax Forums

Servos Propeller GCC - Need to Drive 8 servos

BTL24BTL24 Posts: 54
edited 2014-07-08 22:26 in Propeller 1
I have been looking for a propeller C routine that will drive 8 servos in background. The "servo.h" library functions only support 7 servos, if memory serves.

1) Has there been an update to the C Libraries of late that support 8 or more servos?

2) Is there an assembly routine that I can call from a propeller C program that runs in background that will drive 8 servos?

I have searched the forums, but came up dry (probably due to my inadequacies of using advanced search engine).

Regards,
BTL24 (Brian)

Comments

  • jazzedjazzed Posts: 11,803
    edited 2014-07-08 17:35
    Use the Servo32 code. http://obex.parallax.com/object/524

    I'll be happy to help you write a C interface and wrappers for it if you post a first attempt.

    Forum search is to blame for inadequacies. Just use google. " site:forums.parallax.com servo "
  • BTL24BTL24 Posts: 54
    edited 2014-07-08 17:45
    Thanks Jazzed! Yes...I will give it a go and post my results. I may need some hand holding to link it into my C code....LOL.

    I assume this will run in parallel with my current executive code that will store off the 8 servo commands to this routine. I will be reading continuously from an SD card with standard file I/O. I assume this servo code wont interfere with those operations.

    I am currently using servo_angle function from servo.h libraries and all is well. Just don't want to mess something up.

    Thanks again...
    Brian (BTL24)
  • jazzedjazzed Posts: 11,803
    edited 2014-07-08 18:47
    Brian,

    Start with making a C version of servo32. Then add API candy wrappers that have similar names to servo.h functions.

    The hardest part of making a C -> PASM interface is by making a mailbox structure for communications.

    The mailbox in spin appears to be this:
            long          ZoneClocks
            long          ServoPinDirection
            long          ServoData[32]                                             '0-31 Current Servo Value 
            long          ServoTarget[32]                                           '0-31 Desired Servo Value 
            long          ServoDelay[32]                                            '0-31 Servo Ramp Delay
    

    You can include these files in the SimpleIDE project directly to use the PASM.

    Servo32v9.spin
    Servo32_Ramp_v2.spin

    The PASM code symbols for each of those will be:

    extern int binary_Servo32v9_dat_start[];
    extern int binary_Servo32_Ramp_v2_dat_start[];

    I suggest looking at the SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial project for an example to get started.


    If that turns out to be "just too hard" try the spinwrap program. http://forums.parallax.com/showthread.php/153919-SpinWrap-a-tool-for-allowing-C-or-C-to-use-Spin-Objects?p=1243144&viewfull=1#post1243144
  • BTL24BTL24 Posts: 54
    edited 2014-07-08 20:12
    Jazzed... et al...

    Having just updated my "learn" folders tonight in getting to review the SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial project , I happened to notice that the latest version of the C library "servo.h" now handles 14 servos or more!

    This solves my problem immediately. I will be testing over the next several days and report status.

    Jazzed... I will put the spin code on hold until I check this out. I will be getting back to it as it is a great example on how to include Spin programs in C.

    Regards,
    Brian (BTL24)
  • BTL24BTL24 Posts: 54
    edited 2014-07-08 21:56
    BTL24 wrote: »
    Jazzed... et al...

    Having just updated my "learn" folders tonight in getting to review the SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial project , I happened to notice that the latest version of the C library "servo.h" now handles 14 servos or more!

    This solves my problem immediately. I will be testing over the next several days and report status.

    Jazzed... I will put the spin code on hold until I check this out. I will be getting back to it as it is a great example on how to include Spin programs in C.

    Regards,
    Brian (BTL24)

    Well Surprise... Surprise! When I compiled my old program with new libraries, it ran out of Hub memory (Over by 4,824 bytes).... OUCH! LOL.

    But, I converted some functions like scanf to getStr and saved a bundle of memory. Whew! Still need to try out that 8th servo...but this little issue got in the way.

    Will keep you posted...

    Regards,
    Brian (BTL24)
  • BTL24BTL24 Posts: 54
    edited 2014-07-08 22:21
    BTL24 wrote: »
    Well Surprise... Surprise! When I compiled my old program with new libraries, it ran out of Hub memory (Over by 4,824 bytes).... OUCH! LOL.

    But, I converted some functions like scanf to getStr and saved a bundle of memory. Whew! Still need to try out that 8th servo...but this little issue got in the way.

    Will keep you posted...

    Regards,
    Brian (BTL24)

    The 8th servo works like a champ! Very pleased my friends... very pleased.

    I even may expand my project more and take advantage of the 14 servos. Nice to have margin.

    Regards,
    Brian (BTL24)
  • SRLMSRLM Posts: 5,045
    edited 2014-07-08 22:23
    If you're interested in seeing what a PWM32 port looks like there's one in libpropeller in C++: https://github.com/libpropeller/libpropeller/blob/master/libpropeller/pwm32/pwm32.h
  • BTL24BTL24 Posts: 54
    edited 2014-07-08 22:26
    SRLM wrote: »
    If you're interested in seeing what a PWM32 port looks like there's one in libpropeller in C++: https://github.com/libpropeller/libpropeller/blob/master/libpropeller/pwm32/pwm32.h

    Thanks... I will take a look.

    Regards,
    Brian
Sign In or Register to comment.