Pulsin on multipins


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838

    Cool Pulsin on multipins

    Hi Guys ,
    I have need to do pulsin on a device that has 18 inputs connected to sensors the changes are generally large and updated every 2 mins. so basicly a status summery of the sensors is done

    the code would be the same with only the array varable storing the change for each sensor

    I thought using the nice method hendric showing of using lookup , with an port offset would work , but sadly not for pulsin as i am getting rubbish on readings which are above 15
    , i think its cos the offset number from porta is larger value than 15 and pulsin has a value limit at 15 ????

    Can anyone advise how to solve this prob with multi inputs with pulsin or am i incorrect ???


    Cheers

    Sheldon

    Code:
    Eg 
    
    for T = 0 to 17
    
       lookup T [ 9,11,13,16,18,22,1,4,6,8,26,27,28,25,23,21,32,34], Portoffset  ' Sensor input 1 - 18
     
        pulsin PORTA.0[PortOffset],1,Leader
    
     Sensor(T) = Leader 
    
    Next T

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: Pulsin on multipins

    Sheldon,

    What's happening there is ... it will look at the state of the specified pin, and use either 0 or 1 for the pulsin pin, which is usually PORTB.0 or PORTB.1 depending on the chip being used.

    So let's say T = 3, then the LOOKUP returns 16.
    An offset of 16 from PORTA.0 is PORTC.0, so it gets the state of that pin (0 or 1).
    If PORTC.0 = 0, it does the PULSIN on PORTB.0.
    If PORTC.0 = 1, it does the PULSIN on PORTB.1.

    There's probably a hundred ways to accomplish it, but here's an untested/not compiled thought.
    Code:
    FOR T = 0 TO 17
        lookup T [ 9,11,13,16,18,22,1,4,6,8,26,27,28,25,23,21,32,34], Portoffset  ' Sensor input 1 - 18
        Leader = 0
        IF PORTA.0[PortOffset] = 0 THEN
            WHILE PORTA.0[PortOffset] = 0 : WEND  ; Wait for start of pulse
            WHILE PORTA.0[PortOffset] = 1         ; Measure Pulse Width
               Leader = Leader + 1
               PAUSEUS 5                          ; Adjust loop timing to your needs
            WEND
        ELSE
            ; error, pin was not low to start
        ENDIF
    
        Sensor(T) = Leader                        ; Store Result
    NEXT T
    DT

  3. #3
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: Pulsin on multipins

    thanks darrel, that worked , i also added a timeout .

    You must have redone pulsin, rctime others commands , in replacement code many times , a code equivalent link page to those code examples would be handy if they were one place for a reference

    Cheers

    Sheldon

Similar Threads

  1. 18f4550 USB and pulsin or pulsin alternative
    By vacpress in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th January 2009, 13:14
  2. Pulsin within subroutine
    By Wesley in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 10th January 2009, 23:05
  3. pulsin: how is it used
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 8th October 2008, 00:11
  4. Pulsin
    By jmbanales21485 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 11th June 2007, 14:25
  5. Pulsin
    By droptail in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th March 2006, 17:03

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