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.

RFID TAG ID Output from 16f628

Status
Not open for further replies.

Larynx1

New Member
Hello everyone,

I am quite new to PIC's, so please bear with me.

What I am trying to do is this.

I can read an RFID token 125Khz EM4100 and see the ID using an ID12, into notepad.

What I want to do is output a data string from say, PortA bit 0 on 16f628 ie emulate a token.

I will then feed this into a door controller's signal input.

My PIC needs to run at 4Mhz

Any help will be greatly appreciated.
 
I have been looking at Nigel's excellent tutorials and was wondering if some one could give me some help in inserting the following data from the EM4100 protocol into Nigel's tutorial on Manchester encoding.

111111111 <- Header
00011 00011 <- Manufacturer ID
00011 00011 00011 00011 <- Serial number
00011 00011 00011 00011
11110 <- parity column and stop bit

Loop
movlw 0xAA ;set packet address byte to 0xAA
movwf mtx_buffer
movlw 'N'
movwf mtx_buffer1
call mtx_send
call Delay20
movlw 'i'
movwf mtx_buffer1
call mtx_send
call Delay20
movlw 'g'
movwf mtx_buffer1
call mtx_send
call Delay20
movlw 'e'
movwf mtx_buffer1
call mtx_send
call Delay20
movlw 'l'
movwf mtx_buffer1
call mtx_send
call Delay20
movlw ' '
movwf mtx_buffer1
call mtx_send
call Delay20
goto Loop

Help would be gratefully received, thanks in advance.
 
You'll need to add Index and Times to your cblock;

Code:
	cblock 	0x20 			;start of general purpose registers

		ncnt
		bt
		sum
		mtx_buffer
		mtx_buffer1
		mtx_delay		; half_frame delay

		count1			;used in delay routine
		count2
		counta			;used in delay routine
		countb			;used in delay routine
		
		Times	;<---- Added
		Index	;<---- Added
		
	endc

Then replace most of the loop with this;
Code:
Loop
		movlw	0xAA			;set packet address byte to 0xAA
		movwf 	mtx_buffer
;----------------------------------------------	
Send_string
		
		CLRF	Index
		movlw	0x40	;64 bits to send
		movwf 	Times	;64 items to read from the data table.
	
Send_string1
		Movf	Index	,w	;Location of where to read data table
		Call	Data_Table
		addlw	0x30	; Add 30 to convert to Ascii
		movwf 	mtx_buffer1
		call	mtx_send
		call	Delay20
		INCF 	INDEX,	F	;Next bit to read
		decfsz  Times,	F	;After displaying 64 bits (0x40), exit.
		Goto	Send_string1
		
stop	goto	stop	;Loop here forever.
		
;--------------------------------------------------------------------		
Data_Table
	ADDWF   PCL, f
	DT	0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01 		;<- Header (9)
	DT	0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x01,0x01	;<- Manufacturer ID (10)
	DT	0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x01,0x01	;<- Serial number (20)
	DT	0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x01,0x01	
	DT	0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x01,0x01	;<- Serial number (20)	
	DT	0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x01,0x01	
	DT	0x01,0x01,0x01,0x01,0x00 				;<- parity column and stop bit (5)
													;	64 bits in total (0x40)
;--------------------------------------------------------------------
;Manchester subroutines

View attachment 68428
 
Last edited:
Thank you very much HouseOfwax,

I have assembled the code with only 1 error, I needed to change the case of "INDEX"

Do I need to change anything in Nigel's code regarding the packet length?
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top