Sony Infared Code in C18

Status
Not open for further replies.
Hey guys im having a RELAY issue or at least i think it is a relay issue...

For some reason the light stays on even if its supposed to be off.

This is the relay im using:


This is my Ballast info:



The relay is supposed to be 1A which should be fine since ballast calls .8amps aka 800mA...

is that too close? should i just use a higher relay? or do you think its the transistor switching it? ima use a multimeter now to test that.
 

Attachments

  • ballast.png
    242.5 KB · Views: 608
  • relay.png
    241.6 KB · Views: 627
Assuming it's a conventional ballast?, it's a highly inductive load, that relay probably isn't up to it?.
 
so a 3A+ relay should be perfect right? I need to order one so i want to make sure i get it right
 
im using the below relay for now. Its 125v @ 1A. At least its holding well for now. Until i can order new relays.

 

Attachments

  • relay2.png
    133.2 KB · Views: 421
Last edited:
so a 3A+ relay should be perfect right? I need to order one so i want to make sure i get it right

I don't know, but it stands more of a chance - you've probably seen light switches arc inside when you turn a flouescent light off? - that's due to the inductance of the choke.

Just like why you have to have a protection diode with a relay driver (I'm presuming you have that?), it's the back-EMF from the inductance.
 
yeah on page 3 you can see the scematic

I learned all about the protection diode from everyone here

Thanks for the tip
 
hey Nigel i know you should be able to answer this...
Code:
The protocol uses bi-phase modulation (or so-called Manchester coding) of a 
36kHz IR carrier frequency. All bits are of equal length of 1.778ms in this protocol,
with half of the bit time filled with a burst of the 36kHz carrier and the other half being 
idle. A logical zero is represented by a burst in the first half of the bit time. 
A logical one is represented by a burst in the second half of the bit time. 
The pulse/pause ratio of the 36kHz carrier frequency is 1/3 or 1/4 which reduces
power consumption.

    * Carrier frequency of 36kHz
    * Constant bit time of 1.778ms (64 cycles of 36 kHz)
    * The recommended carrier duty-cycle is 1/4 or 1/3.
...When it says frequency of 36 kHz should i divide 1/36000... =0.000 027 777 777 8

which is essentially 0.00002777 Seconds aka 27.77uS (microseconds). So if i use 1/3
as the duty cycle im supposed do it like: 27.77 / 3 = 9.256uS is the 1/3 now 2/3 of it is 9.256 *2= 18.513uS.

So i should turn on the IR Led for 9.256uS then off for 18.513us .

Knowing this:
Code:
 All bits are of equal length of 1.778ms in this protocol, with half of the bit time filled with 
a burst of the 36kHz carrier and the other half being idle.

i should pulse at that rate for 1.778ms / 2 = 889uS. If thats the case i should divide 889uS / 27.77uS = ~32 which means i should send out:
Code:
32x loop:
9.256uS = pin high
18.513uS = pin low
32x loop
27.77uS = pin low

to produce a logic 0?

SB-Projects: IR remote control: Philips RC-5

I know this isnt sony but its IR and wanted to test my theory of thinking
 
Last edited:
3 amp would work fine When your light first comes on it will pull 1.5 amps till it lights the bulbs. there always a inrush of current with fluorescent light bulbs till they fire
 
ok cool Thanks! heh anyone know a good source to learn things like this from? Whether it be E-Book or Website
 
I realize that this thread has been dormant for over a month but...

I was playing with Jason's code and discovered that no matter what button I pressed to be learned afterwards only the "1" button would activate the LED that I substituted for his relay on pin 3 (GPIO4). After reading through the code a couple of times I found his mistake. In this section of code:


Code:
MainApp:
    MainAdd = ReadEE(0x00);
    MainCmd = ReadEE(0x01);

    while(1){
        GetSIRC(&MyAdd,&MyCmd);

        if(MyAdd == 0x01)
            if(MyCmd == 0x00){
                if(IsSet == 0){
                    RelayPin = 1;
                    IsSet = 1;
                } else {
                    RelayPin = 0;
                    IsSet = 0;
                }
            }

        delay_ms(250);
        delay_ms(250);
  }


this:

Code:
 if(MyCmd == 0x00)


should be replaced with this:


Code:
if(MyCmd == MainCmd)

This post is not meant to degrade Jason or his work. He did a good job in commenting the code and in creating it to begin with. I was looking at it to integrate with other code for dimming lights and controlling AC motor speed. Now I just need to modify what he has done to allow multiple buttons to be learned and get that integration thing done.

Mike
 
heh thanks i forgot to edit that. As you can see from my usetube videos i do have it working and still use it for my lights

Multiple codes arent too hard. A LCD would help or some LEDs to show what code is being programmed.
 
Hi again AtomSoft

lovely work!!. Is it possible to somehow make the transmitter and receiver for your code on Proteus?

I wanted to use your code but add a few more buttons in the transmitter.

Please kindly help.
 
I have tried your code on 18F1320.

It works perfect on 8MHz clock. However when i change the clock to 4MHz, it doesnt quite work.

I thought it would be easy to convert it from 8 -> 4 MHz just by reducing all the delays to half but that also doesnt work. Can you please guide a little on how to use your code on other clock speeds?

Yes i am using external clock.
 
Thank you for replying Atom

I have been stuck with it for quite some time.
I have attached the complete folder i am working in. It contains the Simulation aswell

I am trying to send like several commands from the transmitter to the receiver using IR link to modulate and demodulate.

However only two commands are recognized.

Transmitter:

Receiver:
 

Attachments

  • Project_IR.zip
    481.1 KB · Views: 136
Last edited:
No i am not trying to learn commands. Just trying to make the transmitter for more channels. Like 16 channel for example.

the receiver should be able to distinguish among each channel (like in normal IR TV control)
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…