IR NecCodes


guten abend leute,
ich versuche mir gerade mit einem meiner attiny45 (hab da noch ein paar von)
eine fernbedinung zu bauen.

protokoll soll dabei das nec-protokoll sein.

habe in atmel studio 6.2 folgenden code geschrieben und dabei versucht den protokollbeschreibungen
von http://www.sbprojects.com/knowledge/ir/nec.php zu folgen.

code: [select]
/*
* remotecont.c
*
* created: 13.08.2014 21:56:20
*  author: adrian
*/

#define f_cpu 1000000l

#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>

//variablen
volatile unsigned long code = 1119735855;
volatile unsigned long mask;
volatile int toggle;

//zum an/ausschalten der ir-led
void startir()
{
tccr1 = (1 << ctc1)|(1 << com1a0)|(1 << cs11); //prescaler auf 2 stellen
ocr1a = ocr1c = 6; //compare match register auf 6 stellen -> frequenz ~38khz
}

void endir()
{
tccr1 = 0;
ocr1a = ocr1c = 0;
}

//hauptschleife
int main(void)
{
//outputpins einstellen
ddrb |= (1 << pb1);
portb &= ~(1 << pb1);

//tccr1 = (1 << ctc1)|(1 << cs11); //prescaler auf 2 stellen
//ocr1a = ocr1c = 6; //compare match register auf 7 stellen
//timsk = (1 << ocie1a);
//sei();

    while(1)
    {
    startir();
    _delay_us(9000);

    endir();
    _delay_us(4500);
   
    for(int = 0; <= 32; i++)
    {
    startir();
    _delay_us(560);
   
    mask = (1 << i);
   
    endir();
   
    //zu übertragendes bit überprüfen
    if(code & mask)
    _delay_us(1690); //ist das bit gesetzt 1.69µs warten
    else
    _delay_us(560); //sonst 0.56µs warten
    }
    }
}

//isr(tim1_compa_vect)
//{
//if(toggle == 1)
//portb ^= (1 << pb1);
//else
//portb = 0;
//}


leider wird der gesendete code nicht als neccode erkannt (test mit arduino und tsop-empfänger) dafür aber als unknown.
daraus folgere ich, dass die modulations frequenz zwar stimmt, aber das timing oder bitshifting nicht.
kann mir vllt jemand sagen, wie ich das fixen kann.

ich hatte das auch mal über einen timercomparematch interrupt versucht (daher unten das makkro), allerdings hat da die frequenz scheinbar nicht gestimmt.

hallo,
sieht aus, als wenn du das zu fuss programmieren willst.
einen arduino hast du ja, probiere doch einmal die lib aus diesem beitrag:
http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html

bei den beispielen gibt es eines, das gibt raw-daten aus. vielleicht kommst du deinem ir-sender auf die schliche.
gruß und spaß
andreas


Arduino Forum > International > Deutsch (Moderator: uwefed) > IR NecCodes


arduino

Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support