| Author
|
Martin Whitlock
|
| Version
|
1.1
|
| Category
|
Wireless
|
NEC IR TX/RX 38KHz component
Sends and receives standard 8-bit-address NEC infrared remote control frames (38kHz carrier). RX is IOC interrupt-driven the project must configure its own both edge interrupt on RxPin calling ProcessEdge().
Detailed description
No detailed description exists yet for this component
Examples
No additional examples
Macro reference
ClearDataDetected
|
ClearDataDetected
|
| Resets DataDetected to false so the next new frame or repeat can be detected again.
|
- VOID
|
Return
|
Initialise
|
Initialise
|
| Sets up PWM, RX pin and held-detection timer. Call once at startup.
|
- VOID
|
Return
|
IsDataDetected
|
IsDataDetected
|
| On-demand: has a new frame or repeat been decoded since the last ClearDataDetected() call?
|
- BOOL
|
Return
|
IsHeld
|
IsHeld
|
| On-demand: is the last decoded button still considered held?
|
- BOOL
|
Return
|
IsRepeat
|
IsRepeat
|
| On-demand: was the last decoded frame a repeat code rather than a fresh frame?
|
- BOOL
|
Return
|
ProcessEdge
|
ProcessEdge
|
| Call on every RxPin edge (both edges). Returns the last decoded value per Mode: 1=Address, 2=Command, 3=both.
|
- BYTE
|
Mode
|
| Which decoded value(s) to return: 1=Address only, 2=Command only, 3=both packed as (Address*256)+Command.
|
- ULONG
|
Return
|
TransmitNEC
|
TransmitNEC
|
| Sends one standard NEC frame: 8-bit address, 8-bit inverted address, 8-bit command, 8-bit inverted command.
|
- BYTE
|
TxAddress
|
|
|
- BYTE
|
TxCommand
|
|
|
- VOID
|
Return
|
Property reference
|
Properties
|
|
PWM Connections
|
|
Channel
|
| Selects which PWM channel the component is connected to.
|
|
Alternative pin
|
| Allows an alternate pin to be used if available. Note that on some devices you will also have to change this setting in the device configuration.
|
|
PWM Pin
|
| Specifies the pin assigned to the PWM channel selected
|
|
Remap Pin
|
| Allows the PWM hardware pin to be reassigned to another pin
|
|
PWM Frequency
|
|
PWM Timer
|
| Timer associated with PWM to drive the output. Warning - All PWM channels linked to the same timer will share the same period and prescaler settings. Do not select Timer 4 - it is used internally by this component for held-button/repeat detection and picking it here will cause a compile error.
|
|
Period Overflow
|
| Allows the user to change the number of counts for the whole PWM period. Note that all PWM channels based on the same timer will share the same period overflow. PIC/AVR Range: 0 - 255 16-bit PIC Range: 0 - 65535
|
|
Prescaler
|
| Allows the user to change the number of program cycles per PWM cycle count. Note that all PWM channels based on the same timer will share the same prescaler.
|
|
Period (us)
|
| Displays the length of time to complete one PWM cycle.
|
|
Frequency (Hz)
|
|
|
|
Frequency (KHz)
|
| Displays the frequency of PWM cycles per second.
|
|
Transmit Options
|
|
Invert Output (PNP driver)
|
| Enable if the IR LED is driven through an inverting stage (e.g. a PNP transistor).
|
|
Calculations
|
|
Required Frequency (Hz)
|
| Type in your required frequency in Hz and the component will automatically calculate the best prescaler and period to acheive the frequency with the maximum possible resolution.
|
|
Calculated Frequency (Hz)
|
| The frequency we have ended up acheiving using the calculated period and prescaler
|
|
Calculated Period
|
| The suggested period setting to use to acheive the calculated frequency.
|
|
Calculated Prescaler
|
| The suggested prescaler setting to use to acheive the calculated frequency.
|
|
Apply To Defaults
|
| Applies the calculated period and prescaler settings to the PWM component default settings.
|
|
RX Timer
|
|
Timer
|
| Timer Peripheral to use to monitor the passage of time.
|
|
Bit Depth
|
| Number of bits in the timer peripheral. 8-bit timers can count from 0-255 before overflowing. 16-bit timers can count from 0 to 65535 before overflowing.
|
|
Prescaler
|
| Scaler applied to the timer, Small scalers allow for finer resolution but will limit the max time and also put more load on the microcontroller. Recommended to use as large a setting as possible which still provides enough accuracy.
|
|
RX Pin
|
| Digital input pin connected to the IR receiver module output (active-low: idle=1, mark=0). The embedding project must configure its own both-edge IOC interrupt on this pin calling ProcessEdge().
|
|
Held Threshold (ms)
|
| How long with no repeat before IsHeld() reports released.
|
|
Estimated Best Period (us)
|
| Read-only: the real tick period these Timer/Prescaler/Bit Depth settings achieve. Copy this (rounded) into Tick Period (us).
|
|
Tick Period (us)
|
| Read-only: auto-set from Estimated Best Period whenever RX Timer settings change.
|
|
Diagnostics Enabled
|
| Flags LastRxState/Working* as diagnostic values to read (e.g. over UART) when debugging.
|
Component Source Code
Please click here to download the component source project: FC_Comp_Source_NEC_IR.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_NEC_IR.fcfx