CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

38kHz IR signal transmitter

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
tunatopraktan



Joined: 19 Mar 2021
Posts: 13

View user's profile Send private message AIM Address

38kHz IR signal transmitter
PostPosted: Thu Apr 15, 2021 1:59 pm     Reply with quote

38kHz IR signal transmitter

Hello friends.
I am working on a IR signal circuit. I want to control my Samsung TV. But i am confused.
I have a 20mHz external crystal. How will i create 38kHz carrier signal ?
There are a few examples with internal oscillator. But as i said, i will use external 20Mhz crystal.

Thank you.
temtronic



Joined: 01 Jul 2010
Posts: 9113
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Apr 15, 2021 2:45 pm     Reply with quote

How ??
There are several ways but we need to know which PIC you have to use.
Depending on the PIC, there are different internal peripherals that can be used.

Also you'll need to know how to 'pulse' the 38KHz signal to 'mimic' the pushbuttons on the remote.
tunatopraktan



Joined: 19 Mar 2021
Posts: 13

View user's profile Send private message AIM Address

PostPosted: Thu Apr 15, 2021 2:55 pm     Reply with quote

temtronic wrote:
How ??
There are several ways but we need to know which PIC you have to use.
Depending on the PIC, there are different internal peripherals that can be used.

Also you'll need to know how to 'pulse' the 38KHz signal to 'mimic' the pushbuttons on the remote.


Hello,
I will use pic16F877A.
I have learned remote codes with my receiver circuit. volume up code, volume down code, etc...
I plan to use pwm out to send signals.
There is a sample code below.

But, i want to use external 20Mhz crystal.
Code:

#include <12F1822.h>
#fuses NOMCLR INTRC_IO PLL_SW
#use delay(clock=32000000)
#use fast_io(A)
#use pwm (PWM1, FREQUENCY = 38KHz, DUTY = 25, PWM_OFF)

void send_signal(unsigned int32 number){
int8 i;
// Send 9ms burst
pwm_on();
delay_ms(9);
// Send 4.5ms space
pwm_off();
delay_us(4500);
// Send data
for(i = 0; i < 32; i++){
    // If bit is 1 send 560us pulse and 1680us space
    if(bit_test(number, 31 - i)){
      pwm_on();
      delay_us(560);
      pwm_off();
      delay_us(1680);
     }
     // If bit is 0 send 560us pulse and 560us space
     else{
       pwm_on();
       delay_us(560);
       pwm_off();
       delay_us(560);
      }
    }
// Send end bit
pwm_on();
delay_us(560);
pwm_off();
delay_us(560);
}

void main() {
setup_oscillator(OSC_8MHZ | OSC_PLL_ON); // Set internal oscillator to 32MHz (8MHz and PLL)
output_a(0);
set_tris_a(0x3B); // Configure RA2 pin as output and others as inputs
port_a_pullups(0x3B); // Enable internal pull-ups for pins RA0,RA1,RA3,RA4 & RA5

while(TRUE){
  while(!input(PIN_A0)){
    send_signal(0x40BF00FF);
    delay_ms(500);
    }

while(!input(PIN_A1)){
  send_signal(0x40BF807F);
  delay_ms(500);
  }

while(!input(PIN_A3)){
  send_signal(0x40BF40BF);
  delay_ms(500);
  }

while(!input(PIN_A4)){
  send_signal(0x40BF20DF);
  delay_ms(500);
  }

while(!input(PIN_A5)){
  send_signal(0x40BFA05F);
  delay_ms(500);
  }
}
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group