Q: IR Receiver using PSoC4

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I see in the Newark's collection of 100 projects for the PSoC4, a project that allows the transmission of RC-5 IR Codes.

   

This is close to what I want to do, only in reverse. I want to set up the PSoC to receive IR codes from a remote. (Actually, I am interested in the Sony IR codes, but feel that the RC-5 is close, and can be modified to the Sony format.)

   

How difficult is it to do this? I have already searched the archives, and all I come up with is using Designer. I want to do this using Creator.

   

 

   

Thanks,

   

 

   

James

0 Likes
33 Replies
ETRO_SSN583
Level 9
Level 9
100 sign-ins 5 likes given 1000 replies posted

Maybe someone else knows of a design, but this might be of interest -

   

 

   

    

   

          http://www.cypress.com/?app=forum&id=2232&rID=47392

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 Thanks Dana,

   

 

   

Yes, I saw this post - it was almost three years ago, and no follow-up on what he wound up doing.

   

 

   

I suppose I could bit-bang it like he did - I was just hoping that there was an easier way.

0 Likes
Anonymous
Not applicable

 Hi,

   

You can easily build a RC5 decoder using the digital resouces in PSoC 4.

   

Thanks,

   

Rahul

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Since RC-5 is a manchester-encoded protocol, you can look at this PSoC Insider blog entry about manchester encoding / decoding. There is also a more detailed http://www.cypress.com/?app=forum&id=2232&rID=54414www.cypress.com/ in the forum.

0 Likes

Hi @HeLi_263931  the link you have given is not working. Can you give me another thread?

 

Thanks,

 

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Thanks Hli. I followed the links, read the articles, downloaded the code, and opened it.

   

 

   

Looking at the code, I pulled the Decoder section out of it and put it into my program. I hooked the IR receiver in to the input of the NOR gate. 

   

 

   

I am able to detect the IR - and am able to switch the output based upon the IR detection, but I am not able to actually decode the pulse train. All I am getting right now looks like a clock of 10101010. (AA is displayed on the LCD.)

   

 

   

So. Any ideas?

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Can you attach a logic analyzer and show what the IR input, the clock and the data output look like?

   

The PWM needs to be configured to a period about 3/4th of a bit period, and this one is 1.778 ms in RC-5. So the PWM should have a pulse width of about 1.33 ms.

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Oh, and RC-5 sends 14 bit words with each transmit: http://en.wikipedia.org/wiki/RC-5#System_and_Command_Codes

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 Hli,

   


Thanks for your response.

   


RE: Can you attach a logic analyzer and show what the IR input, the clock and the data output look like?

   
    Actually, no. I do not have a logic analyzer to use with this. I was hoping to escape having to invest in one for this - especially since I didn't need one when writing something similar for the BASIC Stamp.   
   
        
   
        
   
    I might be able to put an oscilloscope on some of the pins to verify that I am getting a signal, but that's about it.   
   
        
   
        
   
    RE: Oh, and RC-5 sends 14 bit words with each transmit -   
   
        
   
    True, but I am decoding SONY IR - which is 12-bits. I have attached a PDF that describes the SONY format.   
   
        
   
        
   
    Thanks again.   
   
        
0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

From the result you printed (0xAA) I figured you are reading only 8 bits...

   

For the Sony protocol, you need different timing (900µs on the PWM), also, did you read the note about possibly needing to invert the input, depending on the sensor?

   

It also seems sensible to add another timer to detect the start condition (single continuous pulse for 2.4 ms) and then start receiving.

   

I have a Sony remote here, but it would take a while to set up the receiver 😞

   

Maybe you can upload your project here (file / create workspace bundle) so we can have a look?

0 Likes
ETRO_SSN583
Level 9
Level 9
100 sign-ins 5 likes given 1000 replies posted

There is a low cost board being used with Freeware for logic analyzer -

   

 

   

EZ-USB FX2LP   

   

www.ebay.com/itm/CY7C68013A-56-EZ-USB-FX2LP-USB2-0-Develope-Board-Module-Logic-Analyzer-EEPROM-/2009...

   

forum.arduino.cc/index.php

   

 

   

@Bob, you also know of something low cost as well ?

   

 

   

