- About
- About IR
- Modules
- Interface Description
- Simulation
- Test
- Status Information
- Issues
- Licence
This repository contains modules related to infrared (IR) emitters and receivers, such as remote controls. All modules in this repository requires external IR devices. These modules are communicated via single pin which kept high when not used. (Pull-up)
IR or Consumer IR (CIR) is a widely used Optical wireless communication (OWC) method. IR transmisson employ Infrared light to transmit data. They require line of sight to operate. They usually use 38 kHz as carrier frequency. Data is usually modulated with Amplitude-shift keying (ASK). Source: Wikipedia
Implemented modules decode/encode 0
as a short low (~600µs, no max.) followed by a short high (~600µs, max. 990µs), and 1
as a short low (~600µs, no max.) followed by a long high (~1.6ms, between 1-1.99ms). Any high period longer than 2ms ends transmisson. Transmission begins when an arbitrary low followed by an arbitrary high received. Transmitting no data or data smaller then 8 bits interpreted as repeat press.
General Description:
Module ir_decoder
decodes the received IR signal. Width of the decoded code controlled by parameter CODEBITS
. If received code is longer than CODEBITS
, only least significant bits are kept. Module requires two clock. Clock clk_100kHz
must be around 100kHz, in testing 97.656KHz is used. System clock, clk
, can be any multiple of clk_100kHz
.
Working Principle:
After a reset ir_decoder
checks for the start condition, which is an arbitrary low followed by an arbitrary high. After receiving start condition, ir_decoder
starts to decode. Decoded bit value determined by counting the duration of the rx
high pulses and stored at the negative edge of rx
. Durations less than 990µs interpreted as 0
, durations between 1ms to 1.99ms interpreted as 1
. If the duration is longer then 2ms end condition is generated and no data is decoded. Exact durations depends on the period of clk_100kHz
, given values assume period of 10µs. If length of the received data is shorter than 8 bits or no data is received, repeat press signal, repeat_press
, is generated and code
is not updated. When a new code is decoded, newCode
pulse with a length of a one clk
is generated.
General Description:
RGBremoteController
can be used to control a RGB LED with a remote controller. Implemented remote has following buttons:
- 2 Brightness button
- On button, Off button
- Red, Green, Blue and White buttons
- 4x3 custom color buttons
- 3 diffrent mode buttons (Flash, Strobe and Smooth)
- Mode switching button
RGBremoteController
requires ir_decoder
module to operate and includes following submodules:
Submodule | Purpose |
---|---|
RGBremoteMapper |
Decodes button number from code |
rgb_led_controller8 |
PWM RGB pins to control color |
brightnessControllerRGB |
Modulate PWMed RGB pins to adjust brightness |
pulseGen |
Generate pulses to change color in Flash and Strobe mode (~3,3Hz) |
Smooth mode is not implemented. Repeated presses are not recognized. Colors can be edited with local parameters; WHITE
, REDx
, GREENx
and BLUEx
.
RGBremoteMapper
module:
RGBremoteMapper
maps code
s to button numbers. Mapping can be changed with local parameters btn_y_x
, where x
and y
are coordinates with btn_0_0
is the top left button. Unknown code
s mapped as button number 31
.
Port | Type | Width | Description |
---|---|---|---|
clk |
I | 1 | System Clock |
clk_100kHz |
I | 1 | 100kHz Clock, used in decoding |
rst |
I | 1 | System Reset |
rx |
I | 1 | Receiver Pin |
code |
O | CODEBITS |
Decoded code |
repeat_press |
O | 1 | Indicates repeat press received |
newCode |
O | 1 | Indicates a new code decoded |
I: Input O: Output
- System Clock,
clk
, frequency can be any multiple ofclk_100kHz
. 100 MHz is used it testing. - If received code is shorter than
CODEBITS
, MSBs will be0
. - If received code is longer than
CODEBITS
, LSBs are kept. clk_100kHz
should be approximately 100kHz, some variation does not affect functionality. During simulation and testing 97.656kHz clock is used.
Port | Type | Width | Description |
---|---|---|---|
clk |
I | 1 | System Clock |
rst |
I | 1 | System Reset |
code |
I | 32 | Decoded code |
newCode |
I | 1 | Indicates a new code decoded |
red_o |
O | 1 | Red LED pin |
green_o |
O | 1 | Green LED pin |
blue_o |
O | 1 | Blue LED pin |
an |
I | 1 | LEDs are connected in anode mode |
I: Input O: Output
RGBremoteMapper
:
Port | Type | Width | Description |
---|---|---|---|
code |
I | 32 | Decoded code |
valid |
O | 1 | Indicates the code is valid |
button |
O | 5 | Button Number, 31 if unvalid |
I: Input O: Output
Module ir_decoder
simulated with sim_ir_dec.v. Module simulated with default CODEBITS
value, 32 bits. One 16bit code (0x0FAA) is send via rx
. Clock signal clk_100kHz
is generated with onboard module clkGen97k656hz
.
Module ir_decoder
tested with ir_decoder_test.v and Basys3_0.xdc. Module tested with default CODEBITS
value, 32 bits. Receiver Pin connected to JB10 port. Decoded code send via UART and shown on seven segment display (SSD). Left most switch, SW15, used to choose which portion of the code
is shown. When SW15 is high MSBs, when low LSBs are shown. Dots on the SSD indicates repeat press. UART transmit connected to JB2 port and USB-RS232 transmit port. Baudrate set to 460.8k. 8 bit data, no parity and 1 bit stop is used. These values are hardcoded in ir_decoder_test.v and can be changed from there. (For more information check UART repository) When a new code decoded, it is transmitted automatically via UART in four transmissons, MSB first.
Module irdec_test
can also be used as IR remote decoder to extract 32 bit codes from IR remotes, and see them.
Module RGBremoteController
tested with rgbRemoteTest.v and Arty-A7-100_0.xdc. LD0 controlled with the remote. All of the buttons are tested.
Last Simulation:
ir_decoder
: 18 January 2021, with Vivado Simulator
Last Test:
ir_decoder
: 18 January 2021, on Digilent Basys 3RGBremoteController
: 20 January 2021, on Digilent Arty A7
ir_decoder
:
- Rarely module stucks and needs reset to work again, happens when buttons pressed rapidly.
CERN Open Hardware Licence Version 2 - Weakly Reciprocal