Timed pulses on 2 pins


Closed Thread
Results 1 to 2 of 2
  1. #1
    Danie Joubert's Avatar
    Danie Joubert Guest

    Question Timed pulses on 2 pins

    Hallo group
    As a new comer to the PBP family I first like to say thanks to all for the tons of info available.
    I have a problem in writing code to check two input pins for changing pulses. The pulses from a shaft arive at the two pins at varying speed and is are alway 90 degrees apart. I want to use the pulses to determine whether the shaft is turning forward or backword.
    Is there anyone who has done something like this?
    If so will you please be so kind in helping.
    I have just cross-graded from the first edition of Pb to PBP, great exitment !!
    Thanks group

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Let’s call our inputs SensorA and SensorB. SensorB is 90 degrees away from SensorA.

    Rotating in one direction, SensorA pulses first, followed by SensorB 90 degrees later, then followed by SensorA again 270 degrees after that.

    Rotating in the other direction, SensorA pulses, followed by SensorB 270 degrees later, then followed by SensorA again 90 degrees after that.

    You will see from this that there are two distinct Timing periods, a short 90 degree period, and a long 270 degree period. Let’s call this TimeShort and TimeLong.

    If SensorB pulse is followed by TimeLong, the we are rotating in one direction. If SensorB pulse is followed by TimeShort you are rotating in the other direction (you can just as easily use SensorA rather than SensorB here).

    Simply start a Timer on one Pulse, save the value on the next pulse, restarting the count. After two Timed counts you can then determine the direction of rotation (and as a bonus, the timed counts themselves will give you the rotational speed). It is probably best to junk the first Pulse from start-up/power-on since you don't know where your shaft is at rest.

    Melanie

Similar Threads

  1. How to drive the Vinculum VDIP1 in UART mode
    By BrianT in forum Code Examples
    Replies: 41
    Last Post: - 23rd May 2013, 12:34
  2. USB-FTDI[UM232R] with PIC16f877a
    By bjox in forum USB
    Replies: 1
    Last Post: - 23rd February 2008, 22:40
  3. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  4. Timing input pulses and re-outputting them
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th February 2007, 01:50
  5. interfacing SPI with 2 pins?
    By modifyit in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 1st December 2005, 22:04

Members who have read this thread : 1

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