Remote Control Handset "1"

For users of Matrix Multimedia Electronics software to discuss projects, circuits and any other electronics concepts.

Moderators: Benj, Mods

Post Reply
User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Remote Control Handset "1"

Post by fotios »

MINI INFRA RED REMOTE CONTROL HANDSET

A GENERAL VIEW
One of the nice peripherals included in the new range of micros recently launched from Microchip, is the Data Signal Modulator (DSM) that can provide a ready for transmission modulated signal, eliminating the need for external parts. The modulation function is executed inside the micro, where both the Carrier and the Modulator signals are mixed and then provided at its MDOUT pin. This function is useful to build remote control transmitters like this of the current project which is a mini IR remote control handset that offers the 4 basic functions: STBY, MUTE, VOL+ and VOL-. The transmission protocol that used is the Philips RC-5. Flow Code offers a ready RC-5 component that includes any necessary macro and its use is very simple: Click on it in the components bar and will drop on project panel. Make the required configuration and connections thru its properties and connections windows and you are ready! The number of parts required for a complete unit – see in photos – is impressively small. Just 14 parts (included the micro, the battery, the PCB and the plastic case) are needed to build the unit and the total cost is about 7.50 Euro.

THE CIRCUIT
A 18 pin PIC16F1827 micro is the heart of the unit, providing the modulated signal at its MDOUT pin (RB.3). A high bandwidth NPN transistor (BC547) is used to isolate the MDOUT of micro from the current that flows thru the 2 parallel connected LED. The one is a common 3mm green LED which blinks in the rate of the sequential RC5 packets that transmitted, while the other is a 940nm IR LED that transmits the RC5 encoded signal in the infrared region of spectra. In practice the green LED serves just to indicate that the transmitter is working and that the battery is in good state. Four momentary push switches (tactile type) are used to activate the 4 functions, connected at four inputs (RB.4 – RB.7) of micro. The internal “weak pull – ups” of these pins are enabled as well their IOC interrupt. When a switch is pressed drives the corresponding input in LOW state causing an "Interrupt On Change" (IOC) that is used just to wake up the micro from its SLEEP state. The SLEEP function saves the battery power which is a 3V Lithium cell. In actual measurements, the current that flows from battery during SLEEP mode is just 25μA, while during ACTIVE mode is 3.7mA average.

