IR-lib and long Raw seqences

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
schmidmi
Posts: 55
Joined: 01 Dec 2016 16:45
Location: Germany (Karlsruhe)

IR-lib and long Raw seqences

Post by schmidmi »

Hi!
I' still in trouble with my Mitsubishi AC device.
As already mentioned, it has a code length of 18 bytes which has to be send twice with a certain header in between.

For encoding these 18 bytes plus the header i need 290 definitions for mark and spaces like:

word raw_command_1[] = {0x122, 0xD34, 0x6D6, 0x19E, 0x4D4, 0x19E, 0x4D4, 0x19E, 0x1A4, 0x19E, 0x1A4......};

When trying to send this array of words with "IR.send_raw16(raw_command_1);"
I can see that there seems to be an overflow in the sending routine. Instead of 0x122 pulses i get an out put of just about 33 pulses.
When I shorten the length of the word array to less then 255 items, I will get a correct output.
But unfortunately it seems not to be possible, to send multiple raw commands directly after each other like

IR.send_raw16(raw_command_1);
IR.send_raw16(raw_command_2);
IR.send_raw16(raw_command_3);
....

to get a correct output stream. When trying this, the transmission will be aborted.

Does anybody know a solution for this nasty problem?
p0lyg0n1
Posts: 242
Joined: 04 Aug 2016 07:14

Re: IR-lib and long Raw seqences

Post by p0lyg0n1 »

0x122 * sizof(word) = 580 bytes!
580 > 300 bytes => Overflow.
If you try to translate it sequently use delayMicroseconds between quants.
Send_raw is not a blocking command...
You have to use fitted time intervals here:

Code: Select all

IR.send_raw16(first_part_data);
delayMicroseconds(first_part_delay);
IR.send_raw16(second_part_data);
delayMicroseconds(second_part_delay);
<...>
You can try to send large data using hardware anyway:
Here is a trick. You have to modify mark/space prescaller to fit your intervals to 1 byte during conversion. Of course it will downgrade a signal quality... See http://z-uno.z-wave.me/Reference/IR/IRT ... terParams/ for more details.
So, the main idea is "interval have to be 127 ticks of your prescaller maximum". In that case it will be encoded to single bytes during translation to hardware. Just try to varying ms_prescaller and analize output sequence. Can give you an example if you attach the whole raw sequence here.

On the other hand you can do this translation by means of GPT too.
schmidmi
Posts: 55
Joined: 01 Dec 2016 16:45
Location: Germany (Karlsruhe)

Re: IR-lib and long Raw seqences

Post by schmidmi »

Thanks for your quick reply!
I didn't understand the hint with the Prescaler.
So I tried to follow the hints with the delay between my splitted raw data variables.
Each of this variables has a length < 150. So it shouldn't violate the range of 300 bytes.
Each variable ends with an mark and I used the required following space as the value for the delay.

But the output is not like it should be.
Sending the first part only (raw_command_1) everything looks nice.
But when adding the two other parts I get a very strange output.
Here is my code:

Code: Select all

#include <IRController.h>
#include <EEPROM.h>

#define LED_PIN 13

// Input for the local On/Off button
#define SWITCH_LOCAL 12

// value to make a dlay of 30 seconds between the reports
#define WAIT_SPAN 300

IRTransmitterParams ir_transmitter(byte(IR_TRANSMITTER_OUTPUT_PIN6), 
                                   IR_FLAGS_OUTPUT_HIGHDRIVE,
                                   IR_MS_PRESCALLER_4MHZ, 
                                   IR_CARRIER_PRESCALLER_8MHZ);

byte currentLEDValue;   // Last saved LED value
int waitCounter;        // counter to make a delay of approx. 30 seconds
                               //1      2       3     4       5     6     7       8       9     10      11    12      13    14    15      16    17      18      19    20    21      22    23      24    25      26    27      28      29    30      31     32     33    34      35    36      37    38      39    40      41    42    43      44      45    46      47    48     49     50      51    52      53     54     55    56      57    58      59    60    61      62    63      64    65      66      67    68      69    70      71    72    73      74      75     76     77    78    79      80    81      82      83     84     85    86      87     88   89       90   91      92      93    94      95    96      97    98    99      100    101    102    103    104    105    106   107     108   109     110   111     112    113    114   115     116   117     118    119    120    121    122   123     124   125     126    127    128   129     130   131     132    133    134   135     136   137     138   139     140   141     142    143    144    145   146    147    148    149                
