- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
For my end project for school I need a IR decoder capable of decoding the NEC protocal. I know this uses pulse distance.
I know that I could use some library found online but my teacher asked to make it with the components available in psoc creator.
Could somebody help me please I have some idea that I need to do something with a Timer/PWM but I don't know how to start with it.
Thanks in advance.
Best regards
Jayson
EDIT: I use the CY8CKIT-042
Solved! Go to Solution.
- Labels:
-
ispn:39611:1:0
-
l1:314:1:0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @jago_4849746 , I have attached a project where I have tried to decode the NEC protocol based on your timing diagrams and other inputs. Please test this and let me know if this works for you.
The are two projects in the workspace: One projects receives the NEC commands and other project sends the NEC commands (I have simply bit banged based on protocol)
In the receiving project, there is a master timer that acts as a timestamp and is used to find the time period of different pulses(falling edges). The NEC_IN GPIO pin is configured as an resistive pull up input pin and triggers an interrupt on the falling edge. The timer is used to find the pulse width between the two falling edges to decode the incoming bits. There is a software based state machine implemented that decodes the protocol based on the pulse width.
Attached screenshots of the tera term output and the waveform of the transmitted command.
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @jago_4849746 ,
Can you give us more information on the requirement? Could you please share the sensor you are using/ datasheet/ block diagram of your requirement to help you better.
To get started with the digital peripherals in PSoC 4, we recommend you to watch the PSoC 101 videos
https://www.cypress.com/training/psoc-101-video-tutorial-series-how-use-arm-cortex-m0-based-psoc-4
Also please checkout the app note:
https://www.cypress.com/documentation/application-notes/an79953-getting-started-psoc-4
You can find code examples in pSoC Creator as well. File > Code Examples. Filter by Device family to get relevant examples.
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @BragadeeshV ,
To explain my project:
I need to adjust fan speed (using fancontroller component)How to do it?
Automaticlly or manually
Automaticly:
I use a DHT11 to meassure the temperature/humidity which will change the speed depending how hot it is.
Manually:
1. With the IR remote I want to increase or decrease the speed of the fan with 2 buttons
2. With the IR remote I want to change the mode from automatic to manual or vice versa with 1 button.
3. With the IR remote I want to stop or start the Fan with 1 button.
I have no issues with the fancontroller component or the automatic part.
The IR receiver I use is the HX1838 IR and I use a CAR MP3 REMOTE to control it.
I Found a sheet about which hexcode gets send out when a certain button is pressed.
My only problem is when the remote sends the encoded hexocde out to then decode it with psoc components again.
Thanks in advance!
Best regards,
Jayson
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @jago_4849746 ,
Thanks for the update. Can you please share the datasheet of the device that has relevant information regarding the encoded hex code. Also please provide timing diagrams for the same.
For further reading, please checkout our app note - PSoC® 4 – Intelligent Fan Controller
https://www.cypress.com/documentation/application-notes/an89346-psoc-4-intelligent-fan-controller
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @BragadeeshV,
Info/Datesheet remote: https://gist.github.com/steakknife/e419241095f1272ee60f5174f7759867
Timing diagrams NEC protocol: https://techdocs.altium.com/display/FPGA/NEC+Infrared+Transmission+Protocol
Datesheet IR receiver: https://datasheetspdf.com/mobile-datasheet/HX1838.html
Thanks again!
Best regards,
Jayson
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @jago_4849746 ,
You can use a timer block configured in capture mode to find the pulse width between rising and falling edges. Based on this information, you can find out if it is a 1 or a 0. Then, you can decode the message accordingly. For example, if the received pulse width is 9 ms, then you can know it is start of Frame and you can set up your firmware to receive the incoming address and data bits.
I've attached a sample project that measures the pulse width (between rising and falling edge).
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @BragadeeshV ,
I've tried your code.It works but only some things confuse me a bit. So when I press the once button on the remote which sends the following hexcode out:
FFA857
I receive this back in my console:
Start Counting...
Stop Counting.
TIME STAMP: 3097 us
Start Counting...
Stop Counting.
TIME STAMP: 380 us
Start Counting...
Stop Counting.
TIME STAMP: 542 us
Start Counting...
Stop Counting.
TIME STAMP: 919 us
Start Counting...
Stop Counting.
TIME STAMP: 531 us
Start Counting...
Stop Counting.
TIME STAMP: 530 us
Start Counting...
Stop Counting.
TIME STAMP: 530 us
Start Counting...
Stop Counting.
TIME STAMP: 529 us
Start Counting...
Stop Counting.
TIME STAMP: 375 us
Start Counting...
Stop Counting.
TIME STAMP: 550 us
Start Counting...
Stop Counting.
TIME STAMP: 520 us
Start Counting...
Stop Counting.
TIME STAMP: 388 us
Start Counting...
Stop Counting.
TIME STAMP: 522 us
The problem I have with this is that it seems as if not all data went through? I could be wrong.
Could you lighten me up?
Thanks in advance!
Best regards,
Jayson
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @jago_4849746 , the best way to find out the issue is to probe the line and check the waveform.
The other issue is we are measuring only the pulse width between the rising and falling edges but the true information lies in the distance between the falling and rising edges as well. For this, I suggest an alternate approach. You can run a free running timer with a step count value of say, 100 uS. Now, assign a GPIO pin that can trigger an interrupt event on the falling edge (or rising edge, please check the polarity). If the period between the falling edges (or rising edge) is around 1ms it is 0, if it is around 2 ms then it is a 1. If it is 13.5 ms then it is SoF.
I was able to find several reference codes for this approach.
https://exploreembedded.com/wiki/NEC_IR_Remote_Control_Interface_with_8051
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @jago_4849746 , I have attached a project where I have tried to decode the NEC protocol based on your timing diagrams and other inputs. Please test this and let me know if this works for you.
The are two projects in the workspace: One projects receives the NEC commands and other project sends the NEC commands (I have simply bit banged based on protocol)
In the receiving project, there is a master timer that acts as a timestamp and is used to find the time period of different pulses(falling edges). The NEC_IN GPIO pin is configured as an resistive pull up input pin and triggers an interrupt on the falling edge. The timer is used to find the pulse width between the two falling edges to decode the incoming bits. There is a software based state machine implemented that decodes the protocol based on the pulse width.
Attached screenshots of the tera term output and the waveform of the transmitted command.
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @BragadeeshV ,
This works perfectly!
I manualy checked if the binarycode checks out with the hexcode I sent with the remote. And yes it checks out 🙂
I think i'm able to do the rest of what my project requires. If not i'll mention you.
Many thanks for the help!!!!
Best regards,
Jayson