THE PROGRAM CODE
It has obtained with the use of Flow Code v5. The configuration settings of P16F1827 are few: INTOSC, BOR and POR resets are enabled while everything else is disabled. MCLR pin is disabled (is tied internaly to Vdd) as the micro General Reset is covered from the combination of POR and BOR resets. BOR level is set to 1.9V because the 3V battery.
The INTOSC of 16F1827 is automatically set at 500 KHz after each reset, so we have to initialize it at 16MHz which is a suitable frequency for the current project that demands a 36KHz Carrier frequency according to RC5 TX-RX protocol. As source of the Carrier frequency has been selected the CCP1 (PWM Channel 1) internal module of micro. By setting its Period Register = 110 (see in PWM compo properties window) and under the given Clock speed of 16MHz we get a period of 27.75μs which corresponds exactly to the target frequency = 36.03604 KHz. Furthermore, the Duty Cycle of PWM is set to “30” or 27% (actually between 25 – 30%). This setting offers additional saving of battery power.
The Modulation signal source is the Flow Code RC5 component (combined with the related program code) that generates the RC5 packets which comprised from the RC5 address, RC5 command and RC5 toggle bit.
The DSM module can be configured in several ways. In the current project all peripheral outputs are disabled and as Modulation input of DSM is selected the MDMIN pin (RB.2). This pin has also been selected as the TX output of RC5 component (see in RC5 connections window) and so the Modulation data are transferred internally (thru the Port RB.2 register) to the DSM. Then the Modulation data are mixed with the HIGH Carrier signal (the LOW Carrier signal is connected to Vss so is always “0”) produced by CCP1 inside the DSM and finally the mixed signal is exported to the MDOUT (RB.3) pin of micro.
A special Loop in the beginning of Flow Chart gives the possibility to select between two different TX address: “16” (RC5 preamp 1) or “19” (RC5 preamp 2). The address “16” is selected by default. To change the address in “19” we have to remove – insert the battery (causing thus a device reset) and to press within 3 seconds the MUTE switch. To recover again the address “16” we simply have to remove – insert the battery without pressing any switch.
In the MAIN program Loop we can see two branches. When the device is inactive the command “SLEEP” is continuously executed. When a switch is pressed it causes an IOC interrupt that wake up the micro from its SLEEP state. The macro “WEAK_UP” exists because the interrupt has to call a… macro and nothing more. After this, a “Switch” icon detects which switch is pressed and accordingly steers the program flow into one of the 4 branches where the variable “RC5cmd” gets the corresponding value. Then the program flow is turned into the second “Switch” icon where the TOGGLE bit is changed or keeps its previous state. It should be noted that the use of TOGGLE bit is necessary. That is because the RC5 Receivers are programmed to handle the STBY and MUTE function in a different way from the VOL+ and VOL- function. STBY and MUTE are executed once and to be executed again we have to release and press again the corresponding switch, while the VOL+ and VOL- are executed continuously as long as the corresponding switch is pressed. You can try the FCF on simulator to see how the TOGGLE bit changes its state. Select a speed of 100, press the RUN button and add in Variables window the “TOGGLE” variable. Press any switch firmly or momentary and keep an eye on variable “TOGGLE” to observe when its state is changed. In the end of branch, and inside the compo macro “RC5_TX_Packet”, the RC5addr – RC5cmd – RC5toggle variables are combined to form a RC5 packet ready for transmission.

CONSTRUCTION & CONCLUSIONS
In this project a SMD P16F1827 (SOIC wide package) is used and so a double sided PCB is necessary. After completing it, I found that inside the box could fit even a conventional PDIP package 16F1827. Though is not so difficult to solder a SOIC device as the only needed is a soldering iron equiped with fine tip and some attention. The PCB is 34mm X 61mm home made. The rest parts can be soldered very easy as they are Through Hole type (THT). To program the SMD micro its ICSP capability should be used. You can see in the left side of PCB the 5 holes (Vpp, Vdd, Vss, PGC and PGD) in which 5 wires are temporarily solderd to communicate with the EB006 programmer. (For this work I use my own made adaptor on which are mounted a 40pin ZIF socket and an ICSP header)
The plastic case is an excellent TEKO 1124.4 (ABS molded) Pocket size. Is formed from 3 separate pieces, the bottom the top and the battery cover. The three pieces can snap to each other very easily and there is no need for screws. The bottom piece provides supports and two guide pins for the mounting and the perfect alignment of the PCB. The PCB can be easily inserted or removed to - from its base. Inside the TEKO package included the 4 key caps which can fit only in tactile switches. The actuators of switches should have a height of 3.4 to 3.7 mm to fit in caps. The only modification that we have to do on the TEKO case is to open a 5mm hole for the IR LED (see in photo).
And now the question: Is it or not worthy the build of this small handset? I did enough research (though, as a DIYer I had no one reason to do this) on the web in this direction. There are enough RC5 compatible universal remote handsets offered on e-bay and other on-line shops for 5 to 7 Euro. There are also original Philips for 15 Euro. Their main disadvantages are three: a) All of them transmit the RC5 address “0” which is dedicated to TV sets. No one transmits the RC5 address “16” or “19” which are dedicated to audio preamplifiers. 2) Are cluttered from 30 to 40 buttons of which just 8 to 10 are useful to control a preamplifier. 3) In all of these is used a low quality membrane type keypad and a cheap non-epoxy PCB that can break easily under press. When a key or the PCB fails (which usually occurs very soon) the remote control handset is for the garbage.I have throw in the trash bin enough such type remote control handsets.
Looking at this small remote handset, its total cost at 7.50 Euro looks some big. Only the cost of the TEKO case is 3.56 Euro, but is of high quality made from very rugged ABS plastic (it is almost unbreakable) and can be disassembled very easily. The other benefit is that transmits the dedicated address for preamps. Its third benefit is the replaceable tactile switches that used. When a switch completes its service life can be easily replaced with a new one as its de-soldering is very easy. Taking into account the above, this "repairable" small unit can be characterized as a “lifetime” device.
In my own view, this project is not for mass production. It is for use from DIYers, hobbyists etc.
And of course is the companion of the project REMOTELY CONTROLLED MOTORIZED VOLUME POT. http://www.matrixmultimedia.com/mmforum ... =3&t=10298
I have already in process a bigger handset that will cover 15 to 20 different functions for the upgrade of multipurpose PGA2310 preamplifier.
Mini Handset 1.jpg
Mini Handset 1.jpg (72.12 KiB) Viewed 26113 times
Mini Handset 2.jpg
Mini Handset 2.jpg (91.65 KiB) Viewed 26113 times
Mini Handset 3.jpg
Mini Handset 3.jpg (67.11 KiB) Viewed 26113 times
Mini Handset 4.jpg
Mini Handset 4.jpg (66.66 KiB) Viewed 26113 times
Best Regards FOTIS ANAGNOSTOU

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: REMOTE CONTROL HANDSET "1"

