Monday, February 6, 2017

ANTICOLLISION STEPS IN NFC ISO14443B

Anticollison Steps in ISO 14443B
o   ISO 14443B (TYPE 2), has two main components reader (PCD) and tag (PICC).
o   At first PCD uses the anti-collision sequence for checking for multiple PICCs.
o   Steps
§  PCD sends REQB command with N where N is number slots defined for anti collision.
§  PICC receives REQB and check for N

  • If N is 1 then returns ATQB (Answer to Request type B)
  • If N is greater than 1  then random number R is generated
  • If R is 1 then sends ATQB
  • If R is not 1 then it wait until slot marker sent by PCD is matched

SIGNALLING IN NFC ISO 14443B
o   Uses the frequency of 13.56MHz as major carrier.
o   Sub carrier if 847.5 KHz is used for carrying data.
o   Signal from PICC to PCD is load modulated and used different signaling than from PCD to PICC.

PCD to PICC signaling
o   Uses 10%(8 to 14% practically) amplitude modulation index, ie there is always a presence of 13.56MHz carrier
o   Uses the NRZ encoding for the data
o   The signal generated from the smart phone as captured shows modulation index of 15%
o   Uses BPSK (Binary Phase Shift Keying) modulation
o   Encoding is NRZ-L for the data.
o   Each of the bit is 8 sub carrier period long.

Wednesday, January 11, 2017

SOFTWARE BASED UART ON ANY CONTROLLER

UART are very easy way for communication in electronics, it is used mostly in any where. UART are available in any micro controllers and very easy to use and understand. 
Sometimes in some controllers we may required some extra UART than available in hardware, in such case we can use software based UART. The details of USART communication is out of scope of this post. 

The code is running on MSP430FR5969, the device is running on 4 MHz DCO. The following code do not utilized any kind of interrupt and strictly depended on polling. While receiving the data, it uses while statement for the start bit. But this code be easily be made efficient using techniques like interrupts and also using PT thread technique. This just gives a basic implementation for the newbies.

The setup is as


Here macros are used for making the code simpler, following are the snippets of the functions.

#define settxoutput P1DIR |= BIT4  //SET AS TX OUTPUT PORT 1 BIT 4
#define highontx P1OUT |= BIT4 //SET OUTPUT HIGH ON TX
#define setlowontx P1OUT &= ~BIT4 //SET OUTPUT LOW ON TX

#define setrxinput P1DIR &= ~BIT3 //SET AS RX INPUT PORT 1 BIT 3
#define isrxhigh P1IN&BIT3

#define baudrate 9600
#define Bittime 4000000/baudrate // one bit time in uS
#define bittime Bittime - 40
#define rbittime Bittime - 40

void tx8_uart(unsigned char data8){
unsigned char i;
setlowontx;
__delay_cycles(bittime); //since frequency of operation is 1mhz its 1us
for( i = 0;i < 8 ; i++){
if( ( (data8>>i) & 0x01) == 0x01 )
highontx;
else
setlowontx;
__delay_cycles(bittime);
}
highontx;
__delay_cycles(bittime);
}


unsigned char  rx8_uart(){
unsigned char data8=0;
int i;

while(isrxhigh); //start bit is 0

__delay_cycles(rbittime);
__delay_cycles(rbittime/2);//taking sample at mid time

for( i = 0;i<8;i++){
if( /*i%2 == 0*/ isrxhigh ){
data8 += (1<<i);
//P1OUT |= BIT7;
}
else{
data8 = data8;
// P1OUT &= ~BIT7;
}
__delay_cycles(rbittime);
}

if( isrxhigh ){
__delay_cycles(rbittime/2);
return data8;
}else{
__delay_cycles(rbittime/2);
return 0x00;
}
}

Monday, July 25, 2016

P10 LED MATRIX BOARD DISPLAY

Here in this project I have used 12 P10 led matrix board in array of 4 horizontal and 3 vertical ie 4 columns and 3 row.
All displays are cascaded ,while last one become the origin or 0,0.

You need a long flat cable of 16 pin connector for connecting the display on different line as suggested in the figure.
I have used the DMD library by freetronics.
First I have planned to display time temperature one the first line, display two messages scrolling in line two and three.
I have used LM35 as temperature sensor which gives 10mV per degree change in celsius scale and used 1.1V as ADC reference for maximum resolution. 
DS1307 as RTC with IIC interface, but the problem is whenever is use DMD with IIC, I dont know why the time value of RTC is not stable its always changing like it gives right time for 3 or 5 times and then 165 165 and 85. May be due to some conflict on resources couldnt really figure out.
Solve this problem using two controller using one as just display drivers and second sending all data of temperature, time, font, writing message , reading message and saving message and controlling the speed of the message scroll.
Here's the link to the code final code https://github.com/kieran-shrestha/led_notice_board

Saturday, July 9, 2016

INTERFACING ADC OF AVR MICROCONTROLLER

The following is the code for using the internal 10 bit ADC of AVR microcontroller.
The code is written for ATMEGA328 with system clock of 16MHZ.
The code uses standard c header files for using printf function and then print the content in serial uart of the microcontroller.

Sunday, June 26, 2016

ATMEGA328P UART0

CONNECTION CONNECT RX AND TX TO TX AND RX OF OTHER DEVICE

//This define the system frequency
#define F_CPU 16000000UL

//Including the required files
#include <avr/io.h>
#include <util/delay.h>

Sunday, June 12, 2016

LCD INTERFACING 8 BIT MODE

Circuit connection is 
RS => PB0
RW => PB1
EN => PB2
D0-D3 =>PORTD 0 TO 3
D4-D7 => PORTC 0 TO 3

READING A GPIO

Circuit diagram includes using PORTB5 as output to toggle a LED and PORTC5 for input with button connected to ground.