Regards, Dana.

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

You cannot really go cheaper than these ebay clones. One can use a BusPirate, but it will cost as much (and goes only to 1 MHz). The simplest logic analyzer to build by yourself is probably the LogicBoost, going up to 20 MHz, but its based on a MSP430 😞

   

Or if you can get your hands on a -050 (or possible y -030) board, you can use my analog-digital Scope as analyzer. But it goes, unmodified, also only up to 1 MHz...

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 Okay. I have zipped up the code for the IR portion of this project and am uploading it.

   

 

   

I am basically using the Manchester Decode portion of the code (taken from code provided in the links above), but it appears that I am missing a crucial part to get it to work correctly with the Sony protocol.

   

 

   

Thanks!

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Dana asked for cheap logic analyzers, no ad

   

ikalogicstore.com/

   

 

   

Bob

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

OK, I looked at the circuit, and the Sony IR protocol again.

   

To recap:

   
        
  • a bit starts with a rising flank (asuming that your receiver is active high - you should check that)
  •     
  • with that flank, you start a timer of 900µs
  •     
  • after that 900µs, you look at the input value, and take it as output (with the DFF)
  •    
   

So this is not really a manchester protocol (which would have different flank direction depending on the input value). I think you can remove the DFF, and replace the ShitfReg with a SPI slave. The SPI slave can the use the PWM output signal as clock, and directly read the input signal after the 900µs.

   

Maybe increase the period of the PWM to about 100, and use a compare value which creates a proper flank at the end of the period (starting at 900µs). I think using the input signal as input clock will read the input value just at the wrong piojnt in time.

0 Likes
Anonymous
Not applicable
        Hli, This sounds great! I am a bit confused though - you mention removing the DFF, then you mention using it. Could you post a JPG of the hookup that you are describing? That would help a lot! Thanks! James   
0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Sorry to have confused you. I should have taken the DFF out of the recap of how it works. If you still need it, I can try to come up with something this evening...

0 Likes
Anonymous
Not applicable
        Yes, if you could put something together, it would help. I have tried to hook up what your words say, but it makes little sense, and there are compiler errors with unused inputs on the SPIS that I do not know how to resolve. Thanks!   
0 Likes
lock attach
Attachments are accessible only for community members.
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

So, here you go. I used a timer for detecting the start bit condition, a PWM for the bit timing and a SPI slave for collecting the bits into a 12bit-word.

   

I did not test it, I juts did throw everything together and (hopefully) configured everything properly (but its getting late now, so there will be some errors in it).

   

There are some timing warnings, so clearly some sync components are needed. I also did not change the code, since I cannot test it anyway...

   

I added comments about the different signals, so you hopefully you know how it should work. If not, ask...

0 Likes
Anonymous
Not applicable
        Thanks Hli. This looks promising. I will see if I can get this to work. I have also ordered a logic analyzer (TSAL0001) and hopefully will be able to use this to assist me in getting this to work. Thanks again!!!   
0 Likes
Anonymous
Not applicable
        Well, I am not having much success (none, actually) getting the method described by Hli to work. I am still trying, but using my new logic analyzer, I am not seeing any pulses getting through any of the 'circuitry'. Frustrating.   
0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored
        
  1. Did you look at the signals coming from the IR receiver?
  2.     
  3. Do they match with whats described in the manual you posted? Is the timing OK? The signals aren't inverted?
  4.     
  5. What signals did you route to GPIOs to look at them? How did you trigger the LA?
  6.     
  7. Did you change the code to start all components?
  8.     
  9. Can you see at least the 'start' trigger do something?
  10.    
0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable
        1. Yes, I did. 2. Yes, Yes & Yes. 3. Pretty much anything. Triggered from the IR channel. 4. Yes. 5. No. Hence the frustration.   
0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable
        The schematic. I have monitored many of the outputs with no signals on any of the monitored points.   
0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Actually, the input signal _is_ inverted. Your description, and my schematic, assumes that the the signal are active high (e.g. the start bit is high to 2400µs). But the LA trace shows the signals are active low. So it might be enough to add an inverter between the IO pin and the net handling the signal.