Post by fotios »

Here is the fcf file of project
Attachments
Remote Control Handset MINI_v5.fcf
(23.01 KiB) Downloaded 1352 times
Best Regards FOTIS ANAGNOSTOU

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: REMOTE CONTROL HANDSET "1"

Post by fotios »

Here is the schematic and the PCB layout. In the last two pdf files you can find the artworks of component side and solder side in 1:1 ready for printing in artwork film for those who are enough brave :wink: to build this project.
Attachments
REMOTE CONTROL MINI_SCH.pdf
(18.99 KiB) Downloaded 1224 times
REMOTE_CONTROL_MINI_MASK.pdf
(8.2 KiB) Downloaded 995 times
REMOTE CONTROL MINI_SOLDER.pdf
(7.65 KiB) Downloaded 1030 times
REMOTE CONTROL MINI_COMPO.pdf
(8.6 KiB) Downloaded 1055 times
Best Regards FOTIS ANAGNOSTOU

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: Remote Control Handset "1"

Post by fotios »

Here two more pictures of the case.

In this is shown the hole of the IR Led in detail
Mini Handset 5.jpg
Mini Handset 5.jpg (34.76 KiB) Viewed 26062 times
In this is shown the home made sticker.
Mini Handset 6.jpg
Mini Handset 6.jpg (28.49 KiB) Viewed 26062 times
Best Regards FOTIS ANAGNOSTOU

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Remote Control Handset "1" Without use of FlowCode RC5 compo

Post by fotios »

