How do you store 1 to 2ms servo pulses in a variable?


Closed Thread
Results 1 to 25 of 25

Hybrid View

  1. #1
    Join Date
    Jun 2007
    Location
    SW England
    Posts
    7

    Default How do you store 1 to 2ms servo pulses in a variable?

    Gents (and ladies), first off, thanks for the neat forum.

    Rather than charge in like a bull at a gate (this is my first posting), I took the liberty of snooping the 'read-this-before-you-post' pages first. That cracking-looking chick there, she mentioned something about new members being mostly berks, and that you experts should be good to us.
    In my defence, I did have a good look around prior to posting this, but couldn't find what I'm looking for.
    Could I ask that you pardon this berky question, but can anybody help me with this?...
    Using the PICBASIC compiler, is it possible to have a '16F84 read 1mS to 2mS radio-control pulses at PORT A, then send the same pulse to PORT B, but inverted? (Inverted as in the RC servo horn operating in reverse).
    I've dabbled with the PCM and SERIN commands and from that you can probably tell I don't really know what I'm doing.

    Can I call on you boffins for your help, please?

    Many thanks for reading.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    pulsewidth var word

    main:
    pulsin port-whatever-pin-whatever, 1, pulsewidth '1 if you pulse is active high
    pulsewidth = 2000 - pulsewidth
    pulsout port-whatever-pin-whatever, pulsewidth
    goto main

    Of course, this assumes that your max pulse width is 2ms, usually they go a tad bit farther than 2ms (2.5ms is max endpoint on one of my Futaba's). And the 2000 will also depend on how fast your oscillator runs.
    And this will (by default), run at the correct frequency, since the pulsin will only activate when you're servo gets a pulse. Then the program will output the 'inverted' pulse, then go back to the start and wait for the next pulse.

    3 other questions:
    What's a berk?
    What is it to be berky?
    What's a boffin, and how many of them does it take to screw in a light bulb?

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Thumbs down Servo pulse inverting calculation ...

    Hi, Skimask

    I wonder it was a typo ...

    but inverting "formula" is :

    Inv.pulsewidth = ( 2*Neutral ) - pulsewidth

    so, in µS it's .... ( 2*1500 ) - pulsewidth

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi, Skimask
    I wonder it was a typo ...
    but inverting "formula" is :
    Inv.pulsewidth = ( 2*Neutral ) - pulsewidth
    so, in µS it's .... ( 2*1500 ) - pulsewidth
    Alain
    I've been using my bit of 'pseudo-code' for awhile, works for me, but there's also a lot of assumptions (4mhz osc, 1500us perfect center, 2000 perfect endpoint, etc).
    I like your bit of code better and I'm going to change my ways of doing those.

  5. #5
    Join Date
    Jun 2007
    Location
    SW England
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    But my understanding is that PULSIN and PULSOUT only applies to PORT B.
    Is there a way that RC pulses can be read into PORT A?
    Can it indeed be done on the PIC16F84 with the PICBASIC compiler?

    Appreciate your time and help with this.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Martin Peters View Post
    But my understanding is that PULSIN and PULSOUT only applies to PORT B.
    Where'd you get that info?
    PulsIn/PulsOut doesn't have those restrictions.
    If the pin can be read, you can use PulsIn.
    If the pin can be written, you can use PulsOut.
    It's all in the PBP manual.

    And are you using PicBasic (PBC) or PicBasicPro (PBP)?
    And which version?

Similar Threads

  1. Thermo 7 segments - little problem
    By fratello in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 27th July 2013, 07:31
  2. RS485 bus - starting probem
    By wurm in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th January 2010, 13:35
  3. one line led light make image
    By bioul in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 12:19
  4. HSERIN doesn´t work
    By wurm in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th July 2007, 14:23
  5. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36

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