Monday, February 22, 2016

Latch and Flip flop difference

Flip flops are used to store informaion

Category:
  1. Asynchronous/Transparent flipflops (Latch)
  2. Synchronous fliplfops
Types:
  1. SR (Set Reset)
  2. D (Data or delay)
  3. T (Toggle)
  4. JK
Underneath hardware:
  1. NOR based (eg. SR latch)
  2. NAND based (eg. SR' latch)
Methods of describing
  • Characteristic table / Truth table
R
S
Q(next)
Action
0
0
Q
Hold state
0
1
1
Set
1
0
0
Reset
1
1
0
Not allowed as Q = Q’ = 0

  • Excitation table
Q
R
S
Q(next)
0
x
0
0
0
0
1
1
1
1
0
0
1
0
x
1

Latches and flip-flops are the basic elements for storing information. One latch or flip-flop can store one bit of information. The main difference between latches and flip-flops is that for latches, their outputs are constantly affected by their inputs as long as the enable signal is asserted. In other words, when they are enabled, their content changes immediately when their inputs change. Flip-flops, on the other hand, have their content change only either at the rising or falling edge of the enable signal. This enable signal is usually the controlling clock signal. After the rising or falling edge of the clock, the flip-flop content remains constant even if the input changes.



NOTE:

  1. When the device is latch/Gate we define it by Truth table
  2. When the device is flip-flop we define it by Excitation table
States of output:
  1. HIGH
  2. LOW
  3. No change
  4. Indeterminate
  5. Race around
State of Input:
  1. HIGH
  2. LOW
  3. Don't care


RS flipflop (mostly used as LATCH)

R
S
Q
Q’
Comment
0
0
0
1
No Change
0
1
1
0
Q Change to 1 as ‘S’ is 1 (Set State)
0
0
1
0
No Change
0
0
1
0
No Change
1
0
0
1
Q Change to 0 as ‘R’ is 1 (Reset State)
0
0
0
1
No change
1
1
0
0
Not allowed. In this state Q = Q’
0
0
?
?
If both R and S change from 11 to 00 then its indeterminate state

SR flipflop is the basic building block for computer memories

D-flipflop (mostly used as LATCH)
Major drawback of SR latch (indeterminate state and Not allowed state) are overcome by D-flipflop
D-Type-edge-trig-symbol.gif
D is a synchronous input
S' and R' are asynchronous inputs

JK-flipflop (mostly a flipflop +ve edged or -ve edged)
JK-MS-symbol.giftable-5-4-1.gif


J
K
Q(next)
Q’(next)
Action
0
0
Q
Q
Hold state
0
1
J
K
J
1
0
J
K
K
1
1
Q’
Q
Toggle

Sunday, February 7, 2016

CAN protocol information


  • CAN control area network
  • Introduced by "Robert Bosch"
  • It has 3 layers of OSI model:
    • Physical layer (CAN Transceiver SN65HVD233)
    • Data link layer (CAN Controller MCP2515)
    • Application layer (Higher level protocols are implemented
Specifications:

ISO 11898
Specification is related to only following two layers
  1. Physical layer
  2. Data link layer
Physical connection:
2 wire interface
uC <---SPI 4---> CAN controller <---Tx & Rx ---> CAN Transceiver <--CANH & CANL
two 120ohm termination resistors are connected on the basis of transmission line theory.

CAN packet description:
  • Standard
SOF(1) + ID(11) + RTR(1) + IDE(1) + RB0(1) + DLC(4) + DataFrame(8*n where 0<=n<=8) +  CRC(15) + CRCdel(1) + ACK slot(1) + ACKdel(1) + EOF(7) + IFS(3)
  • Extended
SOF(1) + ID(11) + SRR(1) + IDE(1) + ID(18) + RTR(1) + RB1(1) + RB0(1) + DLC(4) + DataFrame(8*n where 0<=n<=8) +  CRC(15) + CRCdel(1) + ACK slot(1) + ACKdel(1) + EOF(7) + IFS(3)

Dominant bit = 0 logic
Recessive bit = 1 logic

Bit stuffing - if there are more than 5 consecutive dominant bits then bit stuffing mechanism is used to send a recessive bit so as to maintain the synchronization

CAN frame types:
  1. standard
  2. extended
  3. remote request
  4. errror (active & passive)
    • CRC error
    • acknowledgement error
    • form error
    • bit error
    • stuff error
  5. overload
CANOpen
Its a application layer protocol


  1. Communication profile (CiA DS-301): The communication profile provides the means to configure devices and communication data and defines how data is communicated between devices.
  2. Device profile (CiA DSP-401): 

  • Device profiles add device-specific behavior for (classes of) devices (e.g. digital I/O, analog I/O,  motion controllers, encoders, etc.)
  • Tuesday, February 2, 2016

    Design patterns

    Proper code design has following advantages:

    1. speed up development process by providing tested, proven development paradigms
    2. to prevent major issues in later stage of project
    3. improves code readability for coders familiar with pattern
    4. helps developers to communicate using well known terms
    5. makes the design robust
    Design patterns types:
    1. Creational
      • Class creational pattern (use inheritance effectively)
      • Object creational pattern (use delegation effectively)
    2. Structural
    3. Behavioral

    Monday, February 1, 2016

    Basic concepts when it comes to OOPs...


    "classes and objects" is the base when it comes to OOP
    classes in C++ are very similar to structures in C

    Important points
    1. class members
    2. access modifiers
    3. constructor (eg. classname(){...})
    4. destructor (eg. ~classname(){...})
    5. copy constructor
    6. friend function
    7. inline function
    8. 'this' pointer

    Concepts / Aspects / Features :
    1. Inheritance (parent/base class & child/derived class)
    2. Overloading - (The definition of the function must differ from each other by the types and/or the number of arguments in the argument list. You can not overload function declarations that differ only by return type.)
      • function overloading
      • operator overloading (important aspect of C++)
      • overload resolution
    3. Polymorphism (functions with same name but different data types of input parameters and/or return types)
      • static resolution / static linkage / early binding (the call of the function is being set once by the compiler as the version defined in the base class)
      • Virtual function - keyword 'virtual': (the compiler looks at the contents of the pointer instead of it's type) - dynamic linkage / late binding
        • Pure Virtual Function (eg. virtual int area() = 0; //The = 0 tells the compiler that the function has no body and above virtual function will be called pure virtual function.)
    4. Abstraction
      • interfaces
      • implementations
    5. Encapsulation (public, private, protected)
      • data encapsulation (data hiding)
      • data abstraction
    6. Interfaces
      • abstract class (class with at least one Pure Virtual function.  The purpose of an abstract class is to provide an appropriate base class from which other classes can inherit. Abstract classes cannot be used to instantiate objects and serves only as an interface.  )
    A step further...
    1. namespaces
      • defining namespaces
      • using namespaces
      • Dis-contiguous namespaces
      • Nested namespaces
    2. templates (A template is a blueprint or formula for creating a generic class or a function. The library containers like iterators and algorithms are examples of generic programming and have been developed using template concept.)
      • function template: typename
      • class template: class
    3. dynamic memory
      • new (eg. float *f1 = new float;) - The malloc() function from C, still exists in C++, but it is recommended to avoid using malloc() function. The main advantage of new over malloc() is that new doesn't just allocate memory, it constructs objects which is prime purpose of C++.
      • delete
    4. exception handling
      • try
      • throw
      • catch
    5. files and streaming
      • ofstream - create and write to file
      • ifstream - read information from file
      • fstream - capability of both ofstream and ifstream
      • open()
      • close()
    6. signal  handling
      • signal() - to trap unexpected events
      • raise() - generate signals
    7. multi threading
      • create thread
      • terminate thread
      • passing arguments to thread
      • join thread
      • detach thread

    PROFILE

    My photo
    India
    Design Engineer ( IFM Engineering Private Limited )

    Followers