The attached fcf file actually is the same like the original fcf posted above. In this file I have just removed the Flow Code RC5 component replacing it with its code expanded. I did this, in case there are people interested for a deeper view on how this Remote Control Handset encodes and transmits the RC5 codes. In the following text this will be analysed through simple Flow Code icons, step by step and without using macros.
A small tutorial about RC5 protocol: Each transmitted packet is formed by 14 bits. The time of each bit is 1.776msec. Each bit is biphasic which means that changes state in the middle of his time, with other words a bit is considered as logic “1” when for the first 888μsec (1.776msec / 2) is LOW and for the next 888μsec is HIGH and vice versa.
The two first bits of packet are the START bits and are always “1” and used from the RC5 receiver IC for AGC. The 3rd bit is the Toggle bit and used from the receiver to recognize if a button on the transmitter is firmly pressed or is repeatedly pressed. That is useful for some functions. Each time we press a button on remote control handset, the Toggle bit changes state. The next five bits constitute the RC5 address code. Each address code is used by the RC5 receiver to detect whether the received packet is for his own use. For example, according to RC5 protocol system, the address code 16d (10h) is dedicated to “audio preamplifier 1”, the address code 19d (13h) is dedicated to “audio preamplifier 2” and the address code 0d (0h) is dedicated to “TV set”. The last six bits constitute the RC5 command code. Each command code is used by the RC5 receiver to activate a concrete function. There is a table of RC5 protocol where is explained in which function is dedicated each command code.
In the first post, we have seen how the RC5 packet modulates a 36KHz carrier frequency and how is transmitted. We will now see how a RC5 packet can be formed to provide a modulation signal, through the use of common Flow Code icons and some logical operations between variables avoiding thus the use of C code and macros.
The entire process occurs within the MAIN Loop, starting from the “switch SWITCH” icon where verified which button has been pressed. Remember that all buttons are “active LOW” and when pressed drive the corresponding input in LOW state. First of all, suppose that the RC5 Address has already initialized to the value 16d = 0x10h. Suppose now that the button STBY has pressed, then in Port B register is written the binary number 1110 0000b = 0xE0h that is transferred into variable “SWITCH”. This number is verified into “switch SWITCH” icon and the program flow is turned to the first branch “0xE0” or “STBY = 12”. In the first Calculation icon the variable “RC5cmd” gets the corresponding value 12d = 0x0Ch:
RC5cmd = 12
In the next Calculation icon the five Address bits are extracted into variable “RC5packet”. The variable “RC5packet” is defined as integer type and has a length of 16 bit:
RC5packet = RC5addr AND 0x1F where 0x1Fh = 0001 1111b and RC5addr = 0001 0000b, so the result of calculation will be: RC5packet = 00 0000 0001 0000 (0x10h)
In the next Calculation icon the last 5 bits of variable RC5packet are shifted LEFT by 6 places. In this way, the 5 Address bits take their position provided by the RC5 protocol into the RC5packet and leave free the last 6 positions for the 6 Command bits:
RC5packet = RC5packet << 6 and the result is: RC5packet = 00 0100 0000 0000 (0x400h)
In the following Calculation icon the 6 Command bits are extracted into variable “RC5packet”:
RC5packet = RC5packet OR RC5cmd where RC5cmd = 12d = 00 1100b and the result is now: RC5packet = 00 0100 0000 1100 (0x40Ch)
In the next Calculation icon the 2 Start bits are set:
RC5packet = RC5packet OR 0x3000h where 0x3000h = 11 0000 0000 0000b and the result is: RC5packet = 11 0100 0000 1100 (0x340Ch)
Remote Control Handset MINI no COMPO_1.JPG
Remote Control Handset MINI no COMPO_1.JPG (36.91 KiB) Viewed 26014 times
Then it follows the “switch TOGGLE” icon where is examined the state of variable “TOGGLE”. Let’s take a look on the history of this variable: Suppose that the STBY button has been pressed for first time after a general Reset of the micro. In the beginning of Flow Chart all variables are cleared and so the “TOGGLE” = 0, a value that is verified into “switch TOGGLE” icon and so the program flow is turned to the first branch “= 0x00”. In the Calculation icon the Toggle bit of RC5 packet is Set and then the variable “RC5toggle” is also Set:
RC5packet = RC5packet OR 0x3800 where 0x3800h = 11 1000 0000 0000b and the result is: RC5packet = 11 1100 0000 1100 (0x3C0Ch)
RC5toggle = 0x01
In this picture is shown the shape of the complete RC5 packet, ready for transmission:
RC5_CODE_BitStream.jpg
RC5_CODE_BitStream.jpg (57.44 KiB) Viewed 26003 times
If the STBY button is firmly pressed the program flow always pass through the same branch “0xE0” of “switch SWITCH” icon. Therefore the variable “TOGGLE” keeps its initial value = 0x00h and the program flow pass again through the same branch “0x00” of “switch TOGGLE” icon and both “RC5packet” and “RC5toggle” variables are not changed.
Remote Control Handset MINI no COMPO_2.JPG
Remote Control Handset MINI no COMPO_2.JPG (18.95 KiB) Viewed 26014 times
If the STBY button is released then in Port B register is written the value 1111 0000b = 0xF0h which is also transferred to the variable “SWITCH”. The new value “SWITCH = 0xF0” does not match with any of the 4 branches of “switch SWITCH” icon, so the program flow follows the straight branch where the variable “TOGGLE” gets the value previously stored into variable “RC5toggle” = 0x01 through the Calculation icon:
TOGGLE = RC5toggle and the result is: TOGGLE = 0x01h
Remote Control Handset MINI no COMPO_4.JPG
Remote Control Handset MINI no COMPO_4.JPG (14.1 KiB) Viewed 26014 times
Then, if the button STBY pressed again the program flow will follow the branch “0x01” of “switch TOGGLE” icon and the RC5 packet toggle bit will be cleared, as well the “RC5toggle” variable:
RC5packet = RC5packet AND 0x37FF where 0x37FFh = 11 0111 1111 1111 and the result is: RC5packet = 11 0100 0000 1100 (0x340Ch)
RC5toggle = 0x00
This is the way in which the Toggle bit holds or changes its value.
Having completed the description of Toggle bit in detail, we can now see the final stage of the complete RC5 packet transmission. From the first post, we should remember that as input of the Data Signal Modulator has been selected the “MDMIN” pin which is assigned to the Port RB.2 of micro. To this, the RC5 packets will be transmitted at the same Port.
The transmission takes place inside a 14 times repeated Loop, a number that corresponds to the 14 bits of RC5 packet. Within the Loop, the first (MSB) bit of RC5 packet is masked, its value is verified and stored into variable “FirstBIT” and then is transmitted:
FirstBIT = RC5packet AND 0x2000 where 0x2000h = 10 0000 0000 0000.
Then through the Decision icon “If FirstBIT = 0x2000?” and according to the value of the first bit of RC5 packet (i.e. MSB = 0 or 1?) the program follows the corresponding branch. For example, the first bit is one of the two Start bits which always are “1” so the variable “FirstBIT” = 0x2000 and the program flow follows the YES branch of Decision icon. Now we have to transmit a Logic “1” bit. We have seen that the RC5 bits are biphasic, so the first half of the bit must be transmitted as “0” while the second half as “1”. That is obvious in the YES branch, where a “0” is immediately transmitted through the Output icon “0-->B2” that Clear the Port RB.2. The “0” transmission should last for the half time of bit (1.776msec / 2 = 888μsec) and this obtained through the Delay icon “888μs”. Then the Port RB.2 is Set through the Output icon “1-->B2” and this state last for the rest time of bit through the next Delay icon “888μs”. Here the transmission of the MSB bit of RC5 packet is completed and now is time for the transmission of the second bit. To this, the bits of RC5 packet are shifted Left by 1 place, so that the second bit will take the place of MSB to be verified if is “1” or “0”. That is obtained through the Calculation icon:
RC5packet = RC5packet << 1
Then the process described above is repeated for 14 times and thus all bits of RC5 packet are transmitted one by one.. When the Loop Count = 14 is completed, the program flow exits from the Loop and the Port RB.2 is Cleared through the Output icon “0-->B2”.
Remote Control Handset MINI no COMPO_3.JPG
(29.88 KiB) Downloaded 10732 times

