Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

IR Remote

Status
Not open for further replies.

AtomSoft

Well-Known Member
Hey guys im back with yet another project. This time i want to make a IR remote. The only issue i have is that i dont have another PIC to use to send the signal and i dont know what other materials im going to need so. Can someone make me like a parts list to a basic remote?

Some features/Info i would like:
1. Can i make up my own devicecode/commandcode and start time?
2. I learned a little from https://www.sbprojects.com i can convert time to cycles no issue but how would i send the info to IR?
3. Some links to more info and basic schematics would be awsome.

Thanks to all.
 
I've seen one PIC remote kit. Hardly seems worth it as remotes are so very cheap and come in a nice case buttons etc. But if you want to build one here's a link.
http://www.sixca.com/eng/articles/remote/index.html

Of course you could hook an IR LED directly to the Junebugs CON5 port, it has a 100ohm resistor built in on RB3. You'd hook an IR LED between RB3 & GND, it's on the PWM pin so 38KHz modulation should be very easy :)

I found this cheap RCA remote for $7
**broken link removed**
 
Last edited:
i would love to make my own if possible just because it would be more understandable i think. I always look at your tutorials but find it complex as i am a beginner. But i will look again and try to better understand it.
 
I've editied my post, a typical IR LED can be connected to CON5 on the Junebug. Setup the PWM for 38KHz for starters. You should be able to control a TV for starters.
 
blueroomelectronics said:
I've editied my post, a typical IR LED can be connected to CON5 on the Junebug. Setup the PWM for 38KHz for starters. You should be able to control a TV for starters.


for starters i dont know what PWM stands for and how to set it up. And i wouldnt know how to code it.
 
Well with IR it would simply be used to modulate the IR LED at the hardware level. Sort of set & go.

With a clock of 4MHz the PWM can be programmed for 38.462 KHz which will work just fine with a 38KHz device. I think Sony is 40 KHz but usually plus or minus a few KHz will work.

Here's a handy PIC calculator.
**broken link removed**
 
Connect the long lead to RB3, the short lead to GND. Don't solder the LED directly to the CON5 pins* as that would ruin the connector. Both parts will do the same thing and both should work.
* in a pinch you might be able to use the programming connector as a temporary LED to CON5 cable. I haven't tried this method but it should work fine.
 
Read my toy car project (on the I should update this projects page of my site)

PWM is overkill for this but dirt easy to use, it can generate the 38KHz carrier for the LED with zero software overhead. Think of it like a LM555

To demonstrate; set the PWM up to run at some slow speed and hook a regular LED to your test cable. Blinking in hardware :)
The duty cycle (for IR 50% is fine) is the ON vs OFF time of the pulse.
 
Last edited:
I cant find info for PR2 or CCP2CON.

PR2 = 10b0111100 ;
T2CON = 0b00000101 ;
CCP1CON = 0b00001100 ;
CCP2CON = 0b00111100 ;

would be in asm
Code:
MOVLW    b'01111100'
MOVWF    PR2
MOVLW    b'00000101'
MOVWF   T2CON
MOVLW    b'00001100'
MOVWF    CCP1CON 
MOVLW    b'00111100'
MOVWF    CCP2CON
right?
Code:
REGISTER 13-1: T2CON: TIMER2 CONTROL REGISTER

bit 7 Unimplemented: Read as ‘0’

bit 6-3 TOUTPS3:TOUTPS0: Timer2 Output Postscale Select bits
0000 = 1:1 Postscale
0001 = 1:2 Postscale
•
•
•
1111 = 1:16 Postscale

bit 2 TMR2ON: Timer2 On bit
1 = Timer2 is on
0 = Timer2 is off

bit 1-0 T2CKPS1:T2CKPS0: Timer2 Clock Prescale Select bits
00 = Prescaler is 1
01 = Prescaler is 4
1x = Prescaler is 16
Code:
REGISTER 15-1: CCP1CON REGISTER FOR ENHANCED CCP OPERATION

bit 7-6 P1M1:P1M0: PWM Output Configuration bits
If CCP1M<3:2> = 00, 01, 10:
xx = P1A assigned as Capture/Compare input; P1B, P1C, P1D assigned as port pins
If CCP1M<3:2> = 11:
00 = Single output; P1A modulated; P1B, P1C, P1D assigned as port pins
01 = Full-bridge output forward; P1D modulated; P1A active; P1B, P1C inactive
10 = Half-bridge output; P1A, P1B modulated with dead-band control; P1C, P1D assigned as
port pins
11 = Full-bridge output reverse; P1B modulated; P1C active; P1A, P1D inactive

bit 5-4 DC1B1:DC1B0: PWM Duty Cycle Least Significant bits
Capture mode:
Unused.
Compare mode:
Unused.
PWM mode:
These bits are the two LSbs of the PWM duty cycle. The eight MSbs are found in CCPR1L.

bit 3-0 CCP1M3:CCP1M0: ECCP1 Mode Select bits
0000 = Capture/Compare/PWM off (resets ECCP module)
0001 = Unused (reserved)
0010 = Compare mode, toggle output on match (ECCP1IF bit is set)
0011 = Unused (reserved)
0100 = Capture mode, every falling edge
0101 = Capture mode, every rising edge
0110 = Capture mode, every 4th rising edge
0111 = Capture mode, every 16th rising edge
1000 = Compare mode, set output on match (ECCP1IF bit is set)
1001 = Compare mode, clear output on match (ECCP1IF bit is set)
1010 = Compare mode, generate software interrupt on match (ECCP1IF bit is set,
ECCP1 pin returns to port pin operation)
1011 = Compare mode, trigger special event (ECCP1IF bit is set; ECCP resets TMR1 or
TMR3 and starts an A/D conversion if the A/D module is enabled)
1100 = PWM mode; P1A, P1C active-high; P1B, P1D active-high
1101 = PWM mode; P1A, P1C active-high; P1B, P1D active-low
1110 = PWM mode; P1A, P1C active-low; P1B, P1D active-high
1111 = PWM mode; P1A, P1C active-low; P1B, P1D active-low
 
ok i am truly lost lol can someone write a small piece of code with some good comments so i can try to understand this. I see so much you have to do this and that from reading the data sheet but nothing really explains. Like CCP2CON doesnt exist in the 1320. The code for the Toy car is for firefly is not to complex thanks but :

movfw ADRESH ;B0 W = A/D high byte

MOVFW ? Doesnt exist.
Whats ANSEL? now ADCON1?

and line:
;__CONFIG _CONFIG1, 0x377C & _CCP1_RB3 & _WDT_OFF

Need that fixed lol my code so far from yours is:
Code:
;*** Toy_Car.asm DIP switch UDDUDD + CON4 (RB3, +5, GND)
;*** uses VR1 (RA1) to set PWM (RB3) to control a small toy motor speed

	list    p=18F1320
	include	<p18F1320.inc>
	CONFIG	OSC = INTIO1, WDT = OFF, LVP = OFF, DEBUG = ON
	;__CONFIG _CONFIG1, 0x377C & _CCP1_RB3 & _WDT_OFF
	org 0x000
	movlw 	b'00000100'
	movwf 	T2CON 			;B0 TMR2 on, no prescaler
	movlw 	b'00001100'
	movwf 	CCP1CON 			;B0 CCP1 PWM mode
	movlw 	b'11001001'
	movwf 	ADCON0			;B0 A/D on VR1
	;bsf 	STATUS,RP0 		;B1 change to bank 1
	;movlw 	b'01000010'
	movlw	0x42
	movwf 	OSCCON 			;B1 set the oscillator to 1 MHz

	movlw 	b'00000000'
	movwf 	ADCON1
	;movwf 	ANSEL 			;B1 PORTA,1 (VR1) analog input
	movlw 	b'11110111'
	movwf 	TRISB 			;B1 RB3 Output (PWM)
	movlw 	.250 			;1KHz (osc /4 /250)
	movwf 	PR2 			;B1 set PWM frequency to 1 KHz
	;*** read VR1 and moves result to PWM duty register
main					;bcf STATUS,RP0 ;B0 change to bank 0
	bsf 	ADCON0,GO 			;B0 begin A/D conversion (VR1)
addone 	btfss 	ADCON0,GO 		;B0 A/D done yet?
	goto 	addone 			;loop till A/D done
	movff 	ADRESH, WREG 			;B0 W = A/D high byte
	movwf 	CCPR1L 			;B0 set duty cycle to A/D result
	goto 	main 			; * any A/D result > 250 will = 100% PWM *
	END

Blinks but way to fast to really notice
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top