word raw_command_1[] = {0x95, 0xD34, 0x6D6, 0x19E, 0x4D4, 0x19E, 0x4D4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x4D4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x4D4, 0x19E, 0x4D4, 0x19E, 0x1A4, 0x19E, 0x4D4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x4D4, 0x19E, 0x4D4, 0x19E, 0x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4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x4D4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x4D4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x4D4, 0x19E, 0x4D4, 0x19E, 0x4D4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E, 0x1A4, 0x19E};

word repeater[] = {0x02, 0x1BB, 0x42CC};

void setup() {
  // put your setup code here, to run once:

    pinMode(LED_PIN, OUTPUT);
    pinMode(SWITCH_LOCAL,INPUT_PULLUP);

    pinMode(6, OUTPUT); 

    ir_transmitter.setupVendor(IR_VENDOR_UNKNOWN);
    IR.begin(&ir_transmitter);
    
    digitalWrite(6, LOW); 
    Serial.begin();
    Serial.println("start");
    EEPROM.get(0,&currentLEDValue,1);
    setSWBIN(currentLEDValue);
}

void loop() {
  // put your main code here, to run repeatedly:
waitCounter = 0;  
    // send every 30 second only
    // we don't use "delay(..), because we have to scan the local button continously
    Serial.println("Loop...");
    do
    {
      // read the input
      byte result = digitalRead(SWITCH_LOCAL);
      if (result == 1)
      {
        // toggle the state On/Off
        if (currentLEDValue == 0)
        {
          setSWBIN(255);
        }
        else
        {
          setSWBIN(0);
        }
//        zunoSendReport(2); // remark: if the button is pushed frequently, there will be more reports than one each 30 seconds!
        // wait until the button is released to prevent cyclic toogle of the state if the button is pushed continously
        while (result == 1)
        {
          result = digitalRead(SWITCH_LOCAL);
        }
      }
      delay(100);
      waitCounter++;
    }
    while (waitCounter < WAIT_SPAN);
}

// methode to update the state of the device
void setSWBIN(byte value) {
  // value is a variable, holding a "new value"
  // which came from the controller or other Z-Wave device
  if (value > 0) {               // if greater then zero
    digitalWrite (LED_PIN, HIGH); //turn the LED on (HIGH is the voltage level)
  } else {                         // if equals zero
    digitalWrite(LED_PIN, LOW);   //turn the LED off by making the voltage LOW
  }
  // we'll save our value for the situation, when the controller will ask us about it
  if (currentLEDValue != value)
  {
    currentLEDValue = value;
    EEPROM.put(0,&currentLEDValue,1);
    //Anstelle der Ansteuerung einer LED wird später IR zur Steuerung des Klimagerätes verwendet
    if (currentLEDValue == 0)
    {
      //Serial.println("Send Command ON");
//      sendRAWCommand(raw_command_ON);
         sendRAWCommand();
    }
    else
    {
      //Serial.println(" Send Command ON");
//      sendRAWCommand(raw_command_ON);
        sendRAWCommand();
    }
  }
}

