Это мой первый пост! Недавно я купил Cambridge Audio Azur 651a без удаленного дистанционного управления, я просто хочу убедиться, что все на удаленной стороне. Он использует протокол Philips RC-5. < /P>
Я написал очень простую программу для PIC18F2550 с компилятором CCS C для управления AMP. Каждая даже команда (значение Bit0 0) работают, но вся команда Odd (значение Bit0 1) не является? Это моя программа: < /p>
//////////////////////////////////////////////////////////////////////////
// //
// PHILIPS RC-5 PROTOCOL //
// //
// This program can reproduce with an IR led emitter, the code to //
// control any electronics that uses the RC-5 Protocol. Just send //
// the Address and Command you want. //
// //
// Remember that you send the two start bits (Always 1), the toggle //
// bit, the MSB to LSB of the Address and then the MSB to LSB of the //
// Command. //
// //
// The toggle bit is a bit that it maintains the same logic level as //
// long as a key is pressed continuously, but if a key is released and //
// is pressed back again (the same or a different key), the toggle bit //
// is inverted. If for example you press the button "1" and you keep //
// it pressed, the remote control sends the RC5 protocol with 114mSec //
// repetition interval, and all these repetitions have the same toggle //
// bit (for example 1). Now suppose that you release the key and you //
// press the same or another button. The next series of packets will //
// be sent with the toggle bit inverted (0). The reason for this bit //
// is for the receiver to recognize the double-click from a long //
// press. If for example you press button 1 twice (to switch to //
// channel 11), the receiver will understand this from the toggle bit //
// that will appear inverted the second time. //
// //
// Start, Inverted MSB of Command, Toggle, 5 bits of Address, Lower 6 //
// bits of Command //
// //
// //
// Cambridge Audio Azur 651A exemple: //
// //
// Address: 16 for Amp (5 bits) Command: 4 for S5 (6 bits) //
// //
// S1 S0 T A4 A3 A2 A1 A0 C5 C4 C3 C2 C1 C0 //
// 1 1 0 1 0 0 0 0 0 0 0 1 0 0 //
// //
// //
// You get a range of about 8 feet with this setup //
// and more if you put a reflector on the led. //
// //
// +5V --- (+IR LED-) ---39ohms---- (C 2N3904 E) ----- GND //
// B //
// | //
// 2N3904 1k Ohms //
// 1 2 3 | //
// E B C RC2/CCP1 //
// //
//////////////////////////////////////////////////////////////////////////
#include
#device adc=10
#fuses HS // High speed Osc (> 4Mhz for PCM/PCH)
#fuses NOWDT // No watch dog timer
#fuses NOPROTECT // Code not protected from reading
#fuses NOLVP // No low voltage programming
#fuses NODEBUG // No debug mode for ICD
#fuses CPUDIV1 // No System Clock Postscaler
#fuses PUT // Power Up Timer
#use delay(clock=20MHZ) // 20 Mhz crystal
// Software UART, not using UART hardware pins.
// Can use any pins for xmit and rcv !!
//#use rs232(baud=57600, xmit=PIN_C6, rcv=PIN_C7, errors)
// Hardware UART, using UART hardware pins.
//#use rs232(baud=9600, UART1, ERRORS)
// PWM is on pin RC2
// IRLED = 1 (to turn PWM Off, set pin as input)
// IRLED = 0 (to turn PWM On, set pin as output)
// This is the only way for changing pin RC2 direction without
// affecting the other pins on PORTC.
#byte TRISC=getenv("SFR:TRISC")
#bit IRLED=TRISC.2
// Command list with address: 16
int16 USB = 0b0011010000000000; // 0 (0x3400)
int16 S1 = 0b0011010000000010; // 2 (0x3402)
int16 S2 = 0b0011010000000101; // 5 (0x3405)
int16 S3 = 0b0011010000000011; // 3 (0x3403)
int16 S4 = 0b0011010000000001; // 1 (0x3401)
int16 S5 = 0b0011010000000100; // 4 (0x3404)
int16 Vol_up = 0b0011010000010000; // 16 (0x3410)
int16 Vol_down = 0b0011010000010001; // 17 (0x3411)
int16 Amp_on = 0b0011010000001110; // 14 (0x340E)
int16 Amp_off = 0b0011010000001111; // 15 (0x340F)
int16 Speaker = 0b0011010000010100; // 20 (0x3414)
int1 toggle_bit = 0;
int8 nb_time = 1;
void Remote_send(int16 command)
{
if (toggle_bit)
{
bit_set(command,11);
}
else
{
bit_clear(command,11);
}
do
{
// Send the 14-bit RC-5 Protocol
for (int8 i = 0;i < 14;i++)
{
if (bit_test(command,(13-i)))
{
// According to RC-5
IRLED = 1;
delay_us(890);
IRLED = 0;
delay_us(890);
//printf("1");
}
else
{
// According to RC-5
IRLED = 0;
delay_us(890);
IRLED = 1;
delay_us(890);
//printf("0");
}
}
// 14 bit long = 24.9ms
// Repeat interval = 114ms
// Interval between packets = 89.1ms
delay_ms(90);
nb_time++;
// Repeat 3 times
}while(nb_time < 4);
nb_time = 1;
toggle_bit = ~toggle_bit;
}
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(T0_OFF);
setup_timer_1(T1_DISABLED);
// PWM frequency:
// clock / ( 4 * prescaler * (period +1))
// 20,000,000 hz / ( 4 * 1 * 138) = 36,232Hz
// Philips RC-5 protocol works at 36khz
setup_timer_2(T2_DIV_BY_1,137,1);
setup_comparator(NC_NC_NC_NC);
setup_ccp1(CCP_PWM);
setup_ccp2(CCP_OFF);
setup_vref(FALSE);
disable_interrupts(INT_TIMER2);
// 25% to 33% duty cycle (.30 * period) according to RC-5 protocol
set_pwm1_duty(41);
// Wait for the RS232 port to settle.
//delay_ms(200);
//printf("Philips RC-5 Emitter\n\n\r");
// IR Led OFF
IRLED = 1;
while(true)
{
delay_ms(5000);
Remote_send(Amp_on);
delay_ms(5000);
Remote_send(USB);
delay_ms(5000);
Remote_send(S1);
delay_ms(5000);
Remote_send(S2);
delay_ms(5000);
Remote_send(S3);
delay_ms(5000);
Remote_send(S4);
delay_ms(5000);
Remote_send(S5);
delay_ms(5000);
Remote_send(Speaker);
delay_ms(5000);
Remote_send(Amp_off);
}
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... f-solution
RC-5 IR-протокол, из раствора ⇐ C++
Программы на C++. Форум разработчиков
1757825101
Anonymous
Это мой первый пост! Недавно я купил Cambridge Audio Azur 651a без удаленного дистанционного управления, я просто хочу убедиться, что все на удаленной стороне. Он использует протокол Philips RC-5. < /P>
Я написал очень простую программу для PIC18F2550 с компилятором CCS C для управления AMP. Каждая даже команда (значение Bit0 0) работают, но вся команда Odd (значение Bit0 1) не является? Это моя программа: < /p>
//////////////////////////////////////////////////////////////////////////
// //
// PHILIPS RC-5 PROTOCOL //
// //
// This program can reproduce with an IR led emitter, the code to //
// control any electronics that uses the RC-5 Protocol. Just send //
// the Address and Command you want. //
// //
// Remember that you send the two start bits (Always 1), the toggle //
// bit, the MSB to LSB of the Address and then the MSB to LSB of the //
// Command. //
// //
// The toggle bit is a bit that it maintains the same logic level as //
// long as a key is pressed continuously, but if a key is released and //
// is pressed back again (the same or a different key), the toggle bit //
// is inverted. If for example you press the button "1" and you keep //
// it pressed, the remote control sends the RC5 protocol with 114mSec //
// repetition interval, and all these repetitions have the same toggle //
// bit (for example 1). Now suppose that you release the key and you //
// press the same or another button. The next series of packets will //
// be sent with the toggle bit inverted (0). The reason for this bit //
// is for the receiver to recognize the double-click from a long //
// press. If for example you press button 1 twice (to switch to //
// channel 11), the receiver will understand this from the toggle bit //
// that will appear inverted the second time. //
// //
// Start, Inverted MSB of Command, Toggle, 5 bits of Address, Lower 6 //
// bits of Command //
// //
// //
// Cambridge Audio Azur 651A exemple: //
// //
// Address: 16 for Amp (5 bits) Command: 4 for S5 (6 bits) //
// //
// S1 S0 T A4 A3 A2 A1 A0 C5 C4 C3 C2 C1 C0 //
// 1 1 0 1 0 0 0 0 0 0 0 1 0 0 //
// //
// //
// You get a range of about 8 feet with this setup //
// and more if you put a reflector on the led. //
// //
// +5V --- (+IR LED-) ---39ohms---- (C 2N3904 E) ----- GND //
// B //
// | //
// 2N3904 1k Ohms //
// 1 2 3 | //
// E B C RC2/CCP1 //
// //
//////////////////////////////////////////////////////////////////////////
#include
#device adc=10
#fuses HS // High speed Osc (> 4Mhz for PCM/PCH)
#fuses NOWDT // No watch dog timer
#fuses NOPROTECT // Code not protected from reading
#fuses NOLVP // No low voltage programming
#fuses NODEBUG // No debug mode for ICD
#fuses CPUDIV1 // No System Clock Postscaler
#fuses PUT // Power Up Timer
#use delay(clock=20MHZ) // 20 Mhz crystal
// Software UART, not using UART hardware pins.
// Can use any pins for xmit and rcv !!
//#use rs232(baud=57600, xmit=PIN_C6, rcv=PIN_C7, errors)
// Hardware UART, using UART hardware pins.
//#use rs232(baud=9600, UART1, ERRORS)
// PWM is on pin RC2
// IRLED = 1 (to turn PWM Off, set pin as input)
// IRLED = 0 (to turn PWM On, set pin as output)
// This is the only way for changing pin RC2 direction without
// affecting the other pins on PORTC.
#byte TRISC=getenv("SFR:TRISC")
#bit IRLED=TRISC.2
// Command list with address: 16
int16 USB = 0b0011010000000000; // 0 (0x3400)
int16 S1 = 0b0011010000000010; // 2 (0x3402)
int16 S2 = 0b0011010000000101; // 5 (0x3405)
int16 S3 = 0b0011010000000011; // 3 (0x3403)
int16 S4 = 0b0011010000000001; // 1 (0x3401)
int16 S5 = 0b0011010000000100; // 4 (0x3404)
int16 Vol_up = 0b0011010000010000; // 16 (0x3410)
int16 Vol_down = 0b0011010000010001; // 17 (0x3411)
int16 Amp_on = 0b0011010000001110; // 14 (0x340E)
int16 Amp_off = 0b0011010000001111; // 15 (0x340F)
int16 Speaker = 0b0011010000010100; // 20 (0x3414)
int1 toggle_bit = 0;
int8 nb_time = 1;
void Remote_send(int16 command)
{
if (toggle_bit)
{
bit_set(command,11);
}
else
{
bit_clear(command,11);
}
do
{
// Send the 14-bit RC-5 Protocol
for (int8 i = 0;i < 14;i++)
{
if (bit_test(command,(13-i)))
{
// According to RC-5
IRLED = 1;
delay_us(890);
IRLED = 0;
delay_us(890);
//printf("1");
}
else
{
// According to RC-5
IRLED = 0;
delay_us(890);
IRLED = 1;
delay_us(890);
//printf("0");
}
}
// 14 bit long = 24.9ms
// Repeat interval = 114ms
// Interval between packets = 89.1ms
delay_ms(90);
nb_time++;
// Repeat 3 times
}while(nb_time < 4);
nb_time = 1;
toggle_bit = ~toggle_bit;
}
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(T0_OFF);
setup_timer_1(T1_DISABLED);
// PWM frequency:
// clock / ( 4 * prescaler * (period +1))
// 20,000,000 hz / ( 4 * 1 * 138) = 36,232Hz
// Philips RC-5 protocol works at 36khz
setup_timer_2(T2_DIV_BY_1,137,1);
setup_comparator(NC_NC_NC_NC);
setup_ccp1(CCP_PWM);
setup_ccp2(CCP_OFF);
setup_vref(FALSE);
disable_interrupts(INT_TIMER2);
// 25% to 33% duty cycle (.30 * period) according to RC-5 protocol
set_pwm1_duty(41);
// Wait for the RS232 port to settle.
//delay_ms(200);
//printf("Philips RC-5 Emitter\n\n\r");
// IR Led OFF
IRLED = 1;
while(true)
{
delay_ms(5000);
Remote_send(Amp_on);
delay_ms(5000);
Remote_send(USB);
delay_ms(5000);
Remote_send(S1);
delay_ms(5000);
Remote_send(S2);
delay_ms(5000);
Remote_send(S3);
delay_ms(5000);
Remote_send(S4);
delay_ms(5000);
Remote_send(S5);
delay_ms(5000);
Remote_send(Speaker);
delay_ms(5000);
Remote_send(Amp_off);
}
}
Подробнее здесь: [url]https://stackoverflow.com/questions/79764088/rc-5-ir-protocol-out-of-solution[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия