Open janbobis opened 8 years ago
By the way, instead of logically ANDing the carrier frequency and the data through hardware (using MOSFETs), you can implement this through software using Fast PWM with Pin 4 of the MCU. You can see from the fork of the IRremote which was done by SeeJayDee (see link below), the carrier signal was at about 36-40Khz but may be set to 455Khz with a little prescaler and output comparator modification. Data to transmission is the same as how it was implemented except that headers, marks, and space needs to be modified. I'll try to do an implementation using yours and his approach and will get back to you once done.
https://gist.github.com/SeeJayDee/caa9b5cc29246df44e45b8e7d1b1cdc5
Nice to see you here Jan Bobis. Please share your changes here!
Nice to see you here to Sir Edward.
Nice observations Janbobis. This implementation with the ATTiny85 has many possible improvements. I placed it on github for others to use or improve on, even though I am going no further with developing this board.
I have spare boards if you would like to have a few. Message me at aetheraristotle@gmail.com if interested.
Another improvement could be the usage of a 14.xxx MHz resontator; the timings may more cleanly align than with 16MHz.
Just wanted to share my iLaps transponder code here. The code below makes use of ATTiny85's internal 8MHz clock. No prescaler has been selected and divide counter was set to 17 resulting to ~470KHz Fast PWM output to PIN4 (by enabling PWM1B in GTCCR). Toggling was done using a 26uS delay causing a 38KHz data mixing with the carrier signal (enabling and disabling the Fast PWM)
#include <avr/io.h>
#include <avr/interrupt.h>
#define MARK 16 // This was supposed to be 26 but due to inaccuracy and some delays using
// internal clock, the value was adjusted to achieve desired output
#define SPACE 26
void setup() {
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
TCCR1 = _BV(CTC1) | _BV(CS10);
GTCCR = _BV(PWM1B);
OCR1C = 17;
OCR1B = 7; // 41% duty cycle
}
void loop() {
// send code 1234567 (equivalent to 0E AD DC BA 98)
sendByte(0x0E);
sendByte(0xAD);
sendByte(0xDC);
sendByte(0xBA);
sendByte(0x98);
sendByte(0xD6);
delay(5);
}
void sendByte(unsigned long data){
for (int i = 0; i<8; i++){
if (i==0) space(SPACE);
if (data & 1) {
mark(MARK);
} else {
space(SPACE);
}
if(i==7) mark(MARK);
data>>=1;
}
}
void mark(int time){
GTCCR &= ~(_BV(COM1B1));
digitalWrite(4, HIGH);
delayMicroseconds(time);
}
void space(int time){
GTCCR |= _BV(COM1B1);
delayMicroseconds(time-2);
}
Nice job!
I've decided to make a version 2 of this transponder. I've uploaded some of the work here: https://github.com/Aether4E0A/IR-Transponder-ATTiny85-v2
Your code looks nice and simplified! Will test this out in my simulator later to see the output and compare this with your previous work. I will post my findings on the v2 github page
Couple of questions/clarifications from me.
Also, in your code, you have the following:
// It'd be best for you to read the datasheet carefully. And then read it again.
TCCR1 &= 0; // Is this register not zeroed by default? TCCR1 |= (1<<CTC1) | (1<<PWM1A) | (1<<CS10) | (1<<COM1A1); // set registers
OCR1A = 18; // Results in 455KHz w/ 51% duty cycle. good enough. OCR1C = 34; // however, glitches occur every 128us, or 2048 cycles. IDK why this occurs.
pinMode(1, OUTPUT); // Set output pin for OCR2B
Not sure about OCR2B, but do you mean OC1A for PB1 instead?