Pulse Input > Array > Output help


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Aug 2005
    Posts
    44


    Did you find this post helpful? Yes | No

    Default Re: Pulse Input > Array > Output help

    thanks for the replies and code richard

    After i saw your first reply, i messed around a little and came up with this

    Code:
    DEFINE OSC 4
    OSCCON = %01101010			' Oscillator internal 4 mhz PLL disabled
    
    CM1CON0.7 = 0				' Comparator 1 off
    CM2CON0.7 = 0				' Comparator 2 off
    CPSCON0.7 = 0				' Capsense module off
    MDCON = %00000000			' Disable the Modulator
    ANSELB = %00000000			' Select no analog
    
    TRISA=%00000000				' Port A all output
    TRISB=%00001001				' Port B all output except 3 ,1
    
               
    PulseArray var byte[80]  ' 88 bytes 640 bits total
    ArrayTail var word
    GetThisPulse var word
    Difference var word
    Offset var word
    
    Arraytail=0
    GetThisPulse=0
    Offset = 250    '(250)
    
    '	----------  COLD START	
    
    ' set all unused pins low
    Low PortA.0
    Low PortA.1
    Low PortA.2
    Low PortA.3
    Low PortA.4
    'Low PortB.0
    Low PortB.1
    Low PortB.2
    Low PortB.4
    Low PortB.5
    Low PortB.6
    Low PortB.7
    
    
    Pause 25				
    
    clear
    Arraytail=0
    
    RunController:
    
    	
    PulseArray.0[Arraytail] = PortB.0  'set the last bit in the array as per b.0
    if arraytail >= 639 then arraytail = 0  ' circle
        
    Arraytail= Arraytail+1 
    latb.4 = !latb.4 '    use p4 to check loop time on scope
    
    
    if offset > arraytail then
        difference = offset-arraytail        
        GetThisPulse = 639 - difference
    else
        GetThisPulse = ArrayTail - offset
    endif
    
    latb.5 = PulseArray.0[GetThisPulse]  ' output this bit 
    
    pauseus 300  ;    adj to suit
    goto  RunController
    it has compiled ok etc but I havent had time to scope it, but i think your second reply is a much cleaner and more practical solution
    Last edited by jamie_s; - 16th October 2016 at 12:35.

Similar Threads

  1. Sharp pulse on ADC input and NAP
    By ardhuru in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 16th August 2011, 06:00
  2. How to reverse polarity on output pulse??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 6th June 2009, 13:25
  3. Input Output interface
    By aratti in forum Schematics
    Replies: 2
    Last Post: - 5th November 2008, 21:36
  4. input output code
    By pitufo in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 19th August 2008, 20:57
  5. Using 4 input to control 10 output
    By cibotsan in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 5th November 2004, 12:08

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