IRcontroller parameters

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
perjar
Posts: 57
Joined: 08 Apr 2018 18:02

IRcontroller parameters

Post by perjar »

Hi,

Wondering if anyone could please explain some of the concepts implemented by IRcontroller.

What does the following parameters do:
IR_MS_PRESCALLER_
IR_CARRIER_PRESCALLER_
IR_TRAILSPACE_

The "flag" parameter has a long list of options:
IR_FLAGS_IO_INVERTED
IR_FLAGS_OUTPUT_HIGHDRIVE
IR_FLAGS_OUTPUT_MSCARRIER
IR_FLAGS_OUTPUT_HIGHIDLE
IR_FLAGS_INPUT_DETECTCARRIER
IR_FLAGS_IO_OUTPUT

The "IO_INVERTED" flag is explained in the reference documentation, but what about the other ones?
I am guessing I can use OR to select several of them. Correct?
Example: IR_FLAGS_IO_INVERTED | IR_FLAGS_INPUT_DETECTCARRIER

Applying it to a real case:
I am trying to capture IR signals from a Bang & Olufsen remote control. It sends IR on 455 kHz so I have a TSOP7000 to capture the IR signals.
I know the "mark" is 200 micro seconds and "space" is a multiple of 3125 micro seconds.
How does that translate into the right prescaler values?

As I have not managed to get my head around the IRcontroller library, I am curently using the GPT to sample the PIN status in order to capture the high/low signals and time them. It works so-so I would say. I am getting problems with the sampling frequency. The interrupt handler seems to stop the Z-Uno from executing some time consuming instructions, like the Serial.print command for instance. I would prefer to use a stable IR library for this sort of job.

Appreciate any help or hint.
p0lyg0n1
Posts: 242
Joined: 04 Aug 2016 07:14

Re: IRcontroller parameters

Post by p0lyg0n1 »

1) IR_FLAGS_INPUT_DETECTCARRIER - Hardware IR controller can detect carrier if you use "raw" receiver (without demodulator). It's not applicable for receivers like TSOP7000 with fixed frequency.
2) IR_FLAGS_OUTPUT_HIGHDRIVE drives up to 12 mA (8mA without this flag)on each IR output pin (you can use paired up to 3 pins simultaneously like this IR_TRANSMITTER_OUTPUT_PIN6|IR_TRANSMITTER_OUTPUT_PIN5|IR_TRANSMITTER_OUTPUT_PIN4).
3) IR_FLAGS_IO_OUTPUT = we use output mode (transmitter). Without this it will be receiver.
4) IR_FLAGS_OUTPUT_MSCARRIER = we calculate marks and spaces in carrier units(IR_CARRIER_PRESCALLER_xx) instead of mark/spaces units(IR_MS_PRESCALLER_xx). It's suitable with IR_FLAGS_INPUT_DETECTCARRIER for more precise results.
5) IR_FLAGS_OUTPUT_HIGHIDLE the high level on output in idle state of transmitter. Suitable with IR_FLAGS_IO_INVERTED in some cases.

6) IR_TRAILSPACE_xx - Trailing space after last Mark. After the incoming IR signal has been low (in terms of selected logic. See IR_FLAGS_IO_INVERTED) for this period of time the IR receiver stops. In IR_MS_PRESCALLER intervals. It defines the end condition for one data packet.

7) IR_MS_PRESCALLER_xx defines the quantum of marks/spaces measurement. In generally it defines accuracy of measurement.

8) IR_CARRIER_PRESCALLER_xx defines the quantum of currier detector. It have to be greater then selected IR_MS_PRESCALLER_xx to avoid skipping of short marks.

IR controller uses internal DMA and runs faster than GPT timer approach, but it only suitable for short IR-packages (128bits max).

calculation of time intervals:
By default we have IR_MS_PRESCALLER_2MHZ, so the internal accuracy of mark/space interval will be 1/2000000 = 500nS. Library converts values to useconds intervals automatically.
I recomend you to use example "IRScanner" for beginning.


To be continued...
petergebruers
Posts: 255
Joined: 26 Jul 2015 17:29

Re: IRcontroller parameters

Post by petergebruers »

perjar wrote:
24 Apr 2018 14:36
(...) The interrupt handler seems to stop the Z-Uno from executing some time consuming instructions, like the Serial.print command for instance.
Some background info...

According to the official docs : "The duration of an application interrupt routine must be below 80us." (See INS13954 Z-Wave 500 Series Appl. Programmers Guide v6.81.0x)

So that does not allow you to do a lot in an ISR. What you can do is set some data, or flags, or queue some commands in your own data structure, then process that in later in loop().

Also calling functions in an ISR might complicate matters and even cause stack exhaustion...
perjar
Posts: 57
Joined: 08 Apr 2018 18:02

Re: IRcontroller parameters

Post by perjar »

@p0lyg0n: Thank you very much, very comprehensive!

@petergebruers: Thanks I had not seen that part. 80 us, that's not much.
Post Reply