Basic 8 Channel RC5 Infrared Remote Control

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Basic 8 Channel RC5 Infrared Remote Control

Post by medelec35 »

RC5 Eblock See:
http://www.matrixmultimedia.com/product.php?Prod=EB060
Is a great Eblock for a Cheap basic DIY infrared remote control.
Important: Jumper must be on A

If you have not got a RC5 Compatible Remote then a Tip would be to buy a universal remote for as little as 99p in our UK 99p store.
Just enter a code in the remote for philips TV and it should not take long to find correct code.

Remote does not have to be for philips TV so long as it is RC5 compatible.
For Example laying around I have got the following remotes that work:
old NTL and newer Virgin media remotes, Philips video remote and a ONE FOR ALL universal remote.

Attached is a Basic Flowcode V5 Flowchart that will control 8 channels using RC5 component.
The secret for keeping the Flowchart small is:

Code: Select all

CH_Output = CH_Output XOR (1 << CHANNEL - 1) 
It may look a bit daunting, but all it does is toggle each CHANNEL-1 individual bit only when that bit is high..
So if port b = 00011100
and CHANNEL = 2 = 00000010
then bit1 (due to CHANNEL-1 part) is toggled
So result = 00011110 which is passed on to port B
If same key is press (2 on the remote)
then result will be 00011100 again.

Operation is simple.
On your Philips RC5 compatible Remote:
Press 1 to toggle bit 0 (Think of it as Channel 1 of Relay 1 Etc.)
Press 2 to toggle bit 1
Press 3 to toggle bit 2
Press 4 to toggle bit 3
Press 5 to toggle bit 4
Press 6 to toggle bit 5
Press 7 to toggle bit 6
Press 8 to toggle bit 7
Press 0 to switch all channels off.
To toggle a channel press key then release.
I have placed a routine that waits for key to be released before channel will change state.

Flowchart will not simulate due to RC5 component but have a play with the formula to understand how it works.

Although I have used a 16F877A, this should work on other devices e.g 16F88.
IR receiver is connected to port A2

This will work well with either Relay Eblock:
http://www.matrixmultimedia.com/product.php?Prod=EB038
Or
Optocoupler Eblock:
http://www.matrixmultimedia.com/product.php?Prod=EB035

Or your own hardware of course :)

I can't say the range for sure, since the room i was in is 20 ft and there was no issues at the 20ft range.

If you want to adapt with more or less channels and I will alter flowchart for you.

Martin
Attachments
RC5 Basic 8 Channel Remote Controller.fcf
(9.5 KiB) Downloaded 1550 times
Martin

bercioiu
Posts: 161
Joined: Sun Feb 25, 2007 10:56 am
Location: bucharest, romania
Has thanked: 90 times
Been thanked: 34 times
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by bercioiu »

Hi Martin!

Thank you for sharing this with us!