0 Likes
Anonymous
Not applicable
        I've already added an inverter on the IR signal. It makes no difference. I get no pulse out of the Timer - or anywhere else. (See my posted IR_Schematic.jpg above)   
0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Its difficult to debug without the appropriate hardware 😞

   

What you might try:

   
        
  • route the input signal back to a pin (maybe after adding the inverter in the PSoC), in case the signal gets somehow mangled by the PSoC
  •     
  • reduce the counter period for the start timer - this is the first component which needs to work
  •     
  • re-read the counter datasheet - maybe I missed something and my idea / configuration will not work as intended
  •    
0 Likes
Anonymous
Not applicable
        Part of my problem may be that I never got a decent program. All I got was a partial schematic, and a 'try this'. I also think that one of the weaknesses of the PSoC (any version) is that there are not enough good examples, and documentation describing the components. The 'datasheets' are very brief, and do not provide enough detail on how to use the components.   
0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Jim, I do not know which version of Creator you use, but for nearly every usermodule you can get a working example when you search for (right click "Find Example Project"). The main difficulty there is (as it is the case for me) is to understand the datasheets because they are english (and this is not my native language). But I must admit that when I studied them intense enough (and tried some examples) I could get them to work. The concept of PSoCs was new for me, having digital and analog hardware that I could place, connect and program to my needs. Since I was used to work with schematic editors and C-language was not uncommon to me, I could successfully deliver project-solutions to my customers.

   

So when you have any specific questions regarding one of the components we surely will be able to help you.

   

 

   

Bob

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

When you have no (functioning) example program, you can rely only on the available documentation. Also, when working with PSoC, you should try not to "think in software". You will get most out if it when you start thinking about how to solve the problem in hardware. Thats how I came up with my solution (even though it doesn't seem to work correctly 😞

   

OTOH, you can try to implement a pure software solution - e.g. port some existing code over.

0 Likes
Anonymous
Not applicable

 Hli,

   

 

   

Thanks for your help. I _am_ thinking in 'hardware', and that is part of my problem. I am thinking in terms of 555 Timers with capacitor & resistor settable delays. Those are not available in the PSoc. 

   

 

   

I was able to make a small amount of progress over the last week, by thinking about this 'sideways'. I am using a Glitch Filter to trigger on pulses greater than 900 to 1000uS. This outputs a pulse - or a '1', for the ones. I am also clocking all of the 13 pulses (including the Start pulse which is 2400uS), and passing them into a pair of Shift Registers. The first one is set for 5 bits, and the second one is set for 8 bits.

   

 

   

I am not sure if this is the correct approach. I am still working on decoding the string of bits. One negative that I am having to deal with is that this solution seems to also trigger on other IR remotes (not just the Sony SIRC codes), which means that I will get false triggers that I need to deal with.

   

 

   

One other thing that I am noticing, and it may be why no one else has taken the Creator approach, is that I am grinding through PSoC resources like crazy, which leaves me with very little left over to use for other features inside the PSoC4.

   

 

   

Regards,

   

 

   

James

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Think of the timer component as a digitally configurable 555, then you are quite close 🙂 Everything else (like DFFs and gates) should then be known to you. Evene the PWM, as its used here, is more like a 555...

   

So if you find a way of decoding the  IR code with 555 timers and digital logic, you can translate this easily into a PSoC.

   

The approach you outlined might work, but I doubt you gett the start bit decoded correctly. Especially detecting other IR protocols (IIRC they use shorter start bits) might get difficult. Speaking of that: yes, other remotes might work, this is the expected result. Their protocols are just similar enough. You will need to check the address bits to filter out anything you don't want to accept (as any other remote control receiver does).

   

Regarding the resources: PSoC4 is one of the smallest PSoCs, especially in terms of UDBs. There are only 4 of them available, so its best to use fixed-function block whenever possible. Each of your shift registers will need one UDB. Using a SPI slave might be better, because it needs no UDBs.

0 Likes
Anonymous
Not applicable

hello all dear guys, i need help to build ir reciver tsop(remote controlled device) using Psoc Creator 4.

   

but i don't know how to do in psoc.please please help me 

   

 

   

thanks

0 Likes