void sendRAWCommand() {
//      Serial.println("Send Command...");
      IR.send_raw16(raw_command_1);
      delayMicroseconds(420);
      IR.send_raw16(raw_command_2);
      delayMicroseconds(1236);
      IR.send_raw16(raw_command_3);
schmidmi
Posts: 55
Joined: 01 Dec 2016 16:45
Location: Germany (Karlsruhe)

Re: IR-lib and long Raw seqences

Post by schmidmi »

p0lyg0n1 wrote:0x122 * sizof(word) = 580 bytes!
580 > 300 bytes => Overflow.
If you try to translate it sequently use delayMicroseconds between quants.
Send_raw is not a blocking command...
You have to use fitted time intervals here:

Code: Select all

IR.send_raw16(first_part_data);
delayMicroseconds(first_part_delay);
IR.send_raw16(second_part_data);
delayMicroseconds(second_part_delay);
<...>
You can try to send large data using hardware anyway:
Here is a trick. You have to modify mark/space prescaller to fit your intervals to 1 byte during conversion. Of course it will downgrade a signal quality... See http://z-uno.z-wave.me/Reference/IR/IRT ... terParams/ for more details.
So, the main idea is "interval have to be 127 ticks of your prescaller maximum". In that case it will be encoded to single bytes during translation to hardware. Just try to varying ms_prescaller and analize output sequence. Can give you an example if you attach the whole raw sequence here.

On the other hand you can do this translation by means of GPT too.
Today I tried to find out the behaviour of the magic ms_prescaler to reduce the raw data from sizeof(word) to sizeof(byte), but I failed :cry:
Increasing this value up to 16MHZ results the length of marks an space to become shorter. OK.
But decreasing the value down to 250KHZ does not change anything.
schmidmi
Posts: 55
Joined: 01 Dec 2016 16:45
Location: Germany (Karlsruhe)

Re: IR-lib and long Raw seqences

Post by schmidmi »

Today tried to find out what is going wrong when sending two sequences directly one after the other.
So I had a look to the state of the IR object before sending the second sequence.

Code: Select all

IR.send_raw16(raw_command_1);
      while (IR.getState() == IR_STATUS_BUSY)
      {
        
      }
//      delayMicroseconds(75040);
      IR.send_raw16(raw_command_2);
In the attached picture of the IR signal you can see, that there is a gap of about 13.000 microseconds until the IR object isn't busy any more.
When sending the next sequence while IR is still busy, will mess up the first sequence too.

I'm getting the feeling, that ZUNO will not be able to handle my AC control and I have to look for a different device to include my AC control into my Home Automation....
Attachments
IR_Analysis.PNG
IR_Analysis.PNG (89.44 KiB) Viewed 9917 times
schmidmi
Posts: 55
Joined: 01 Dec 2016 16:45
Location: Germany (Karlsruhe)

Re: IR-lib and long Raw seqences

Post by schmidmi »

Hmmm, no reply is also a type of reply....
schmidmi
Posts: 55
Joined: 01 Dec 2016 16:45
Location: Germany (Karlsruhe)

Re: IR-lib and long Raw seqences

Post by schmidmi »

and by the way:
I failed also to use a 'normal' output for creating correct sequences :cry:
p0lyg0n1
Posts: 242
Joined: 04 Aug 2016 07:14

Re: IR-lib and long Raw seqences

Post by p0lyg0n1 »

Hi,
Looks like the delay that you can see is associated with filling of inner IRController buffer.
So, the only one chance to get it work without external IRController is to use GPT.
Can you send me raw marks and spaces in microseconds? I can try it myself using GPT.

Don't worry we try to answer asap ;)... but sometimes we have the holidays:)
schmidmi
Posts: 55
Joined: 01 Dec 2016 16:45
Location: Germany (Karlsruhe)

Re: IR-lib and long Raw seqences

Post by schmidmi »

Thanks for the quick reply 8-)
I don't know this word 'holidays' because I'm working as a freelancer. But of course I hope, you did enjoy yours...

But back to IR:

The length of marks and spaces are already described in the raw data variables in my code.
But if it would help, here again a listing of the signals with the length of marks an spaces. The first value is a mark, the second a space the third a mark and so on...