For reasons unknown for me, I can`t compile that with 16F690 or 16F631. I need that particular chips because I have one ready made PCB for a remote controlled receiver that use a 20 DIP micro controller and I want to use it.
So, when i chose in Flowcode to compile, I receive following error:

Code: Select all

Licence:   Professional
Registered to: Puiu Bercioiu
http://www.matrixmultimedia.com
Launching the compiler...
..................

Remote.c(524:23): error: unknown identifier 'TMR0IE'
Remote.c(524:23): error: invalid operand 'TMR0IE'
Remote.c(524:18): error: failed to generate expression
Remote.c(524:18): error: invalid operand '<<'
Remote.c(524:12): error: failed to generate expression
Remote.c(548:36): error: unknown identifier 'TMR0IF'
Remote.c(548:36): error: invalid operand 'TMR0IF'
Remote.c(548:31): error: failed to generate expression
Remote.c(548:31): error: invalid operand '<<'
Remote.c(548:26): error: failed to generate expression
Remote.c(548:26): error: invalid operand '& '
Remote.c(548:14): error: failed to generate expression
Remote.c(557:24): error: unknown identifier 'TMR0IF'
Remote.c(557:24): error: invalid operand 'TMR0IF'
Remote.c(557:19): error: failed to generate expression
Remote.c(557:15): error: invalid operand '~(1 << ( TMR0IF))'
Remote.c(557:12): error: failed to generate expression
Remote.c(882:25): error: unknown identifier 'TMR0IF'
Remote.c(882:25): error: invalid operand 'TMR0IF'
Remote.c(882:20): error: failed to generate expression
Remote.c(882:16): error: invalid operand '~(1 << ( TMR0IF))'
Remote.c(882:13): error: failed to generate expression
Remote.c(889:24): error: unknown identifier 'TMR0IE'
Remote.c(889:24): error: invalid operand 'TMR0IE'
Remote.c(889:19): error: failed to generate expression
Remote.c(889:19): error: invalid operand '<<'
Remote.c(889:13): error: failed to generate expression
Remote.c(939:25): error: unknown identifier 'TMR0IE'
Remote.c(939:25): error: invalid operand 'TMR0IE'
Remote.c(939:20): error: failed to generate expression
Remote.c(939:16): error: invalid operand '~(1 << ( TMR0IE))'
Remote.c(939:13): error: failed to generate expression
Remote.c(1430:27): error: unknown identifier 'TMR0IE'
Remote.c(1430:27): error: invalid operand 'TMR0IE'
Remote.c(1430:22): error: failed to generate expression
Remote.c(1430:22): error: invalid operand '<<'
Remote.c(1430:17): error: failed to generate expression
Remote.c(1430:62): error: unknown identifier 'TMR0IF'
Remote.c(1430:62): error: invalid operand 'TMR0IF'
Remote.c(1430:57): error: failed to generate expression
Remote.c(1430:57): error: invalid operand '<<'
Remote.c(1430:52): error: failed to generate expression
Remote.c(1430:17): error: invalid operand '& '
Remote.c(1430:52): error: invalid operand '& '
Remote.c(1430:38): error: failed to generate expression
Remote.c success

failure

.Return code = 1
Flowcode was unable to compile the flowchart's C code due to the following errors:


If your flowchart contains C code, please review this carefully. If your flowchart contains no C-code or you have thoroughly reviewed the code, contact Technical Support.


FINISHED
Hope you can help me and tel me how to alter the Flowcode example for that chip. Thank you!

This is the PCB that I want to use for my application:
Attachments
20130406_002924.gif
20130406_002924.gif (114.25 KiB) Viewed 35342 times
Last edited by bercioiu on Fri Apr 05, 2013 11:40 pm, edited 1 time in total.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by medelec35 »

Hi bercioiu,
Issue is with the RC5 component for 16F690.
I have altered flowchart for 16F690 but not tested on hardware so can't guarantee it will work.

Martin
Attachments
RC5 Basic 8 Channel Remote Controller 16F690.fcf
(30.15 KiB) Downloaded 1192 times
Martin

bercioiu
Posts: 161
Joined: Sun Feb 25, 2007 10:56 am
Location: bucharest, romania
Has thanked: 90 times
Been thanked: 34 times
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by bercioiu »

Thank you for your fast reply, Martin!

If I don`t ask too much, I saw that is used only 0.5k from ROM and 70 bytes from RAM, so, what do you alter in the example, (because I can`t see any differences) if I wan`t to change for 16F631 ( I have a lot of that chip and for the moment I don`t have 690).
Thank you again!


Later edit:

Never mind, I manage to change to 631 but it didn`t fit in 631... only for 7 bytes... :-(
Last edited by bercioiu on Fri Apr 05, 2013 11:57 pm, edited 1 time in total.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by medelec35 »

Your welcome.
I Modified the custom code for RC5 component.
I afraid it won't work on 16F631 as there will not be enough RAM available on that target device.

If you do decide to use a 16F690, I have not modified the configuration settings as I won't know what hardware you have got.
Martin

bercioiu
Posts: 161
Joined: Sun Feb 25, 2007 10:56 am
Location: bucharest, romania
Has thanked: 90 times
Been thanked: 34 times
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by bercioiu »

Mean time, I edit upper post, yes you are right, did not fit and I have to add more instruction, so I will use 16F690, it`s much bigger than 631. Thank you again!

P.S.
I have one more question for you. What is the frequencies for the IR Receiver LED Module? 36 or 38 KHz?

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by medelec35 »

Your welcome.

I used this Eblock:
http://www.matrixmultimedia.com/resourc ... 0-30-1.pdf
Which uses a TsOP1236.
According above datasheet and:
http://www.vishay.com/docs/82013/tsop12xx.pdf
carrier is 36KHz
Martin

bercioiu
Posts: 161
Joined: Sun Feb 25, 2007 10:56 am
Location: bucharest, romania
Has thanked: 90 times
Been thanked: 34 times
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by bercioiu »

Unfortunately it did not work with 690.
I alter the flowchart for the 648 but still there is a problem... It work only with external oscillator. I tried with 8 MHz internal oscillator and did not respond. There is an explication? It is another issue?
Thank you again for your time!

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by medelec35 »

Your welcome.
I have a 690 laying around somewhere, but I wont be able to check it out until Sunday evening.
If I find anything out I will post information.
Martin

bercioiu
Posts: 161
Joined: Sun Feb 25, 2007 10:56 am
Location: bucharest, romania
Has thanked: 90 times
Been thanked: 34 times
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by bercioiu »

Thank you Martin for your consistently help!
I`ll be happy to use that chip because I can use that PCB without any modification. :)

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by medelec35 »

Hi bercioiu,
One mistake I have made is i have set the port C output to bit0 rather than the whole of portC.
Even with that changed there is still no output.

It looks like RC5 is not decoding for 16F690.
Benj is the expert on this.

Ben would you mind letting us know what the issue is please?
Also is it possible to get RC5 to work with 16F690 wichout the need of altering custom code.
Unless I'm totally missing something, and RC5 is not suppose to work with 16F690?
Martin

bercioiu
Posts: 161
Joined: Sun Feb 25, 2007 10:56 am
Location: bucharest, romania
Has thanked: 90 times
Been thanked: 34 times
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by bercioiu »

Hi martin!
Thank you again for your reply!
I notice that output of port C. In fact, my flowchart is totally different that yours but The issue is the same... I ask your help to set that flowchart and after that I alter that file after my needs. In the present The only way that work is to use 16F648A with external oscillator at 19,660800 MHz. I can`t use external oscillator on that PCB because the IR receptor is routed at the pin 16 of the 16F648 (if I put 16F648 instead of 16F690). So, what are the settings to config the internal oscillator at 4MHz? In fact the question is: RC5 can work with the internal oscillator and if the answer is ye, how? I tried a lot of chips (many models like 16F628, 16F88 etc) with internal oscillator but with no luck. What do I doing wrong?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by Benj »

Hello,

Adding these two lines of code to the defines section of the supplementary code window fixes the compile issue for the 16F690.

Code: Select all

#define TMR0IE T0IE
#define TMR0IF T0IF
I will see if there is a better way around this as it would be good to get rid of this issue.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by medelec35 »

Hi Ben,
Thanks for your reply.
I had customised code to:

Code: Select all

#define %a_TIMER_ENBIT			T0IE
#define %a_TIMER_FLAGBIT		T0IF
So it compiled ok
The issue outstanding is there is no response out from RC5.
Its not decoding RC5 IR from remote, and I could not see the reason for this?

Martin
Martin

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by jgu1 »

Hi Ben & Martin!

When I look in proporties for RC 5 and in helpmenu, I se this:

char RC5_Collect_Data ( char Selection )

Collects a section of the received signal.

Selection = 0 - Command is read back

Selection = 1 - Address is read back

Selection = 2 - Toggle bit is read back

Is this the 3 command we have to choose in Expressionmenu in proporties for "Selection BYTE" RC5 Collect data.



What does that mean :?: Please

Best regard

Jorgen.

bercioiu
Posts: 161
Joined: Sun Feb 25, 2007 10:56 am
Location: bucharest, romania
Has thanked: 90 times
Been thanked: 34 times
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by bercioiu »

Hi Jorgen,

Image

"In this picture is shown the shape of the complete RC5 packet, ready for transmission"

As you can see bit0-bit2 are "potion" of the one packet transmission, for more detailed information, look at the Fotios`s thread here, it is very detailed explain how RC5 works.

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by jgu1 »

Hi Bercioiu!

Thank you wery much for the explanation. So these Bit is for the start, toggle, adress and command I suppose. I will read the tread and laern. :D

Best regard

Jorgen

bercioiu
Posts: 161
Joined: Sun Feb 25, 2007 10:56 am
Location: bucharest, romania
Has thanked: 90 times
Been thanked: 34 times
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by bercioiu »

I had discover the misery about 690 :-)
It`s a problem with the EB006 board. It was my bad because I don`t look at the schematic... Bytes 0-2 to the port A on the 20 pins socket (690) are routed to B port header RA0 to RB7, RA1 to RB6 and RA2 to RB2...It`s logic, because RA0 and RA1 are pins for programmer (PGD and PGC)... My IR sensor was connected on RA2 on the portA header...
So, I put the chip on breadboard and is working like a charm. The only issue that it remains is the internal RC oscillator, It work only at the max 2MHz... I am not sure about this, but when we set the internal oscillator, that frequency is the efective frequency of the MCU? Or that that frequency is divide by 4 like at the external oscillator? Or is multiplied by 4? How it works?
Thank you again, and sorry for my grammar... :oops:

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by medelec35 »

Well spotted!
I only mentioned about portA access for 16F690 yesterday:
http://www.matrixmultimedia.com/mmforum ... 172#p47052
medelec35 wrote: Are you using Eblocks e.g programmer and EB005 LCD?

If so then LCD will not work as there are only two pins that will work on port A of programmer,

That is A6 (this is RA4 on target device) and A7 (this is RA5 on target device).
Thats the point when the penny should of dropped, but it did not :oops:

I think I need a holiday! :)

Martin
Martin

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by medelec35 »

bercioiu wrote: The only issue that it remains is the internal RC oscillator, It work only at the max 2MHz... I am not sure about this, but when we set the internal oscillator, that frequency is the efective frequency of the MCU? Or that that frequency is divide by 4 like at the external oscillator? Or is multiplied by 4? How it works?:
Try this:
Set your clock speed to 8MHz
place a C code block at the beginning of your Flowchart with:

osccon=0x70;

That should run your internal oscillator at 8MHz
With no osccon at the beginning, the internal osc runs at the default setting of 4MHz, So the clock speed should be set at that.

Hope this helps

Martin
Martin

bercioiu
Posts: 161
Joined: Sun Feb 25, 2007 10:56 am
Location: bucharest, romania
Has thanked: 90 times
Been thanked: 34 times
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by bercioiu »

No luck :( Tried that before...

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by JohnCrow »

Hi
Out of interest
Ive tried the following remotes with the RC5 Eblock

Hauppauge remote for a USB TV decoder - This works
Aiwa video recorder remote - Doesn't work
JVC Midi Hifi remote - Doesn't work

Think I might look for one of the philips ones as I have ideas for a RC5 project myself.
Ive got some TSOP38236 devices to try, which though not pin compatible with the TSOP1236 look to be an almost identical specification.
In fact looking at the "Not for new design" statement on the TSOP1236 data sheet, I wonder if it is being phased out.
1 in 10 people understand binary, the other one doesn't !

bercioiu
Posts: 161
Joined: Sun Feb 25, 2007 10:56 am
Location: bucharest, romania
Has thanked: 90 times
Been thanked: 34 times
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by bercioiu »

You have to "breadboard" this flowchart (Martin`s flowchart) and test your remote if it is RC5 compatible. The LCD will display Address and Data (Command) bytes of the remote.

ssears
Posts: 5
Joined: Fri May 09, 2014 5:28 pm
Has thanked: 1 time
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by ssears »

Thank you for your post on this project has been very helpful in learning the RC5 component in Flow Code. Do you have a schematic of the circuit?

Thanks

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Basic 8 Channel RC5 Infrared Remote Control

Post by medelec35 »

Hi ssears,
No I don't have a schematic as I used Eblocks, but I can help you develop the hardware as there are not many components used.
The heart of the receiver is used in the EB060 is TSOP1236.
It's just a IR receiver which contains a photo detector and preamplifier.
If you look at the Datasheet, you can see how its connected to the RX of the microcontroller
The other Eblock used is EB038 Quad Relay board
If you look at that Datasheet, it should help to follow the description below
The idea being when an output pin goes high, this turns on a transistor via a current limiting resistor.
The transistor acts as a on switch, it pulls the 0V side of the relay to nealy 0V.
Since the other side of the relay is connected to +supply, the relay energises.

If you require any more help, I will be happy to assist you further.

Martin
Martin

Post Reply