![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
fkl
Joined: 20 Nov 2010 Posts: 44
|
rfid: em4095 + pic |
Posted: Sat Nov 20, 2010 5:50 am |
|
|
Can not figure out how to work with the em4095.
Prompt, can have a ready code (preferably for pic18f14k50) to work with the em4095.
p.s.
I apologize for my English |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9176 Location: Greensville,Ontario
|
|
Posted: Sat Nov 20, 2010 3:33 pm |
|
|
I would suggest buying a premade 'module' and start with that if you already don't have one. It will be far easier to debug and test. |
|
![](templates/subSilver/images/spacer.gif) |
fkl
Joined: 20 Nov 2010 Posts: 44
|
|
Posted: Sat Nov 20, 2010 11:07 pm |
|
|
temtronic wrote: | I would suggest buying a premade 'module' and start with that if you already don't have one. It will be far easier to debug and test. |
I have this one http://www.mikroe.com/eng/products/view/185/rfid-reader-board.
But there is no code for ccs.
Use pic18f14k50. |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9176 Location: Greensville,Ontario
|
|
Posted: Sun Nov 21, 2010 6:39 am |
|
|
I just downloaded all the C code from the modules website.
It's not that difficult to convert into CCS C code.
Most of it is 'cut and paste', the rest just needs to be thought out.
Heck, it's all high level stuff, in the same language. Try converting z80 assembler to 68HC11 one day !
If you do the work, you'll have a better appreciation for the time and effort that goes into cutting code.
I don't use the 18 series of PICs, nor do I have one of those readers so I can't help in conversion but having done similar tasks before. I'd figure a long weekend and a couple pots of coffee will complete the task.
Also, once you convert that code, any other application that you find on that site will be easier in the future!
Heck, at $25 per board, it's a great deal less than 15 minutes of my R&D cost. |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9176 Location: Greensville,Ontario
|
|
Posted: Mon Nov 22, 2010 10:04 am |
|
|
Just checked and ...
In version 4.064,in the drivers folder, there is a EM4095.c driver for that
rfid chip ! |
|
![](templates/subSilver/images/spacer.gif) |
fkl
Joined: 20 Nov 2010 Posts: 44
|
|
Posted: Mon Nov 22, 2010 10:24 am |
|
|
temtronic wrote: | Just checked and ...
In version 4.064,in the drivers folder, there is a EM4095.c driver for that
rfid chip !
|
not work
main.c
Code: |
#include <18F14K50.h>
//#fuses XT,NOWDT,NOPROTECT,NOLVP,NOBROWNOUT,PUT,CCPB3,NOMCLR
#FUSES NOWDT //c сторожевого таймера
//#FUSES WDT4096 //16,384c //Делитель сторожевого таймера 1:128
#FUSES HS //Высокоскоростной кварц (выше 4 МГц)
#FUSES NOFCMEN //Fail-safe clock monitor disabled
#FUSES BROWNOUT //Сброс при опасном снижении напряжения питания
#FUSES BORV19
#FUSES PUT //Таймер задержки включения питания
#FUSES NOCPD //No EE protection
#FUSES STVREN //Перезагружать МК при переполнении стека
//#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES NOWRT //Память программ не защищена от записи
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES NOWRTC //configuration not registers write protected
#FUSES IESO //Внутренний регулятор питания включен
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOPROTECT //Code not protected from reading+++++++++++++++++++++++++++++++
#FUSES NOCPB //No Boot Block code protection
#FUSES NOWRTB //Boot block not write protected
#FUSES NOLVP //Режим низковольтного программирования отключен
#FUSES NOHFOFST
#FUSES NOWRT0
#FUSES NOWRT1
#FUSES USBDIV1
#FUSES PCLKEN
#FUSES BBSIZ2K //2K words Boot Block size
#FUSES PLLEN
#FUSES CPUDIV1 //No System Clock Postscaler
#use delay(clock=12000000)
// Purpose: Powers down the RF antenna
#define rf_mod_off() output_low(RF_MOD);
// Purpose: Powers up the RF antenna
#define rf_mod_on() output_high(RF_MOD);
#define RF_RDY_CLK PIN_C7 // External interrupt used to read clock
#define RF_SHD PIN_B6 // High disables the antenna signal
#define RF_MOD PIN_B7 // High does 100% modulation
#define RF_DEMOD_OUT PIN_C5 // Data read in interrupt service routine
#define GrinLED PIN_B5
#include "em4095.c"
#include "em4102.c"
#include <usb_cdc.h>
#include <string.h>
int8 code[5];
int8 msg[32];
void main(void)
{
setup_adc_ports(NO_ANALOGS);
setup_comparator(NC_NC_NC);
rf_mod_off();
int8 wrong_attemps;
int32 tagNum;
int8 customerCode;
delay_ms(3000);
output_high(GrinLED);
delay_ms(3000);
output_low(GrinLED);
delay_ms(3000);
rf_powerDown();
usb_cdc_init();
usb_init();
output_high(GrinLED);
delay_ms(3000);
output_low(GrinLED);
delay_ms(3000);
rf_init(); //initialization
rf_powerUp();
output_high(GrinLED);
delay_ms(3000);
output_low(GrinLED);
delay_ms(3000);
/////////////////////////////////////////////////////////////////
printf(usb_cdc_putc,"Ready...\n\r");
while(1)
{
if(read_4102(code)) //read the code
{
output_high(GrinLED);
tagNum = make32(code[1],code[2],code[3],code[4]);
customerCode = code[0];
sprintf(msg,"\r\nScanned ID: %u-%lu",customerCode,tagNum);
printf(usb_cdc_putc,msg);
sprintf(msg,"( [%u][%u]",code[0],code[1]);
printf(usb_cdc_putc,msg);
sprintf(msg,"[%u][%u][%u] )",code[2],code[3],code[4]);
printf(usb_cdc_putc,msg);
}
}
}
|
em4095.c
Code: |
/////////////////////////////////////////////////////////////////////////
//// em4095.c ////
//// This file contains drivers for a EM4095 RFID basestation. ////
//// ////
/////////////////////////////////////////////////////////////////////////
|
++++++++++++++++++++++++++
Code deleted.
Reason: Forum Rule #10
10. Don't post the CCS example code or drivers, or ask for such code and drivers.
Forum Rules:
http://www.ccsinfo.com/forum/viewtopic.php?t=26245
-- Forum Moderator
++++++++++++++++++++++++++ |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9176 Location: Greensville,Ontario
|
|
Posted: Mon Nov 22, 2010 12:15 pm |
|
|
First I would simplify your program by deleting all the USB code unless you are 100% confident that it CANNOT interfere with the RFID driver.
Cut code to 'flash' your green LED at different rates during the program. Reach a critical step, flash once, next critical step, flash twice, etc. So you know WHERE the program fails.
Second, look at the pins you use for the RFID and check to be sure that onboard PIC peripherals are NOT in conflict.
Third, there is a specific setup/timing related to the RFID chip, be sure to check those codes.
Fourth, Try another PIC ? You may have miswired the current setup, damaging an I/O pin, so recheck all wiring.
I don't use the 18 series of PICs but it's easy to miss a multipurpose I/O pin default configuration, especially with the more powerful PICs! |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|