3384 1652 448 1232 468 1212
448 392 448 392 448 392
448 1228 452 388 452 388
452 1228 448 1232 452 388
448 1232 448 392 448 392
448 1232 448 1228 452 388
452 1228 480 1200 472 368
452 388 448 1232 448 392
448 392 448 1232 448 392
448 388 452 388 452 388
452 388 452 388 452 388
448 392 448 392 448 392
448 392 448 392 448 392
448 392 448 392 448 388
452 388 452 388 452 388
452 388 452 1228 472 368
448 392 480 360 480 360
448 392 448 1232 448 1228
452 388 452 388 452 388
452 1228 448 1232 472 1208
448 392 448 392 448 392
448 392 448 392 448 388
452 1228 452 1228 452 388
452 1228 448 1232 448 392
448 392 448 392 448 392
448 388 472 1208 452 388
452 388 452 1228 480 360
448 392 448 1232 448 392
448 392 448 392 448 1228
452 1228 452 388 452 388
452 388 448 392 448 392
448 392 448 392 448 392
448 392 448 392 448 392
468 372 448 388 452 388
452 388 452 388 452 388
452 388 452 388 448 392
448 392 448 392 448 392
448 392 448 392 448 1232
448 392 448 388 484 356
452 388 452 388 452 388
448 392 448 392 448 392
448 392 448 392 448 392
448 392 448 392 448 392
448 392 448 388 452 388
452 388 452 388 452 388
448 396 444 392 448 1232
448 392 448 1232 448 392
448 1228 452 1228 452 388
452 388 448 11324 3384 1652
448 1232 448 1232 448 392
448 392 448 392 448 1228
452 388 448 392 480 1200
448 1232 448 392 448 1232
448 392 448 392 448 1232
448 1228 452 388 452 1228
452 1228 448 392 448 392
448 1232 448 392 448 392
448 1232 448 388 452 388
452 388 452 388 452 388
452 388 452 388 452 388
448 392 448 392 448 392
448 392 448 392 448 392
448 392 448 388 452 388
452 388 452 388 452 388
452 1228 472 368 448 392
448 392 448 392 448 392
448 1232 480 1200 448 388
452 388 452 388 452 1228
448 1232 448 1232 448 392
448 392 448 392 448 392
448 392 448 388 452 1228
452 1228 452 388 472 1208
472 1208 448 392 448 392
448 392 448 392 448 392
448 1228 452 388 452 388
452 1228 448 392 448 392
448 1232 448 392 448 392
448 392 448 1228 452 1228
456 384 452 388 452 388
452 388 448 392 448 392
448 392 448 392 448 392
448 392 448 392 448 392
448 392 448 392 448 388
452 388 452 388 472 368
452 388 448 392 448 392
448 392 448 392 448 392
448 392 448 1232 468 368
452 388 452 388 472 368
452 388 452 388 452 388
448 392 448 392 448 392
448 392 448 392 448 392
448 392 448 392 448 388
452 388 452 388 452 388
452 388 452 388 452 388
452 388 452 1228 440 400
448 1232 480 360 440 1236
440 1240 440 400 440 400
440

The magenta value of 11324 microseconds is the space which anounces the repetion of the telegram.
That means my remote control sends the telegram twice with that space in between.
At the moment i don't know, if the AC device accepts one telegram also.
p0lyg0n1
Posts: 242
Joined: 04 Aug 2016 07:14

Re: IR-lib and long Raw seqences

Post by p0lyg0n1 »

Hi,
I made an example with GPT. It works ok, but it reproduce a signal without modulation. So, you have a start point for your research... I don't have a time to go deeper.

Code: Select all


ZUNO_SETUP_ISR_GPTIMER(software_ir_gpt);

#define SOFT_IR_PIN 6
#define MY_SERIAL 	Serial0
#define MAX_IR_BUFF	512

word g_sfir_buff[MAX_IR_BUFF];
word g_sfir_offset = 0;
word g_sfir_count = 0;
word g_sfir_interval = 0;

word raw_command_1[] = {
							424, 
							0xD34, 0x6D6, 
							0x19E, 0x4D4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4,
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x4D4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4,
							0x19E, 0x4D4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x4D4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x4D4, 
							0x19E, 0x4D4, 
							0x19E, 0x4D4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E, 0x1A4, 
							0x19E
						};

void sendSoftIRData(word * raw16)
{
	word i;
	g_sfir_count = raw16[0];

	g_sfir_interval  = 0;
	for(i=0;i<raw16[0];i++)
	{
		g_sfir_interval +=  raw16[i+1];
		g_sfir_buff[i] = raw16[i+1];
		g_sfir_buff[i] <<= 2; // *= 4, we use 4Mhz ticks instead of microseconds	
	}

	pinMode(SOFT_IR_PIN, OUTPUT);
	digitalWrite(SOFT_IR_PIN, HIGH);
	zunoGPTInit(ZUNO_GPT_CYCLIC);	
  	zunoGPTSet(g_sfir_buff[0]); 
  	zunoGPTEnable(1); 
  	zunoGPTSet(g_sfir_buff[1]); 
  	g_sfir_offset = 1;
}

void setup() {
  
  MY_SERIAL.begin(115200);

}


void loop() {
  
  MY_SERIAL.print("loop:");
  MY_SERIAL.println(millis());

  sendSoftIRData(raw_command_1);
  delay(10000);

}

void software_ir_gpt()
{
	digitalToggle(SOFT_IR_PIN);
	g_sfir_offset++;
	if(g_sfir_offset >= g_sfir_count)
	{

		digitalWrite(SOFT_IR_PIN, LOW);
		zunoGPTEnable(0); 
	}
	else
	{
		zunoGPTSet(g_sfir_buff[g_sfir_offset]); 
	}

}
Post Reply