Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Why SIRC decoding will not work?

Status
Not open for further replies.
Re: Why this SIRC decoding not working?

Yes. Same problem in real hardware. I am using TSOP1840 but Tx code is for IR burst. The same code works fine with PIC18F45K22. I need it to implement using 877A or 18F452.

99607d1386614930-ir18f.png
 

Re: Why this SIRC decoding not working?

Your oscilloscope simulator channel C seems to be showing that the timing is all wrong.

Wrong crystal fitted? or wrong frequency set in Proteus?

Your MikroC configuration bits look right to me, so I would guess at a Proteus problem. .... but I have no understanding of Proteus.
 
Re: Why this SIRC decoding not working?

Thank you. Yes the proteus clock was wrong but after fixing it still it is showing wrong data both in hardware and Proteus.

99608d1386616772-ir18f2.png
 

Attachments

  • ir18f2.png
    ir18f2.png
    120.7 KB · Views: 109

Re: Why this SIRC decoding not working?

Code:
void sony_print(void){

    signed int temp_ir;

    while(ir_in);                         // wait for IR to go low
Your Proteus oscilloscope shows that IR signal starts with a high, but the code you posted (and my code) tests for a low.

Won't this get a bit confusing?

Is this where the first mistake is?
 
Re: Why this SIRC decoding not working?

Next step is to write some diagnostic code...

1 Call the get_mark() function and see what the size of the start bit is by converting the integer returned into ASCII and displaying on LCD or send to UART.
2 call get_mark() and ignore the return value. call get_space() and see what integer value equates to a 600us space
3 get_mark(), get_space(), get_mark() and show the resulting integer as ASCII to get the mark value of the first data bit
.... and so on....

Then you can diagnose what is being received and check that you receive code is looking for the correct values - plus and minus a good margin for error.

When you are receiving bytes correctly - print out the values of Command and address.

After all of this work, you should be getting the hang of debugging IR protocols.
 
Re: Why this SIRC decoding not working?

It's working now with 18F452 but still not working with 16F877A and 16F88. My client needs only 877A or 16F88 for receiver. They don't have PLL and I can't have 32 MHz on those chips.
 

Re: Why this SIRC decoding not working?

My client needs only 877A or 16F88 for receiver.
You are selling this code?

Oh dear, I don't think that my amateur code is fit for a commercial product.

A professional would not code this way.
 
Re: Why this SIRC decoding not working?

@HexRreader

Please help me with this SIRC code. I did as you mentioned. I printed the Timer values on UART and I am getting these values. How to use them? I am using 8 MHz Fosc. I am attaching the project files.

The value displayed is very high and I think it is not correct. I am having trouble choosing the range of values.

99886d1387159213-ir-test.png
 

Attachments

  • SIRC PIC16F877A PIC16F877A.rar
    233.6 KB · Views: 72
  • ir test.png
    ir test.png
    159.4 KB · Views: 95

Re: Why this SIRC decoding not working?

Code:
// get IR mark time (low)
int get_mark(void){
        TMR1L = 0;
        TMR1H = 0;
        while(!ir_in);                       // wait for IR to go high
        retint = TMR1L;
        retint += (TMR1H<<8);
        IntToStr(retint, myStr);
        UART1_Write_Text(myStr);
        UART1_Write(13);
        UART1_Write(10);
        return retint;
}
You cannot write to UART while you are reading a mark signal.

Writing to UART is very slow. Many, many IR bits will be sent by the transmitter (but ignored by your code) while you are sending to UART.

Store timing values very quickly in variables, and do not try to print them out until you have finished receiving as many IR bits as you want to measure.


See post 46 above.
 
Last edited:
Re: Why this SIRC decoding not working?

I did as you mentioned but still getting wrong values.

Edit: Sorry, I posted the wrong file. Here is the rev2 file.
 

Attachments

  • SIRC PIC16F877A PIC16F877A rev2.rar
    233.9 KB · Views: 67
Last edited:

Re: Why this SIRC decoding not working?

Had a quick look, but cannot work out what is happening.

Might try again tomorrow.....
 
Re: Why this SIRC decoding not working?

Fixed one more mistake. The int I am using was declared as unsigned instead of unsigned int but still getting all 0's for marks. Latest file attached.
 

Attachments

  • SIRC PIC16F877A PIC16F877A rev4.rar
    234.4 KB · Views: 69
Last edited:

Re: Why this SIRC decoding not working?

I have attached a simple test program to get integer values for mark length and space length.

This might help you to start understanding what is being received by your real hardware IR receiver.

It will be of no use for your Proteus simulation, since the signals are the inverse of real signals, and Proteus timing is perfect, whilst real signals are not.
 

Attachments

  • Rx.rar
    166.2 KB · Views: 78
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top