The Delay icon “100ms” at the end of branch exists to fulfill a rule of RC5 protocol: Successive RC5 codes (or packets) must be repeated in time intervals no less than from (4 X 16 bit-times) or: 4 X (16 X 1.776msec) = 113.664msec. If we subtract the time of the 14 bits of each packet: 113.664msec – (14 X 1.776msec) we led in a distance between the end of a RC5 packet and the start of the next RC5 packet of 88.8msec. That helps a lot the RC5 receiver to synchronize with the start of the RC5 packet received. A delay time of 100msec between successive packets is very safe for a correct communication.
At this point the analysis has been completed. I sincerely hope to be helpful to anyone is interested. It should be noted that the fcf can be run by 100% on Flow Code simulator. For that reason I also have added the red LED that is connected at Port RB.2. It can gives an optical indication of transmitted bits.
Thanks for your attention.
Attachments
Remote Control Handset MINI no COMPO.fcf
(25.79 KiB) Downloaded 1320 times
Best Regards FOTIS ANAGNOSTOU

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

Re: Remote Control Handset "1"

Post by bercioiu »

Hi there!
I want to make a remote control with 10 buttons.
For this, I chose pic16F1828 because that has 10 IOC. All well and good, but I can not manage to alter your code for my needs ... I post my altered version for the 16F1828 and please, when you have time, to correct my code.
Regards, Puiu!
Attachments
TX_1828.fcf
(39.97 KiB) Downloaded 954 times

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: Remote Control Handset "1"

