johnnyaction
Joined: 04 Feb 2008 Posts: 1 Location: Florida
|
Infrared remote emulation question |
Posted: Wed Feb 20, 2008 7:03 pm |
|
|
||EDIT:||
I think I need to learn how to send a 38khz carrier wave with pwm. I don't know how to do this.
||:End EDIT||
What I am attempting to do: Create a simple custom remote control sender and receiver over IR. I have a good working sender unit with the vishay IR breakout board from sparkfun but I'm having issues sending with a square wave like a normal IR remote control.
The problem I am having is sending IR signals so that they get received as a square wave. When I have a normal LED pulsing on and off at a constant rate when I hook it up to my oscilloscope I see a square wave. Good deal not the problem.
When I replace said normal LED with an IR led and use the following code with a vishay ir receiver breakout ( http://www.sparkfun.com/commerce/product_info.php?products_id=8554 ) reading the output of pin B4 yields nice definable square waves from a normal remote control but from my sending circuit all I get is a little spike and not the saw pattern I was expecting.
I am using 16F628a's with an input on B0 for the IR and an output on B4 for the oscilloscope lead on the receiving unit:
Code: |
#include <16F628A.h>
#include <math.h>
#fuses INTRC_IO,NOWDT,PUT,NOLVP
#use delay(clock=8000000)
int16 t0=0;
int16 t1=0;
int8 t0state=0;
int16 t2=0;
int16 multi_plier =0;
int8 mstate=0;
int16 change=0;
int16 servo=80;
int8 servo_state=0;
int8 data1=0;
int8 direction=0;
void main()
{
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_16);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8 );
setup_timer_2(T2_DIV_BY_16,255,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
disable_interrupts(GLOBAL); // all interrupts OFF
//Setup_Oscillator parameter not selected from Intr Oscillotar Config tab
// TODO: USER CODE!!
while(1){
t0 = get_timer0();
t1 = get_timer1();
//t2= get_timer2();
if(input(PIN_B0)==0){
output_high(PIN_B4);
}else{
output_low(PIN_B4);
}
}
}
|
code for the sending unit:
Code: |
#include <16F628A.h>
#include <math.h>
#fuses INTRC_IO,NOWDT,PUT,NOLVP
#use delay(clock=4000000)
int16 t0=0;
int16 t1=0;
int8 t0state=0;
int16 t2=0;
int16 multi_plier =0;
int8 mstate=0;
int16 change=0;
int16 servo=300;
int8 servo_state=0;
int8 data1=0;
int8 direction=0;
void delay_zs(int16 t)
{
do
{
delay_us(65500);
} while(--t);
}
void main()
{
//setup_timer_0(RTCC_INTERNAL|RTCC_DIV_16);
//setup_timer_1(T1_INTERNAL|T1_DIV_BY_8 );
// setup_timer_2(T2_DIV_BY_16,255,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
//disable_interrupts(GLOBAL); // all interrupts OFF
//Setup_Oscillator parameter not selected from Intr Oscillotar Config tab
//output_low(PIN_B4);
// TODO: USER CODE!!
while(1){
//t0 = get_timer0();
//t1 = get_timer1();
//t2= get_timer2();
output_high(PIN_B3);
output_high(PIN_B4);
//delay_zs(100);
delay_us(200);
output_low(PIN_B3);
output_low(PIN_B4);
//delay_zs(100);
delay_us(200);
}
}
|
|
|