Can some one please check my code out thanks


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2005
    Posts
    28

    Default Can some one please check my code out thanks

    Hi there this is my first real bit of codeing for pic basic pro.
    Can some one please look over it for me and see if there are any mistakes or have any advice regarding it thank you

    The idea of the code is to control two pwm signals and output the result for a servo.
    When input one is in use it will control the output but when not in use ie in the neutral position of 1.5ms pulses then input 2 controls the output.

    when here is the code

    'servo control prog

    'set variables

    ch1 var byte
    ch2 var byte

    s1 = 150

    start:

    if ch1 < s1 then output1
    if ch1 > s1 then output1
    if ch1 = s1 then output2


    output1:

    pulsout portb.3,ch1
    pause 18
    goto start

    output2:

    pulsout portb.3,ch2
    pause 18
    goto start

    end

  2. #2
    Join Date
    Sep 2005
    Posts
    28


    Did you find this post helpful? Yes | No

    Default Any one??

    Any one?? care to look

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,970


    Did you find this post helpful? Yes | No

    Default

    I think you should find a way to give a value to var ch1. As it is it will get a random number on startup.

    Ioannis

  4. #4
    Join Date
    Sep 2005
    Posts
    28


    Did you find this post helpful? Yes | No

    Default xcode

    thanks for the reply i have just seen my mistake thanks really it shound look like this then?

    'servo control prog

    'set variables

    ch1 var byte
    ch2 var byte

    s1 = 150

    start:

    pulsin portb,1,Ch1
    pulsin portb,2,Ch2

    if ch1 < s1 then output1
    if ch1 > s1 then output1
    if ch1 = s1 then output2


    output1:

    pulsout portb.3,ch1
    pause 18
    goto start

    output2:

    pulsout portb.3,ch2
    pause 18
    goto start

    end


    Secound question how do i subsitue ch2 for a pot instead of a pwm signal would it look like this

    potportb.2,200,var

    would this give me the correct value to output to a servo?

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,970


    Did you find this post helpful? Yes | No

    Default

    You may have to give us more details of what you are trying to accomplish. No one would "play" with you and build command by command your code or what evere.

    Give more input. What is you input signal. Is it Pulse? Is it from a PC? Is it from a pot?

    You are not clear. I said that your variable would need a value. Pulsin would give a value to ch1 but is it what you really want to do?

    Ioannis

  6. #6
    Join Date
    Sep 2005
    Posts
    28


    Did you find this post helpful? Yes | No

    Default hi

    Hi there thanks for your help i have anouther thread running in this same fourm its called How would i write this in pic basic pro (Servo controller)

    thanks

Similar Threads

  1. Nokia COLOR LCD PicBasicPro 2.50a example code
    By skimask in forum Code Examples
    Replies: 49
    Last Post: - 28th September 2011, 01:43
  2. can't find include file!
    By jimbostlawrence in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 10th November 2009, 08:44
  3. Manchester coding/decoding Code help
    By financecatalyst in forum Code Examples
    Replies: 0
    Last Post: - 25th August 2009, 19:05
  4. Code to control 4 LEDs and 2 servos
    By The Master in forum Off Topic
    Replies: 2
    Last Post: - 26th November 2008, 13:33
  5. changing code from 16F to 18F microprocessor
    By SCC_699 in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 14th May 2008, 13:27

Members who have read this thread : 0

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

Posting Permissions

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