Post by fotios »

bercioiu wrote:Hi there!
I want to make a remote control with 10 buttons.
For this, I chose pic16F1828 because that has 10 IOC. All well and good, but I can not manage to alter your code for my needs ... I post my altered version for the 16F1828 and please, when you have time, to correct my code.
Regards, Puiu!
Hi to you too! :D
Why you don't use the Flow Code RC5 component? It can simplifies things a lot.
Best Regards FOTIS ANAGNOSTOU

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

Re: Remote Control Handset "1"

Post by bercioiu »

Thanks for your reply!
In the mean time, I manage to alter your original flowchart with RC5 component and its working ok!

Genilsonsa
Posts: 150
Joined: Mon Oct 15, 2012 5:19 pm
Has thanked: 12 times
Been thanked: 18 times
Contact:

Re: Remote Control Handset "1"

Post by Genilsonsa »

Hello can anyone explain me how the RC5.Será component to give to implement a remote control decoder project NEC protocol with him.

plstryagain
Posts: 2
Joined: Tue Sep 22, 2015 9:31 am
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: Remote Control Handset "1"

Post by plstryagain »

bercioiu wrote:Thanks for your reply!
In the mean time, I manage to alter your original flowchart with RC5 component and its working ok!
Hi!
I want to make a remote control with 6 buttons and I chose pic16F1828 too but my program doesn't run!
I post my fcf file and please, when you have time, to correct my code.

Regards.
Last edited by plstryagain on Fri Sep 25, 2015 3:55 pm, edited 1 time in total.

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: Remote Control Handset "1"

Post by fotios »

plstryagain wrote:
bercioiu wrote:Thanks for your reply!
In the mean time, I manage to alter your original flowchart with RC5 component and its working ok!
Hi!
I want to make a remote control with 6 buttons and I chose pic16F1828 too but my program doesn't run!
I post my fcf file and please, when you have time, to correct my code.

Regards.
Hi
Try the attached fcf and don't forget to get the modulator output - which must be connected to the base of transistor - from the port RC.4
Attachments
RemoteControl (1).fcf
(29.09 KiB) Downloaded 772 times
Best Regards FOTIS ANAGNOSTOU

plstryagain
Posts: 2
Joined: Tue Sep 22, 2015 9:31 am
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: Remote Control Handset "1"

Post by plstryagain »

fotios wrote: Hi
Try the attached fcf and don't forget to get the modulator output - which must be connected to the base of transistor - from the port RC.4
Thank you very much, Mr fotios!

Regards!
Last edited by plstryagain on Fri Sep 25, 2015 3:54 pm, edited 1 time in total.

Post Reply