PDA

View Full Version : Wired remote for Alpine



fratello
- 31st January 2012, 15:17
Hello !
Since I have good results with "wired remote for Pioneer HU" (see : http://www.picbasic.co.uk/forum/showthread.php?t=15229 ) one friend ask me to build something similar for his Alpine ...
I found a good topic here : http://www.mp3car.com/input-devices/131147-need-alpine-wired-remote-control-pinout.html , where it's described the "protocol".
I intend to use the same hardware : PIC 16F628A and remote control stalk near the steering wheel, from Renault.
But...I need help to put in PBP this :

Vol Up 110101111101101110101011110110111101011011010101
Vol Dn 110101111101101110101011011011011111011011010101
Mute 110101111101101110101011101011011110111011010101
Pst up 110101111101101110101011101010111110111101010101
Pst dn 110101111101101110101011010101011111111101010101
Source 110101111101101110101011101101111101101101010101
Trk up 110101111101101110101011101110111101101011010101
Trk dn 110101111101101110101011010111011111101011010101
Power 110101111101101110101011011101111110101101010101
Ent/Play 110101111101101110101011010101111111110101010101
Band/prog 110101111101101110101011011010111111011101010101


Note that the same series of 1's and 0's is at the start and end of each command, so here are the unique parts of each:


(Start) 110101111101101110101011

Vol Up 11011011110101101
Vol Dn 01101101111101101
Mute 10101101111011101
Pst up 10101011111011110
Pst dn 01010101111111110
Source 10110111110110110
Trk up 10111011110110101
Trk dn 01011101111110101
Power 01110111111010110
Ent/Play 01010111111111010
Band/prog 01101011111101110

(End) 1010101
So if "0" is low for 1000 us, and "1" is high for 500 us AND low for 500 us, how can I write the code ?!
Something like this (pseudo-code):


;(Start) 110101111101101110101011
; Vol Up 11011011110101101

check: select case key case 1 ; volume down
portb.7 = high
pauseus 500
portb.7 = low
pauseus 500 ' this is first "1"
portb.7 = high
pauseus 500
port.7 = low
pauseus 500 ' this is second "1"
... so on, so on ?!?


I need "a clue" ! Thanks in advance !!!

HenrikOlsson
- 31st January 2012, 16:23
Hi,

Here's an idea:

'************************************************* ***************
'* Name : Fratello_Alpine.PBP *
'* Author : Henrik Olsson *
'* Notice : *
'* : *
'* Date : 2012-01-31 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************

' CONFIGs and hardware setup, ADCON, CMCON, TRIS whatever not shown here.

'------------------------------------------------------------------------
StartH CON %11010111 ' High 8 bits of start frame
StartM CON %11011011 ' Middle 8 nits of start frame
StartL CON %10101011 ' Low 8 bits of start frame
'------------------------------------------------------------------------
VolUpH CON %11011011 ' High 8 bits of command
VolUpM CON %11010110 ' Middle 8 nits of command
VolUpL CON %11010101 ' Low bit of command + 7bits END of frame
'------------------------------------------------------------------------
VolDnH CON %01101101 ' High 8 bits of command
VolDnM CON %11110110 ' Middle 8 nits of command
VolDnL CON %11010101 ' Low bit of command + 7bits END of frame
'------------------------------------------------------------------------
ByteArray VAR BYTE[6] ' 6 bytes = 48bits
BitCount VAR BYTE ' Index variable for above array
i VAR BYTE ' General purpose
'------------------------------------------------------------------------
' Initialise the first three bytes of the array, these are static.
ByteArray[0] = StartH
ByteArray[1] = StartM
ByteArray[2] = StartL

Pause 1000
HSEROUT["Program start",13]


Main:
For i = 0 to 20
GOSUB VolumeUp
Pause 300
NEXT

FOR i = 0 TO 20
GOSUB VolumeDn
Pause 300
NEXT

Goto Main

END
'------------------------------------------------------------------------

'------------------------------------------------------------------------
' Subroutines follows:
'------------------------------------------------------------------------
VolumeUp:
' Set non static part of array to current command.
ByteArray[3] = VolUpH
ByteArray[4] = VolUpM
ByteArray[5] = VolUpL
GOSUB SendIt
RETURN
'------------------------------------------------------------------------
VolumeDn:
ByteArray[3] = VolDnH
ByteArray[4] = VolDnM
ByteArray[5] = VolDnL
GOSUB SendIt
RETURN
'------------------------------------------------------------------------
SendIt:
FOR BitCount = 0 to 47
If ByteArray.0[BitCount] = 1 THEN
GOSUB One
ELSE
GOSUB Zero
ENDIF
NEXT
RETURN
'------------------------------------------------------------------------
One:
PORTB.7 = 1
PAUSEUS 500
PORTB.7 = 0
PAUSEUS 500
RETURN
'------------------------------------------------------------------------
Zero:
PortB.7 = 0
PAUSEUS 1000
RETURN

/Henrik.

fratello
- 31st January 2012, 17:05
WOW !!! What fast and GREAT answer !!! :applause:
Thank YOU so much ! I will try this and post feed-back !

fratello
- 31st January 2012, 19:57
One little queries : In "SendIt:" which is the command to send (to portb.7) the data from ByteArray[n] (n=3;4;5) ? I miss something ? Thanks !

HenrikOlsson
- 31st January 2012, 20:35
Hi,
Not sure I understand what you mean....
Send it iterates thru the bytearray bit by bit. For each bit it GOSUBS either One or Zero based on if the bit is 1 or 0. It's in the routines One and Zero that the actual port is written.

With that said, the code is untested so I may have missed something.

fratello
- 1st February 2012, 07:39
I understand...Thanks !
Next step : need confirmation if works correct (just VolumeUp & VolumeDn at this moment) !
In attach : code and Proteus simulation.

fratello
- 1st February 2012, 13:32
Please, take a look at this two pictures ..."original" vs. testing ...
In "our" case, after commander begins ("an 8ms pulse at +5V and then 4.5ms at 0V"), we have 11101011110...instead 1101011111 ... :(

ScaleRobotics
- 1st February 2012, 14:17
It looks to me like the :

StartH CON %11010111 ' High 8 bits of start frame

is getting read out backwards, as it is incrementing from bit 0 to 47. I think you need to change some things so it gets read out forward.

HenrikOlsson
- 1st February 2012, 15:42
Yeah, didn't think that one thru all the way - apparently. But you're smart enought to move things around so the bits come in the right order.

fratello
- 1st February 2012, 16:04
I reverse ... something, and the results are Ok (in Proteus) ! Hope to testing soon if work ! Thank You all ! I will post the results !

;StartH CON %11010111 ' High 8 bits of start frame
StartH CON %11101011
StartM CON %11011011 ' Middle 8 nits of start frame
;StartL CON %10101011 ' Low 8 bits of start frame
StartL CON %11010101
'------------------------------------------------------------------------
VolUpH CON %11011011 ' High 8 bits of command
;VolUpM CON %11010110 ' Middle 8 nits of command
VolUpM CON %01101011
;VolUpL CON %11010101 ' Low bit of command + 7bits END of frame
VolUpL CON %10101011

fratello
- 9th February 2012, 18:46
Mr.Henrik Olsson : THANK YOU ! With some minors modification (reversing order ; changes in KeyPad2.pbp ; adding input/output timming), the code work PERFECT !!!

fratello
- 9th March 2012, 08:26
I have all information about code for JVC remote : http://www.avforums.com/forums/car-entertainment-ice-sat-nav/248455-jvc-stalk-adapter-diy-2.html#post16560076
The code is ... SO BIG :( ....
This is how commands look :


11111111000000000000000011111111
01110111011101110101010111<C>0111
11111111111111111111111111111111
01110111011101110101010111<C>0111
11111111111111111111111111111111
01110111011101110101010111<C>0111
11111111111111111111111111111111
where the <C>s should be replaced by:


0x04 Vol+ 01010111101010101
0x05 Vol- 01111010111101010101
0x08 Source 01010101111010101
0x0D Sound 01111010111101111010101
0x0E Mute 01011110111101111010101
0x12 Skip fwd or Right 01011110101011110101
0x13 Skip back or left 01111011110101011110101
0x14 Skip fwd hold or Up 01010111101011110101
0x15 Skip back hold or down 01111010111101011110101
How #*&^%$#@"_)_ can write this in PBP ? I can figure out...Any help will be wellcome ! Thanks !

fratello
- 12th March 2012, 11:41
In front of each <Command> it's this : 00000000000000001111111101110111011101110101010111 <C>
How can be writting, more "elegant" this :

timp con 536
...
portb.x = 0
pauseus 8584 ; 16 x 536,5 us
portb.x = 0
pauseus 4292 ; 8 x 536,5 us
portb.x = 0
pauseus timp
portb.x = 0
pauseus 1610 ; 3 x 536,5 us
portb.x = 0
pauseus timp
portb.x = 0
pauseus 1610
portb.x = 0
pauseus timp
portb.x = 0
pauseus 1610
portb.x = 0
pauseus timp
portb.x = 0
pauseus 1610
portb.x = 0
pauseus timp
portb.x = 0
pauseus timp
portb.x = 0
pauseus timp
portb.x = 0
pauseus timp
portb.x = 0
pauseus timp
portb.x = 0
pauseus timp
portb.x = 0
pauseus timp
portb.x = 0
pauseus 1610

HenrikOlsson
- 12th March 2012, 15:54
Hi,
As last time this is completely untested. This builds and sends the command in steps which means that there will be some delay between the "preamble", "command" and "postamble". I don't know how tight the timing has to be so doing it this way may or may not work.

'************************************************* ***************
'* Name : Fratello_JVC.pbp *
'* Author : Henrik Olsson *
'* Notice : *
'* : *
'* Date : 2012-03-12 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
i VAR BYTE
j VAR BYTE
OutBuffer VAR BYTE[8]
BitsToSend VAR BYTE


Main:
For j = 0 to 10
GOSUB VolUp
Pause 1000
NEXT

FOR j = 0 to 10
GOSUB VolDn
PAUSE 1000
NEXT
GOTO Main


SendPreamble:
' 00000000 00000000 11111111 01110111 01110111 01010101 11
' Each individual byte reversed:
OutBuffer[0] = %00000000
OutBuffer[1] = %00000000
OutBuffer[2] = %11111111
OutBuffer[3] = %11101110
OutBuffer[4] = %11101110
OutBuffer[5] = %10101010
OutBuffer[6] = %00000011

BitsToSend = 50

GOSUB SendBits
RETURN

'-----------------------------------------------------------------------
SendPostAmble:
' 01111111 11111111 11111111 11111111 11110111 01110111 01110101 010111
OutBuffer[0] = %11111110
OutBuffer[1] = %11111111
OutBuffer[2] = %11111111
OutBuffer[3] = %11111111
OutBuffer[4] = %11101111
OutBuffer[5] = %11101110
OutBuffer[6] = %10101110
OutBuffer[7] = %00111010

BitsToSend = 54

GOSUB SendBits
RETURN
'-----------------------------------------------------------------------
'-----------------------------------------------------------------------
VolUp:
GOSUB SendPreAmble
' 01010111 10101010 1
' Each individual byte reversed
OutBuffer[0] = %11101010
OutBuffer[1] = %01010101
OutBuffer[2] = %00000001

BitsToSend = 17

GOSUB SendBits
GOSUB SendPostAmble
RETURN
'-----------------------------------------------------------------------
'-----------------------------------------------------------------------
VolDn:
GOSUB SendPreAmble
' 01111010 11110101 0101
' Each individual byte reversed
OutBuffer[0] = %01011110
OutBuffer[1] = %10101111
OutBuffer[2] = %00001010

BitsToSend = 20
GOSUB SendBits
GOSUB SendPostAmble
RETURN
'-----------------------------------------------------------------------
'-----------------------------------------------------------------------
SendBits:
BitsToSend = BitsToSend - 1
For i = 0 to BitsToSend
PortB.0 = OutBuffer.0[i]
PauseUs 536
NEXT
RETURN
'-----------------------------------------------------------------------

Again, not tested so take it for what it is.

/Henrik.

fratello
- 12th March 2012, 15:59
WOW :._rolleyes: ! Amazing ! Thank YOU so much !!!
I discover, every time when someone, like YOU, post such a great example of code, how far I am from understanding this great art of programming !!!
I made the tests and post the results. Best regards !

fratello
- 12th March 2012, 17:18
I made some changes ....

VolUp:
GOSUB SendPreAmble
' 01010111 10101010 1
' Each individual byte reversed
OutBuffer[0] = %11101010
OutBuffer[1] = %01010101 ; modified
OutBuffer[2] = %00000001

BitsToSend = 17

GOSUB SendBits
GOSUB SendPostAmble

OutBuffer[0] = %11101010
OutBuffer[1] = %01010101 ; modified
OutBuffer[2] = %00000001

BitsToSend = 17

GOSUB SendBits
GOSUB SendPostAmble

OutBuffer[0] = %11101010
OutBuffer[1] = %01010101 ; modified
OutBuffer[2] = %00000001

BitsToSend = 17

GOSUB SendBits
GOSUB SendFinalAmble
RETURN
and added this :

SendFinalAmble:
' 01111111 11111111 11111111 11111111 11111111 11111111 11111111 111111
OutBuffer[0] = %11111110
OutBuffer[1] = %11111111
OutBuffer[2] = %11111111
OutBuffer[3] = %11111111
OutBuffer[4] = %11111111
OutBuffer[5] = %11111111
OutBuffer[6] = %11111111
OutBuffer[7] = %11111111

BitsToSend = 54

GOSUB SendBits
RETURN
...and in Proteus look fine !

HenrikOlsson
- 12th March 2012, 18:04
Are you sure you actually have to send the command three times? Personally I have NO knowlage about these things but I would've guessed (if this is captured from a remote for example) that it just kept repeating the command and postamble untill the button was released and then issued the 'FinalAmble'. So perhaps Preamble, Command, FinalAmble is all you actually need? Oh well, like I said, I have no idea really - just guessing, you'll figure it out.

/Henrik.

fratello
- 12th March 2012, 19:19
My informations are from one user of AVFORUMS.COM.
"Every time you send the device and command codes, you should repeat the device and command codes three times, but pause between them for about 20ms." I think it's true...

fratello
- 13th March 2012, 15:04
Still beta-testing :) ...
I wonder...It's one way to obtain EXACTLY 536.5 us ?!?

HenrikOlsson
- 13th March 2012, 15:52
Depends.... What's you oscillator speed? At 20Mhz an instruction cycles is 200ns so, in theory, doing something like

PauseUs 536
@ NOP
@ NOP
should get you pretty close (536.4us). If the timing is that critical then it's probably not going to work the way I wrote it since there will be "gaps" between the preamble, command, postamble etc. You'd need to build the complete message in a larger array and then send it but that gets a bit complicated due to the variation in length of the commands (they won't line up at even byte boundries).

/Henrik.

fratello
- 13th March 2012, 16:44
Thank You for support !
The oscillator is 4 MHz...

HenrikOlsson
- 13th March 2012, 17:52
Hi,
Well, at 4Mhz each instruction cycle is 1us so the smallest time possible to resolve at that speed is just that - 1us. I don't think I can come up with any way to get higher resolution without increasing the oscillator speed.

/Henrik.

fratello
- 13th March 2012, 18:00
Understand... so, maybe, I need a 20 MHz oscillator speed.
But first - hardware test ! Best regards !

fratello
- 23rd March 2012, 13:59
Mr.Henrik wrote the code...me just put together parts...
BUT : even if in Proteus the signal(s) appears to be OK, the HU-JVC don't react at all !
Maybe the "timming" need to be more accurate ?! At this point, I'm hopeless and stuck :( ... Any help will be appreciated !
Hex and dns attached...

;************************************************* **************************
;*
;* Test variant, using 2N3904 on output - PORTC.0
;*
;************************************************* **************************

@ DEVICE PIC16F684, HS_OSC, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_OFF
DEFINE OSC 20
include "ALLDIGITAL.pbp"

TRISA= 000011
PORTA= 000011

PORTC= 000000

CMCON0 = 000111 ' Disable analog comparators.
VRCON = 000000 ' Disable Comparator Voltage Reference
ANSEL = 000000 ' Set pin'S to digital
ADCON0 = 000000 ' Set up A/D converter - OFF

Pause 1000

i VAR BYTE
j VAR BYTE
OutBuffer VAR BYTE[8]
BitsToSend VAR BYTE


Main:
if porta.0 = 0 then gosub VolUp ' just for test
if porta.1 = 0 then gosub VolDn ' just for test

Pause 100 ' do it for 0.1 sec
Goto Main


'-----------------------------------------------------------------------
SendPreamble:
; 01110111 01110111 01010101 11
OutBuffer[0] = 010001 ; 101110 REVERSED BECAUSE OF USING TRANSISTOR AT OUTPUT !!!
OutBuffer[1] = 010001 ; 101110
OutBuffer[2] = 010101 ; 101010
OutBuffer[3] = 111100 ; 000011

BitsToSend = 26
GOSUB SendBits
RETURN
'-----------------------------------------------------------------------
AGC:
TRISC.0 = 1 ; 0
PauseUs 8584
TRISC.0 = 0 ; 1
PauseUs 4292
RETURN
'-----------------------------------------------------------------------
SendPostAmble:
' 01111111 11111111 11111111 11111111 11110111 01110111 01110101 010111
OutBuffer[0] = 000001 ; 111110
OutBuffer[1] = 000000 ; 111111
OutBuffer[2] = 000000 ; 111111
OutBuffer[3] = 000000 ; 111111
OutBuffer[4] = 110000 ; 001111


BitsToSend = 36

GOSUB SendBits
RETURN
'-----------------------------------------------------------------------
SendFinalAmble:
' 01111111 11111111 11111111 11111111 11111111 11111111 11111111 111111
OutBuffer[0] = 000001 ; 111110
OutBuffer[1] = 000000 ; 111111
OutBuffer[2] = 000000 ; 111111
OutBuffer[3] = 000000 ; 111111
OutBuffer[4] = 000000 ; 111111
OutBuffer[5] = 000000 ; 111111
OutBuffer[6] = 000000 ; 111111
OutBuffer[7] = 000000 ; 111111

BitsToSend = 54

GOSUB SendBits
RETURN
'-----------------------------------------------------------------------
VolUp:
Gosub AGC
;==============================
GOSUB SendPreAmble ; one
' Volume Up
OutBuffer[0] = 010101 ; 101010
OutBuffer[1] = 101010 ; 010101
OutBuffer[2] = 111110 ; 000001

BitsToSend = 17
GOSUB SendBits
GOSUB SendPostAmble
;==============================
gosub SendPreamble ; two
' Volume Up
OutBuffer[0] = 010101 ; 101010
OutBuffer[1] = 101010 ; 010101
OutBuffer[2] = 111110 ; 000001

BitsToSend = 17
GOSUB SendBits
GOSUB SendPostAmble
;==============================
gosub sendPreamble ; three
' Volume Up
OutBuffer[0] = 010101 ; 101010
OutBuffer[1] = 101010 ; 010101
OutBuffer[2] = 111110 ; 000001

BitsToSend = 17
GOSUB SendBits
GOSUB SendFinalAmble
RETURN ; end command
'-----------------------------------------------------------------------

VolDn:
Gosub AGC
;==============================
GOSUB SendPreAmble
' 01111010 11110101 0101
' Volume Down
OutBuffer[0] = 100001 ; 011110
OutBuffer[1] = 010000 ; 101111
OutBuffer[2] = 110101 ; 001010

BitsToSend = 20
GOSUB SendBits
GOSUB SendPostAmble
;==============================
GOSUB SendPreAmble
' 01111010 11110101 0101
' Volume Down
OutBuffer[0] = 100001 ; 011110
OutBuffer[1] = 010000 ; 101111
OutBuffer[2] = 110101 ; 001010

BitsToSend = 20
GOSUB SendBits
GOSUB SendPostAmble
;==============================
GOSUB SendPreAmble
' 01111010 11110101 0101
' Volume Down
OutBuffer[0] = 100001 ; 011110
OutBuffer[1] = 010000 ; 101111
OutBuffer[2] = 110101 ; 001010

BitsToSend = 20
GOSUB SendBits
GOSUB SendFinalAmble
RETURN
'-----------------------------------------------------------------------
SendBits:
BitsToSend = BitsToSend - 1
For i = 0 to BitsToSend
TRISC.0 = OutBuffer.0[i]
PauseUs 536
@ nop
@ nop ; for 536.5 us
NEXT
RETURN
'-----------------------------------------------------------------------
END

HenrikOlsson
- 23rd March 2012, 16:47
Hi,
Like I said earlier, with this aproach you're going to get variation in the bit to bit timing when going from preamble to data to postamble etc. You should be able to SEE this on the scope. Also verify that you actually GET 536.4us between bits (I think it'll be a bit more due to the FOR-NEXT loop) and adjust the delay to match exactly.

What I'd try, just to see IF timing is all there is to it is to stitch a complete packet together and send it in one go. Just extend the size of the array and load it up with bits, set BitsToSend accordingly and call SendBits.

/Henrik.

fratello
- 23rd March 2012, 18:30
You are such a fine gentleman !!! Thanks !
...so You say to put the entire command in "one place" ?

OutBuffer[0] = ....
to
OutBuffer[n] = ....
and
BitsToSend = n x 8 GOSUB SendBits
?!
I have some doubt about how I understand this :
"You really shouldn't drive the output line at 5V or 3V or any other voltage for a high output. If you want the output to be high, you do that by turning off the PIC's output driver. This way it doesn't matter what voltage the head unit uses, your hardware will always be compatible. It'll work at 5V, 3.3V, or anything.
To do that, search the PIC manual for "Open-drain".
For the 16-bit PIC24F series, you configure the pins as open drain by setting the bits in the ODCx register to '1's BEFORE you configure the pin as an output by writing '0's to the TRISx register."
It's ok what I wrote in code, ie how I use PortC and TrisC ?

HenrikOlsson
- 24th March 2012, 00:13
Exactly, take the complete bitstream and fill the array with that, make sure you have the correct numbers of bits and then call SendBits. Because the actuall commads seem to be of different length the n*8 may not be true, make sure to count the actual number of bits in the packet.

Regarding the other comment....It totaly depends on the actual hardware you're using but since you indicate that you're using a transistor between the PIC and the actual unit I think you need to DRIVE that transistor base high AND low, not float it by setting TRIS - again, depends on how your hardware is done.

/Henrik.

fratello
- 31st March 2012, 12:14
Since I have no results with this code, I made this "PICKit2 IR capture tool" , from here : PIC Kit 2 IR capture tool « Spiralbrain's Blog (http://sunbizhosting.co.uk/%7Espiral/blog/?p=85)
The signals captured with this tool are totally different !!! I build even an IR widget for analyzing the IR signal...My conclusions : my remote, JVC RM-RK252, send a different code than that presented till now in this topic......I post the picture of all my captures, using AND an IR_Widget with IR_Scope (yes, I build this one too !)
So : this is how the volume_up signal is ! The red part (in pdf) it's the part common for all commands ; the black part is proper command.
Can I use Mr.Henrik examples for writting the new code ?! I have some questions : 415, 560 and 1400 are values by itselfs ...How can I put them in code ? Using something like this : "Data 560, 1400 ( this in hex ?), 560,1400,560,415,560,415, so on, so on ...." ?
Thanks in advance for support and I apologize for my ignorance :( ...

fratello
- 31st March 2012, 16:51
Can be done in this way ???:

;
; testing code for new JVC Remote
; march, 31

@ DEVICE PIC16F684, HS_OSC, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_OFF, PROTECT_ON
DEFINE OSC 20
include "ALLDIGITAL.pbp"

PORTA= 000011
TRISA= 000011

PORTC= 000000
TRISC= 111110

CMCON0 = 000111 'Disable analog comparators.
VRCON = 000000 ' Disable Comparator Voltage Reference
ANSEL = 000000 ' Set pin (AN2) to analog input, the rest to digital
ADCON0 = 000000 ' Set up A/D converter - Right Just., VDD REF., CH 3, ON

Pause 1000


i VAR BYTE
j VAR BYTE
pulse con 560

main:

if porta.0 = 0 then gosub VolUp

Pause 100 ' do it for 0.1 sec

goto main


VolUp :
TRISC.0 = 1
pauseus 4000
TRISC.0 = 0
pauseus 1900
TRISC.0 = 1
pauseus pulse
TRISC.0 = 0
pauseus 1400
TRISC.0 = 1
pauseus pulse
TRISC.0 = 0
pauseus 1400
TRISC.0 = 1
pauseus pulse

for i = 0 to 30
Lookup i,[$BE,$8C,$8C,$2A,$2A,$2A,$2A,$2A,$2A,_
$8C,$2A,$2A,$2A,$2A,$2A,$2A,$2A,$2A,_
$8C,$2A,$2A,$2A,$8C,$2A,$2A,$2A,$2A,_
$2A,$2A,$8C,$8C] ,j
TRISC.0 = 0
PauseUs j*10
TRISC.0 = 1
PauseUs pulse
next i
Return
In Proteus it's ok ; just the "preamble" part so far.
Any advice will be wellcome !

fratello
- 31st March 2012, 19:28
This code :

i VAR BYTE
j VAR BYTE
pulse con 560

main:

if porta.0 = 0 then gosub volup
TRISC.0 = 1
goto main


VolUp :
Gosub Preamble
FOR I = 0 TO 17
Lookup i,[$8C,$2A,$2A,$8C,$2A,$2A,$2A,$8C,$2A,$8C,_
$2A,$2A,$2A,$2A,$8C,$8C,$8C,$8C ] ,j
TRISC.0 = 0
PauseUs j*10
TRISC.0 = 1
PauseUs pulse
next i
PauseUs 4500
RETURN

Preamble :
TRISC.0 = 1
Pauseus 4000
for i = 0 to 30
Lookup i,[$BE,$8C,$8C,$2A,$2A,$2A,$2A,$2A,$2A,_
$8C,$2A,$2A,$2A,$2A,$2A,$2A,$2A,$2A,_
$8C,$2A,$2A,$2A,$8C,$2A,$2A,$2A,$2A,$2A,$2A,_
$8C,$8C ] , j
TRISC.0 = 0
PauseUs j*10
TRISC.0 = 1
PauseUs pulse
next i
Return
give me, in Proteus (!), the code I need ...The next step it's hardware testing !

fratello
- 1st April 2012, 19:33
I put all the values into one command :

pulse con 567

MAIN :
if porta.0 = 0 then
PORTC.0 = 0
pauseus 4032

for i = 0 to 48
lookup i, [value, value, value, ....], j
PORTC.0 = 1
PauseUs j
PORTC.0 = 0
PauseUs pulse
next i

PORTC.0 = 0
PauseUs 4500
PORTC.0 = 1
ENDIF

PAUSE 25
goto main
...but testing hardware I have no results :( , despite the "full similarity" with code captured with IR_Scope !
Somebody has more experience with IR remote control ? It's the "lenght" of each pulse so critical ?
I don't understand what I do wrong ...

fratello
- 2nd April 2012, 18:08
Still no good news ... Cycle " for ...next" generate a "big" delay ?

gadelhas
- 2nd April 2012, 18:49
Hi fratello;

I dind't read the hole thread, but are you trying to reproduce a IV remote control??
If so, i see on your last post that your reproducing the pulses, but you are not using modulation, and you must use modulation when using IV. Probably 36Khz, or 38Khz, or 40Khz.

HenrikOlsson
- 2nd April 2012, 18:50
Hi,
The actual FOR-NEXT construct will add some additional delay due to the fact that it is a jump isntruction and it has to make the comparison. Add to that the execution time of the LOOKUP instruction you're using. Why don't you just measure it and adjust the pulse constant so it matches the capture of the working remote?

/Henrik.

fratello
- 2nd April 2012, 20:07
Thanks !
@Gadelhas : I try to build a wired-remote, not IR remote ; I use IR remote just for reading codes, but I intend to use wired - steering wheel - remote.
@Henrik : Good ideea !!! I will try tomorrow to read MY signal ...by putting one LED to PIC output (?!)

fratello
- 3rd April 2012, 13:55
I make reverse-engineering ... I put one IR-LED on output (driving by transistor) to see how the code work !
And... surprise ! It's totally different by Proteus simulation and my whis !!!
Despite I try to "PauseUs 560" the Pauseus, measured in IR_Scope, it's 202 to 208 us !

I read this : "PAUSEUS assumes an oscillator frequency of 4MHz ;PAUSEUS 1000 ' Delay for 1 millisecond "
It's not applicable on my code ?! Why ? I use an 4 MHz crystal , I define "XT_OSC" ... I really don't understand :( ...

HenrikOlsson
- 3rd April 2012, 17:11
Hi,
Are you sure that it is a 4Mhz and not a 10Mhz crystal?
Do you have the correct capacitors inplace to load the crystal?

Try something like

TRISC.0 = 0
Main:
PortC.0 = 1
Pauseus 1000
PortC.0 = 0
Pauseus 1000
Goto Main
What's the frequency of the output signal?

/Henrik.

fratello
- 3rd April 2012, 17:20
Unfortunately, I dont have an oscilloscope ...I use just software tools, which are not so accurate !
I capture the signal with OSCILLOSCOPE V1.40 and it's ok (measuring all pulses and pauses, dont know how accurate)...
I am in big deadlock ! I don't know what else I can do.

kolega35
- 3rd February 2014, 11:26
Hi! I am from Turkey. Taken in the forum I read that you are running on the remote control for Alpine.What did you use microcontrollers. I worked very hard, but did not succeed. Can you give pbp code for alpine? My adress is [email protected] Thanks.
Mr.Henrik Olsson : THANK YOU ! With some minors modification (reversing order ; changes in KeyPad2.pbp ; adding input/output timming), the code work PERFECT !!!