Could someone please explain PULSIN to me !
First off here some code as a starter to test PULSIN
So as per the manual :Code:' Philips RC5 IR decoder for 12F629 @ 4MHZ 'set for samsung TV on universal rae-1000 (or similar??) remote - TV1 -code 189 most buttons work define OSC 4 '4MHz DEFINE OSCCAL_1K 1 ' Set OSCCAL for 1k -HELPS tuning the crystal for more accurate timing CMCON = 7 'TRISIO = %76543210 ' port GPIO 0=output and 1=input TRISIO = %00000100 ' GPIO.2 is an input all the rest are outputs 'OPTION_REG.7 = 0 ' Internal pull-ups = on 'debug defines DEFINE DEBUG_MODE 0 ' Debug sending INVERTED serial data DEFINE DEBUG_REG GPIO ' Debug Port = GPIO DEFINE DEBUG_BIT 0 ' Debug.bit = GPIO.0 DEFINE DEBUG_BAUD 2400 ' Default baud rate = 2400 'end of debug defines 'Variables here IRpulse_length var word(13) 'holds pulse length IRpin var GPIO.2 'IR module ..TSOP1736..check my schematic in earlier posts' LED var GPIO.1 'LED is connected here 'end of variables main: debug "working = ",13,10 'send to hyperterminal replace this with serin or hserin if you like LOW led 'LED off Getstartbits: the incoming header test irpin =0 'set ir pin low irpulse_length = 0 'set irpulse_length low PuLSIN IRpin,0,IRpulse_length(0) 'start PULSIN on irpin state 0 store in irpulse_length debug "pulse length " ,dec irpulse_length ,10,13 ' send irpulse_length to hyperterminal irpulse_length = 0 goto getstartbits: 'do it again end
So a question here is :PULSIN Pin,State,Var
If State is zero, the width of a low pulse is measured.
If State is one, the width of a high pulse is measured.
Can the state be altered as execution takes place.
For example if I have set STATE as 0 to measure the width of a low pulse, can I change the state of PULSIN to detect a high pulse just after , so that STATE is 1 and PULSIN measures a HIGH PULSE ?
This statement is true I have noticed the irpulse_length value displayed in hyperterminal
The measured width is placed in Var.
BUT.... is this only the value for the header pulse that is being displayed ?
The reason I ask is because as per the code stub I only get one reading on each button press..is this because things are happening so fast that PULSIN has already picked-up (buffered ) all incoming pulse
Given the following pulse :
_____|--------|______|------|______
low----high------low----high----low
If both high and low pulses are the same size then the duty cyclye is 50% not so ?
and as per the manual
Is this where PULSIN_MAX comes into play ?If the pulse edge never happens or the width of the pulse is too great to measure, Var is set to zero
so we could specify the max pulse size PULSIN should care to measure?
It looks to me like the way to measure the RC5 signal is to use a combination of interrupts ,bit check for each pulse and a counter.
Any help or clarity on this would be really appreciated.
Kind regards
Dennis




Bookmarks