Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

InfraRed in Pic simulator

Status
Not open for further replies.
I think for the application you are converting to oshonsoft picbasic, the following should work

servoin GPIO.3,start
servoin GPIO.3,pulse[counter]

'servoin' can only count in 'bytes', and not 'words' like 'pulsin'.
But for this application this limitation does not matter, since 'start' and 'pulse' are declared as bytes.
 
You could use almost directly the second example in the thread for reading Philips RC5 protocol.
Just read the state of an input, for example: IF GPIO.3=1 THEN ....
and add correct delay statements ( Waitus x )
 
You could use almost directly the second example in the thread for reading Philips RC5 protocol.
Just read the state of an input, for example: IF GPIO.3=1 THEN ....
and add correct delay statements ( Waitus x )

Hello,
thank you for your answer it advance a little, the two solutions me always give the same values. except for some keys data 118 id 28

My code
Code:
'// SONY SIRC IR decoder

Define CONF_WORD = 0x3f72
Define CLOCK_FREQUENCY = 4
Define COUNT_MODE = 2
Define LCD_BITS = 8
Define LCD_DREG = PORTD
Define LCD_DBIT = 0
Define LCD_RSREG = PORTB
Define LCD_RSBIT = 5
Define LCD_RWREG = PORTB
Define LCD_RWBIT = 4
Define LCD_EREG = PORTB
Define LCD_EBIT = 3
Define LCD_READ_BUSY_FLAG = 1
Define COUNT_MODE = 2
Lcdinit
'Define SIMULATION_WAITMS_VALUE = 0
Dim a As Byte
Dim y(12) As Byte  'Holds 12-bit SIRC code
Dim loop As Byte  'Loop variable
Dim data As Byte
Dim id As Byte
Symbol pin = PORTB.0  'RB.0 input pin reading data

TRISB.0 = 1  'Set RB.0 direction to input
OPTION_REG.7 = 0  'Internal pull-ups = on

home:
If pin = 1 Then Goto home  'Wait for low going pulse
WaitUs 100  'Short delay
If pin = 1 Then Goto home  'Was it noise?
WaitUs 2400  'Pause to read 2nd half of 1st bit period
WaitUs 600
For loop = 11 To 0 Step -1  '12 pulses MSB to LSB
Count pin, 3, y(loop)
WaitUs 600
Next loop  'in middle of 2nd bit period

If y(11) > 1 Then
id.7 = 1
Else
id.7 = 0
Endif
If y(10) > 1 Then
id.6 = 1
Else
id.6 = 0
Endif
If y(9) > 1 Then
id.5 = 1
Else
id.5 = 0
Endif
If y(8) > 1 Then
id.4 = 1
Else
id.4 = 0
Endif
If y(7) > 1 Then
id.3 = 1
Else
id.3 = 0
Endif

If y(6) > 1 Then
data.6 = 1
Else
data.6 = 0
Endif
If y(5) > 1 Then
data.5 = 1
Else
data.5 = 0
Endif
If y(4) > 1 Then
data.4 = 1
Else
data.4 = 0
Endif
If y(3) > 1 Then
data.3 = 1
Else
data.3 = 0
Endif
If y(2) > 1 Then
data.2 = 1
Else
data.2 = 0
Endif
If y(1) > 1 Then
data.1 = 1
Else
data.1 = 0
Endif
If y(0) > 1 Then
data.0 = 1
Else
data.0 = 0
Endif


'If y.LB = $ff Then Goto home  'Was it noise?
'y = ~y & $003f  'Mask upper 10-bits to return 6-bit data
'in lower 6-bits of word result
'Hserout ["Key Pressed = ", dec y, 13, 10]
'y = 0  'Clear key codes
'pause 250  'Used for testing only

Lcdcmdout LcdClear
'For a = 11 To 0 Step -1
Lcdout #data, " ", #id
'Next a
WaitMs 5000
Lcdcmdout LcdClear

Goto home  'Return Home

thank you for your help

Thierry

PS: Sorry for my bad english (google translate);)
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top