Multi servo interrupt program in Mikro Basic converting to PBP


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2011
    Location
    Indian Harbour Nova Scotia
    Posts
    108

    Default Multi servo interrupt program in Mikro Basic converting to PBP

    I found a neat multi-servo program using interrupts, written in Mikro Basic (I think - looks familiar). I translated as much as I could into PBP, but I cannot get the system to work. I've gone over it many times and ran the ICD in MCS+ trying to troubleshoot it. (Unfortunately ICD doesn't seem to work for interrupts).

    I uploaded both programs for "someone" to take a look at to see if there is something obvious I'm doing wrong.

    FYI, some things that I did change: 1) I don't have the For-Next loop to add all the servos, I only use one for now. 2) my servo is servo1 at PortA.0. 3) Mikro program used a 16F877 at 20MHz, I am using a 16F887 at 4 MHz so I changed the timer preload and prescaler accordingly. I'm comfortable with timers and interrupts, but i'm certainly no expert.

    Any help is appreciated of course.

    Original Mikro Basic is Servo8_1000. My PBP attempt is Servo8_100FEMOD

    Oh...I have some difficulties with loading the 16bit timer TMR1
    Attached Files Attached Files
    Last edited by queenidog; - 21st May 2015 at 22:36.

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,380


    Did you find this post helpful? Yes | No

    Default Re: Multi servo interrupt program in Mikro Basic converting to PBP

    the original code cycles through 8 servos 2.5ms at a time to give a refresh rate for each servo of 2.5*8 ms (20ms) , the standard servo refresh rate.
    won't your code of 1 servo try to refresh every 2.5 ms ------ the servo won't like that.
    also the flakey timing of oninterrupt will probably give you a twitchy servo .
    dt ints would be more stable
    4mhz won't allow for much resolution for servo commands too, I seem to recall dismal results from similar efforts years ago a twitchy servo is apitb

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Multi servo interrupt program in Mikro Basic converting to PBP

    I am experimenting with this version that uses ccp1 and ccp2. It works really well. It can run 8 servos with a 1uS resolution at 8mhz. What I found important is using a separate power supply for the motors and the pic. Once I started loading the motors, the current could spike over 1 amp and this was resetting the pic and or feeding back into the adc. This caused twitchy and erratic movements.

    The code in this link will not compile until you add a underscore to the variable in the assembly line. I hope to also port this to PBP

    http://www.mikroe.com/forum/viewtopi...7&hilit=+servo

Similar Threads

  1. Mikro Elektronika Basic and PBP
    By queenidog in forum mel PIC BASIC
    Replies: 5
    Last Post: - 24th May 2013, 01:26
  2. Multi timer interrupt question
    By Hylan in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 9th December 2012, 23:27
  3. help converting assembely program
    By ahmed_salah in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 7th August 2008, 16:28
  4. converting assemble to pic basic pro
    By Jhdgkss in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 30th April 2006, 20:55
  5. Multi Interrupt How To ?
    By capitano in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd February 2005, 15:48

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts