Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 9th May 2008, 03:13 PM   (permalink)
Experienced Member
 
AtomSoft is just really niceAtomSoft is just really niceAtomSoft is just really niceAtomSoft is just really nice
Send a message via MSN to AtomSoft Send a message via Skype™ to AtomSoft
Default

i guess i should have known that by now lol ive seen it so many places lol thanks alot. Ill move the commands down from 5 so 4 and 3 would be next :
Code:
SW1	Equ	7			;set constants for the switches
SW2	Equ	6
SW3	Equ	4
SW4	Equ	3
__________________
My YouTube Videos!

AtomSoft Live
AtomSoft is online now   Reply With Quote
Old 9th May 2008, 03:46 PM   (permalink)
Experienced Member
 
ericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to behold
Default

Quote:
Originally Posted by AtomSoft
i guess i should have known that by now lol ive seen it so many places lol thanks alot. Ill move the commands down from 5 so 4 and 3 would be next :
Code:
SW1	Equ	7			;set constants for the switches
SW2	Equ	6
SW3	Equ	4
SW4	Equ	3
hi atom,
Lets know how you get on with the PIC Sim, if you have any questions about it, please ask..
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/
ericgibbs is online now   Reply With Quote
Old 9th May 2008, 05:22 PM   (permalink)
Experienced Member
 
AtomSoft is just really niceAtomSoft is just really niceAtomSoft is just really niceAtomSoft is just really nice
Send a message via MSN to AtomSoft Send a message via Skype™ to AtomSoft
Default

This is my code so far i will post schematics in a minute, Im having so many issues with this in MPLAB SIM... For some reason PORTA wont set HIGH and well just so many issues from that alone...

Code:
;Tutorial 5.2 - Nigel Goodwin 2002
;Sony SIRC IR transmitter
	LIST	p=18F1320		;tell assembler what chip we are using
	include	<p18F1320.inc>		;include the defaults for the chip
	CONFIG	OSC = INTIO1, WDT = OFF, LVP = OFF, DEBUG = ON		;sets the configuration settings (oscillator type etc.)

	cblock 	0x20 			;start of general purpose registers
		count1 			;used in delay routine
		counta 			;used in delay routine 
		countb
		count
		Delay_Count
		Bit_Cntr
		Data_Byte
		Dev_Byte
		Rcv_Byte
		Pulse
	endc
	

IR_PORT	Equ	PORTB
IR_TRIS	Equ	TRISB
IR_Out	Equ	0x01
Ser_Out	Equ	0x01
SW1	Equ	7			;set constants for the switches
SW2	Equ	6
SW3	Equ	4

TV_ID		Equ	0x01			;TV device ID

But1		Equ	0x00			;numeric button ID's
But2		Equ	0x01
But3		Equ	0x02

		org	0x00
Start
		movlw	0x62			; 4MHz clock select
    	movwf	OSCCON
		clrf	IR_PORT			;make PortB outputs low
 
   		movlw 	b'11111101'		;set PortB all inputs, except RB1
   		movwf 	IR_TRIS
		movlw 	b'11111111'
	    movwf	TRISA
		movlw 	b'11111111'
		movwf	PORTA

Read_Sw
		btfss	PORTA, SW1
		call	Switch1
		btfss	PORTA, SW2
		call	Switch2
		btfss	PORTA, SW3
		call	Switch3
		;call	Delay27
		goto	Read_Sw

Switch1		movlw	But1
		call	Xmit_RS232
		retlw	0x00

Switch2		movlw	But2
		call	Xmit_RS232
		retlw	0x00

Switch3		movlw	But3
		call	Xmit_RS232
		retlw	0x00

TX_Start	movlw	d'92'
		call	IR_pulse
		movlw	d'23'
		call	NO_pulse
		retlw	0x00

TX_One		movlw	d'46'
		call	IR_pulse
		movlw	d'23'
		call	NO_pulse
		retlw	0x00

TX_Zero		movlw	d'23'
		call	IR_pulse
		movlw	d'23'
		call	NO_pulse
		retlw	0x00

IR_pulse			 	
		MOVWF	count		;  Pulses the IR led at 38KHz
irloop		BSF	IR_PORT,	IR_Out 
		NOP			;
		NOP			;
		NOP			;
		NOP			; 
		NOP			;
		NOP			;
		NOP			;
		BCF	IR_PORT,	IR_Out
		NOP			;
		NOP			;
		NOP			;
		NOP			;
		NOP			;
		NOP			;	
		NOP			;
		NOP			;	
		NOP			;
		NOP			;
		NOP
		NOP
		NOP			;
		NOP			;
		DECFSZ	count,F
		GOTO 	irloop	
		RETLW	0

NO_pulse			 	
		MOVWF	count		;  Doesn't pulse the IR led
irloop2		BCF	IR_PORT,	IR_Out 
		NOP			;
		NOP			;
		NOP			;
		NOP			;
		NOP			;
		NOP			;
		NOP			;
		NOP			; 
		NOP			;
		NOP			;
		NOP			;
		BCF	IR_PORT,	IR_Out
		NOP			;
		NOP			;	
		NOP			;
		NOP			;	
		NOP			;
		NOP			;
		NOP
		NOP
		NOP			;
		NOP			;
		DECFSZ	count,F
		GOTO 	irloop2	
		RETLW	0

Xmit_RS232      MOVWF   Data_Byte            	;move W to Data_Byte
                MOVLW   0x07                 	;set 7 DATA bits out
                MOVWF   Bit_Cntr
                call	TX_Start		;send start bit
Ser_Loop        RRCF     Data_Byte , f        	;send one bit
                BTFSC   STATUS    , C
                call	TX_One
                BTFSS   STATUS    , C
                call	TX_Zero
                DECFSZ  Bit_Cntr  , f        	;test if all done
                GOTO    Ser_Loop
						;now send device data
		movlw	D'1'
		movwf	Dev_Byte		;set device to TV
		MOVLW   0x05                 	;set 5 device bits out
                MOVWF   Bit_Cntr
Ser_Loop2       RRCF     Dev_Byte , f        	;send one bit
                BTFSC   STATUS    , C
                call	TX_One
                BTFSS   STATUS    , C
                call	TX_Zero
                DECFSZ  Bit_Cntr  , f        	;test if all done
                GOTO    Ser_Loop2
                retlw	0x00



;Delay routines

Delay255	movlw	0xff		;delay 255 mS
		goto	d0
Delay100	movlw	d'100'		;delay 100mS
		goto	d0
Delay50		movlw	d'50'		;delay 50mS
		goto	d0
Delay27		movlw	d'27'		;delay 27mS
		goto	d0
Delay20		movlw	d'20'		;delay 20mS
		goto	d0
Delay5		movlw	0x05		;delay 5.000 ms (4 MHz clock)
d0		movwf	count1
d1		movlw	0xC7
		movwf	counta
		movlw	0x01
		movwf	countb
Delay_0		decfsz	counta, f
		goto	$+2
		decfsz	countb, f
		goto	Delay_0

		decfsz	count1	,f
		goto	d1
		retlw	0x00

;end of Delay routines

	end
__________________
My YouTube Videos!

AtomSoft Live
AtomSoft is online now   Reply With Quote
Old 9th May 2008, 06:17 PM   (permalink)
Experienced Member
 
AtomSoft is just really niceAtomSoft is just really niceAtomSoft is just really niceAtomSoft is just really nice
Send a message via MSN to AtomSoft Send a message via Skype™ to AtomSoft
Default

__________________
My YouTube Videos!

AtomSoft Live
AtomSoft is online now   Reply With Quote
Old 9th May 2008, 06:34 PM   (permalink)
Experienced Member
 
ericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to behold
Default

hi atom,
What baud rate is the IR being transmitted at.?
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/
ericgibbs is online now   Reply With Quote
Old 9th May 2008, 06:48 PM   (permalink)
Experienced Member
 
AtomSoft is just really niceAtomSoft is just really niceAtomSoft is just really niceAtomSoft is just really nice
Send a message via MSN to AtomSoft Send a message via Skype™ to AtomSoft
Default

i know nothing on baud rate lol im just trying to alter this code to work on my 18F1320. Its Nigels original code. I dont understand it 100% But i know some PIC ASM and can read a datasheet so i though ill give it a shot
__________________
My YouTube Videos!

AtomSoft Live
AtomSoft is online now   Reply With Quote
Old 9th May 2008, 06:52 PM   (permalink)
Experienced Member
 
ericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to behold
Default

Quote:
Originally Posted by AtomSoft
i know nothing on baud rate lol im just trying to alter this code to work on my 18F1320. Its Nigels original code. I dont understand it 100% But i know some PIC ASM and can read a datasheet so i though ill give it a shot
hi,
Reason for asking, I was using the software uart on the oshonsoft sim, it detects the individual bits in the stream, but it 'hic cups' on the 'stop' bit.?

The switches are being detected correctly and its going into the required SW subr and then returning to the SW scan/test. OK
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/
ericgibbs is online now   Reply With Quote
Old 9th May 2008, 08:09 PM   (permalink)
Experienced Member
 
AtomSoft is just really niceAtomSoft is just really niceAtomSoft is just really niceAtomSoft is just really nice
Send a message via MSN to AtomSoft Send a message via Skype™ to AtomSoft
Default

changed config EDITED:
Code:
OSC = INTIO2
__________________
My YouTube Videos!

AtomSoft Live
AtomSoft is online now   Reply With Quote
Old 9th May 2008, 08:44 PM   (permalink)
Experienced Member
 
AtomSoft is just really niceAtomSoft is just really niceAtomSoft is just really niceAtomSoft is just really nice
Send a message via MSN to AtomSoft Send a message via Skype™ to AtomSoft
Default

ok works now yay!
Code:
;Tutorial 5.2 - Nigel Goodwin 2002
;Sony SIRC IR transmitter
	LIST	p=18F1320		;tell assembler what chip we are using
	include	<p18F1320.inc>		;include the defaults for the chip
	CONFIG	OSC = INTIO2, WDT = OFF, LVP = OFF, DEBUG = ON		;sets the configuration settings (oscillator type etc.)

	cblock 	0x00 			;start of general purpose registers
		count1 			;used in delay routine
		counta 			;used in delay routine 
		countb
		count
		Delay_Count
		Bit_Cntr
		Data_Byte
		Dev_Byte
		Rcv_Byte
		Pulse
	endc
	

IR_PORT	Equ	PORTB
IR_TRIS	Equ	TRISB
IR_Out	Equ	0x01
Ser_Out	Equ	0x01
SW1	Equ	7			;set constants for the switches
SW2	Equ	6
SW3	Equ	4

TV_ID		Equ	0x01			;TV device ID

But1		Equ	0x00			;numeric button ID's
But2		Equ	0x01
But3		Equ	0x02

		org	0x00
Start
		movlw	0x62			; 4MHz clock select
    	movwf	OSCCON
		clrf	IR_PORT			;make PortB outputs low
 
   		movlw 	b'11111101'		;set PortB all inputs, except RB1
   		movwf 	IR_TRIS
		movlw 	b'11111111'
	    movwf	TRISA
		movwf	LATA
		movlw 	b'11110000'
		movwf	PORTA

Read_Sw
		btfss	PORTA, SW1
		call	Switch1
		btfss	PORTA, SW2
		call	Switch2
		btfss	PORTA, SW3
		call	Switch3
		;call	Delay27
		goto	Read_Sw

Switch1	movlw	But1
		call	Xmit_RS232
		retlw	0x00

Switch2	movlw	But2
		call	Xmit_RS232
		retlw	0x00

Switch3	movlw	But3
		call	Xmit_RS232
		retlw	0x00

TX_Start	movlw	d'92'
		call	IR_pulse
		movlw	d'23'
		call	NO_pulse
		retlw	0x00

TX_One		movlw	d'46'
		call	IR_pulse
		movlw	d'23'
		call	NO_pulse
		retlw	0x00

TX_Zero		movlw	d'23'
		call	IR_pulse
		movlw	d'23'
		call	NO_pulse
		retlw	0x00

IR_pulse			 	
		MOVWF	count		;  Pulses the IR led at 38KHz
irloop	BSF	IR_PORT,	IR_Out 
		NOP			;
		NOP			;
		NOP			;
		NOP			; 
		NOP			;
		NOP			;
		NOP			;
		BCF	IR_PORT,	IR_Out
		NOP			;
		NOP			;
		NOP			;
		NOP			;
		NOP			;
		NOP			;	
		NOP			;
		NOP			;	
		NOP			;
		NOP			;
		NOP
		NOP
		NOP			;
		NOP			;
		DECFSZ	count,F
		GOTO 	irloop	
		RETLW	0

NO_pulse			 	
		MOVWF	count		;  Doesn't pulse the IR led
irloop2		BCF	IR_PORT,	IR_Out 
		NOP			;
		NOP			;
		NOP			;
		NOP			;
		NOP			;
		NOP			;
		NOP			;
		NOP			; 
		NOP			;
		NOP			;
		NOP			;
		BCF	IR_PORT,	IR_Out
		NOP			;
		NOP			;	
		NOP			;
		NOP			;	
		NOP			;
		NOP			;
		NOP
		NOP
		NOP			;
		NOP			;
		DECFSZ	count,F
		GOTO 	irloop2	
		RETLW	0

Xmit_RS232      MOVWF   Data_Byte            	;move W to Data_Byte
                MOVLW   0x07                 	;set 7 DATA bits out
                MOVWF   Bit_Cntr
                call	TX_Start		;send start bit
Ser_Loop        RRCF     Data_Byte , f        	;send one bit
                BTFSC   STATUS    , C
                call	TX_One
                BTFSS   STATUS    , C
                call	TX_Zero
                DECFSZ  Bit_Cntr  , f        	;test if all done
                GOTO    Ser_Loop
						;now send device data
		movlw	D'1'
		movwf	Dev_Byte		;set device to TV
		MOVLW   0x05                 	;set 5 device bits out
                MOVWF   Bit_Cntr
Ser_Loop2       RRCF     Dev_Byte , f        	;send one bit
                BTFSC   STATUS    , C
                call	TX_One
                BTFSS   STATUS    , C
                call	TX_Zero
                DECFSZ  Bit_Cntr  , f        	;test if all done
                GOTO    Ser_Loop2
                retlw	0x00



;Delay routines

Delay255	movlw	0xff		;delay 255 mS
		goto	d0
Delay100	movlw	d'100'		;delay 100mS
		goto	d0
Delay50		movlw	d'50'		;delay 50mS
		goto	d0
Delay27		movlw	d'27'		;delay 27mS
		goto	d0
Delay20		movlw	d'20'		;delay 20mS
		goto	d0
Delay5		movlw	0x05		;delay 5.000 ms (4 MHz clock)
d0		movwf	count1
d1		movlw	0xC7
		movwf	counta
		movlw	0x01
		movwf	countb
Delay_0		decfsz	counta, f
		goto	$+2
		decfsz	countb, f
		goto	Delay_0

		decfsz	count1	,f
		goto	d1
		retlw	0x00

;end of Delay routines

	end
had to remove a 4.7k resistor from base of transistor..Will post schematic now..1 min
__________________
My YouTube Videos!

AtomSoft Live
AtomSoft is online now   Reply With Quote
Old 9th May 2008, 08:48 PM   (permalink)
Experienced Member
 
AtomSoft is just really niceAtomSoft is just really niceAtomSoft is just really niceAtomSoft is just really nice
Send a message via MSN to AtomSoft Send a message via Skype™ to AtomSoft
Default

schematic:
__________________
My YouTube Videos!

AtomSoft Live
AtomSoft is online now   Reply With Quote
Old 9th May 2008, 09:02 PM   (permalink)
Experienced Member
 
Blog Entries: 4
blueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to behold
Send a message via Skype™ to blueroomelectronics
Default

Should R6 be 47ohms? 4.7K seems very high. You can pump a fair amount of current through an IR LED.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is offline   Reply With Quote
Old 9th May 2008, 09:06 PM   (permalink)
Super Moderator
 
Nigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to behold
Default

Quote:
Originally Posted by blueroomelectronics
Should R6 be 47ohms? 4.7K seems very high. You can pump a fair amount of current through an IR LED.
Or even 4.7 ohms?, I would suggest using two LED's in series (twice the power for no extra current), and check the value of resistor in my tutorial.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline   Reply With Quote
Old 9th May 2008, 10:33 PM   (permalink)
Experienced Member
 
AtomSoft is just really niceAtomSoft is just really niceAtomSoft is just really niceAtomSoft is just really nice
Send a message via MSN to AtomSoft Send a message via Skype™ to AtomSoft
Default

im going to try 47 ohms now
__________________
My YouTube Videos!

AtomSoft Live
AtomSoft is online now   Reply With Quote
Old 9th May 2008, 10:57 PM   (permalink)
Experienced Member
 
AtomSoft is just really niceAtomSoft is just really niceAtomSoft is just really niceAtomSoft is just really nice
Send a message via MSN to AtomSoft Send a message via Skype™ to AtomSoft
Default

dude you know you forgot to fix this:

Code:
						;now send device data
movlw	D'16';	D'1'
movwf	Dev_Byte		;set device to TV
Mines is like:
Code:
						;now send device data
;movlw	D'16';	D'1'
movff	TV_ID, Dev_Byte ;Load Preset Device #
;movwf	Dev_Byte		;set device to TV
Just noticed still isnt good like that i have to put a Decimal 16 like
D'16' for mines lol
__________________
My YouTube Videos!

AtomSoft Live

Last edited by AtomSoft; 9th May 2008 at 11:03 PM.
AtomSoft is online now   Reply With Quote
Old 9th May 2008, 11:48 PM   (permalink)
Experienced Member
 
AtomSoft is just really niceAtomSoft is just really niceAtomSoft is just really niceAtomSoft is just really nice
Send a message via MSN to AtomSoft Send a message via Skype™ to AtomSoft
Default

Quote:
Originally Posted by Nigel Goodwin
Or even 4.7 ohms?, I would suggest using two LED's in series (twice the power for no extra current), and check the value of resistor in my tutorial.
I currently Have 1 in stock so i will be sure to make the schematic for 2 and add the other when i get to goto my radio shack
__________________
My YouTube Videos!

AtomSoft Live
AtomSoft is online now   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
Capacitor Charge/Discharge question ThermalRunaway General Electronics Chat 23 1st June 2007 01:20 PM
Basic Transmission question CamNuge General Electronics Chat 2 8th March 2006 10:08 PM
Question about bank selection, 16F628A, Nigel's tutorial kcn Micro Controllers 4 13th March 2005 06:23 AM
a question about nigel's tutorial jijita Micro Controllers 3 2nd July 2004 09:03 PM
PBX question waqar Electronic Projects Design/Ideas/Reviews 0 30th March 2003 06:21 PM



All times are GMT. The time now is 06:02 PM.


Electronic Circuits  |  Radio Controlled
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.