• 1

    ..

  • 2

    ...

  • 3

    ...

Friday, 30 January 2015

I2C Header File for AVR By Elecdude


/************************************************************************************/

 Author: ElecDude
         admin@elecdude.com        

 Please report bugs, errors, modifications, etc. Thank you

 Copyright - 2015 - ElecDude

 USAGE AND REDISTRIBUTION OF THIS SOURCE CODE IS PERMITTED PROVIDED THAT
 THE FOLLOWING CONDITIONS ARE MET:

    1. REDISTRIBUTIONS OF SOURCE CODE MUST RETAIN THE ABOVE ORIGINAL COPYRIGHT
  NOTICE AND THE ASSOCIATED DISCLAIMER, THIS LIST OF CONDITIONS AND
  THE FOLLOWING DISCLAIMER.
    2. REDISTRIBUTIONS IN BINARY FORM MUST REPRODUCE THE ABOVE COPYRIGHT
  NOTICE, THIS LIST OF CONDITIONS AND THE FOLLOWING DISCLAIMER IN
  THE DOCUMENTATION AND/OR OTHER MATERIALS PROVIDED WITH THE
  DISTRIBUTION.

 THIS IS PROVIDED WITHOUT ANY  EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
 BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 A PARTICULAR PURPOSE ARE DISCLAIMED. TO BE USED FOR LEARNING PURPOSE ONLY.  
 IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT OWNER, BE LIABLE FOR ANY DIRECT,
 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ARISING IN ANY WAY OUT OF THE
 USE OF THIS SOURCE CODE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/*************************************************************************************/
/**************************************************************
 I2C  TWI  ROUTINES
void I2CInit();
void I2CStart();
void I2CStop();
unsigned char I2CWriteSLA(unsigned char sla);
unsigned char I2CWriteByte(unsigned char dat);
unsigned char I2CReadByte(unsigned char *data); */

#ifndef _I2C_H
#define _I2C_H

/*******************MACRO's DEFINITION******************************/
#ifndef BIT
#define BIT(x) _BV(x)
#endif

#ifndef SETBIT
#define SETBIT(x,b) x|=_BV(b);
#endif

#ifndef CLEARBIT
#define CLEARBIT(x,b) x&=~_BV(b);
#endif

#ifndef TOGGLEBIT
#define TOGGLEBIT(x,b) x^=_BV(b);
#endif

#ifndef CHECKBIT
#define CHECKBIT(x,b) (x & _BV(b))
#endif
/*******************************************************************/


#define TRUE 1
#define FALSE 0

void I2CInit()
 {
  TWBR=0x04;//F=100KHz
  TWSR|=((1<<TWPS1) | (1<<TWPS0));

  SETBIT(TWCR,TWEN)
 }

void I2CStart()
{
 TWCR=(1<<TWINT)| (1<<TWSTA)|(1<<TWEN);
 while(!(TWCR & (1<<TWINT)));

}

void I2CStop()
{
 TWCR=(1<<TWINT)| (1<<TWEN)|(1<<TWSTO);
 //while(!(TWCR & (1<<TWSTO)));

}

unsigned char I2CWriteSLA(unsigned char sla)
 {

  TWDR=sla;
  TWCR=(1<<TWEN) | (1<<TWINT);
  while(!(TWCR & (1<<TWINT)));
  if((TWSR & 0xF8)==0x18 || (TWSR & 0xF8)==0x40)
  //18 = SLA+W sent & ACK returned
  return TRUE;//40 = SLA+R sent & ACK returned
  else
    return FALSE;
}

unsigned char I2CWriteByte(uint8_t dat)
 {
  unsigned char
  TWDR=dat;

  TWCR=(1<<TWEN) | (1<<TWINT);
  while(!(TWCR & (1<<TWINT)));


  if((TWSR & 0xF8)==0x28 || (TWSR & 0xF8)==0x30)
  return TRUE; //28= Data sent, ACK returned.  30 data sent, NACK retuned
  else
    return FALSE;
}

unsigned char I2CReadByte(unsigned char *data)
 {
 
  TWCR&=(~(1<<TWEA));
 
  CLEARBIT(TWCR,TWINT)
  while(!(TWCR & (1<<TWINT)));

  if((TWSR & 0xF8)==0x50 || (TWSR & 0xF8)==0x58)
   {
  *data=TWDR; //58 = data READ & NACK retuned
return TRUE; //50 = Data READ & ACK returned
    }
  else
    return FALSE;
}

/***************************************************************************/
#endif
I2C.H

If you enjoyed this post plz let us know your views via comments.
This helps us to do much more better.
Thankyou.


interfacing DS1307 (RTC) with AVR By Elecdude



//***********************************************************************************//
 Author: ElecDude
         admin@elecdude.com        

 Please report bugs, errors, modifications, etc. Thank you

 Copyright - 2015 - ElecDude

 USAGE AND REDISTRIBUTION OF THIS SOURCE CODE IS PERMITTED PROVIDED THAT
 THE FOLLOWING CONDITIONS ARE MET:

    1. REDISTRIBUTIONS OF SOURCE CODE MUST RETAIN THE ABOVE ORIGINAL COPYRIGHT
  NOTICE AND THE ASSOCIATED DISCLAIMER, THIS LIST OF CONDITIONS AND
  THE FOLLOWING DISCLAIMER.
    2. REDISTRIBUTIONS IN BINARY FORM MUST REPRODUCE THE ABOVE COPYRIGHT
  NOTICE, THIS LIST OF CONDITIONS AND THE FOLLOWING DISCLAIMER IN
  THE DOCUMENTATION AND/OR OTHER MATERIALS PROVIDED WITH THE
  DISTRIBUTION.

 THIS IS PROVIDED WITHOUT ANY  EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
 BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 A PARTICULAR PURPOSE ARE DISCLAIMED. TO BE USED FOR LEARNING PURPOSE ONLY.  
 IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT OWNER, BE LIABLE FOR ANY DIRECT,
 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ARISING IN ANY WAY OUT OF THE
 USE OF THIS SOURCE CODE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//***********************************************************************************//


                  FUNCTIONS IN DS1307.H
```````````````````````
    DSinit();        To initialise DS1307 RTC chip

DSWriteTime(h, m, s); To write time hr, min, sec to RTC

    DSReadTime(&h, &m, &s); To read time hr, min, sec from RTC

    DSWriteDate(d, m, y); To write date to RTC

    DSReadDate(&d, &m, &y); To read date from RTC
 
    DSReadDay(&dy);     To read day from RTC

    DSWriteDay(dy); To write day to RTC
***********************************************************/

#ifndef _ds1307_H
#define _ds1307_H
#include "I2C.h"


//declare variables for hour, minutes, seconds, day, date, month & year.
unsigned char h=0,m=0,s=0; //comment these lines if defined in Main.c
unsigned char dy=0,dd=0,mm=0,yy=0; //comment these lines if defined in Main.c

/*_________________________________________________________________________
                   DECLARATION FOR DS1307                   */
#define DS_R 0xD1   //7 bit SLA + 1(read bit)
#define DS_W 0xD0 //7 bit SLA + 0(write bit)

//DS1307 RTC Registers addresses....
#define secr   0x00
#define minr   0x01
#define hrr 0x02
#define dayr   0x03
#define dater 0x04
#define monr   0x05
#define yrr 0x06
#define conr 0x07
/*_________________________________________________________________________*/
// DSWrite(addr1,data1);
// To write 'data1' in the 'addr1' location
unsigned char DSWrite(unsigned char addr,uint8_t data)
{
//_delay_us(500);
  I2CStart();

  if(! (I2CWriteSLA(DS_W)) )//Select device
return FALSE;

  if(! (I2CWriteByte(addr)) )//select destn. register
return FALSE;

  if(! (I2CWriteByte(data)) )//write data
return FALSE;
  I2CStop();
  return TRUE;
}

// DSRead(addr1,&data1);
// To data 'data1' from the 'addr1' location
unsigned char DSRead(unsigned char addr,unsigned char *data)
{
  I2CStart();
  if(! (I2CWriteSLA(DS_W)) )//select device
return FALSE;
  if(! (I2CWriteByte(addr)) )//select register
return FALSE;

//_______________Send Repeat start for read_____________
  I2CStart();

  if(! (I2CWriteSLA(DS_R)) )// select device in MASTER READ mode
return FALSE;
  if(! (I2CReadByte(data)) )//read data form device
return FALSE;

  I2CStop();
  return TRUE;
}
/*_________________________________________________________________________*/
// DSinit();
        // To initialise DS1307 RTC chip
void DSinit()
{
unsigned char x;
DSRead(secr,&x);
x&=(~(1<<CH)); //Clear CH Bit
DSWrite(secr,x);

x=0x10;
DSWrite(conr,x);//enable out @ 1Hz
}

// DSWriteTime(h, m, s)
// To write time hr, min, sec to RTC
DSWriteTime(unsigned char h, uns
igned char m, unsigned char s)
{
DSWrite(secr,s);
DSWrite(minr,m);
DSWrite(hrr,h);
}

// DSReadTime(&h, &m, &s)
// To read time hr, min, sec from RTC
DSReadTime(unsigned char *h, unsigned char *m, unsigned char *s)
{
DSRead(secr,&s);
DSRead(minr,&m);
DSRead(hrr,&h);
}

// DSWriteDate(d, m, y)
// To write date to RTC
DSWriteDate(unsigned char dd, unsigned char mm, unsigned char yy)
{
DSWrite(dater,dd);
DSWrite(monr,mm);
DSWrite(yrr,yy);
}
// DSReadDate(&d, &m, &y)
// To read date from RTC
DSReadDate(unsigned char *h, unsigned char *m, unsigned char *s)
{
DSRead(dater,&dd);
DSRead(monr,&mm);
DSRead(yrr,&yy);
}

// DSReadDay(&dy)
// To read day from RTC
DSReadDay(unsigned char *dy)
{
DSRead(dayr,&dy);
}
// DSWriteDay(dy)
// To write day to RTC
DSWriteDay(unsigned char dy)
{
DSWrite(dayr,dy);
}

#endif
DS1307.H 

Please follow this link for I2C header File 

If you enjoyed this post plz let us know your views via comments.
This helps us to do much more better.
Thankyou.


Using Perl in your VHDL Design By Elecdude


/************************************************************************************/
 Author: ElecDude
         admin@elecdude.com        

 Please report bugs, errors, modifications, etc. Thank you

 Copyright - 2015 - ElecDude

 USAGE AND REDISTRIBUTION OF THIS SOURCE CODE IS PERMITTED PROVIDED THAT
 THE FOLLOWING CONDITIONS ARE MET:

    1. REDISTRIBUTIONS OF SOURCE CODE MUST RETAIN THE ABOVE ORIGINAL COPYRIGHT
  NOTICE AND THE ASSOCIATED DISCLAIMER, THIS LIST OF CONDITIONS AND
  THE FOLLOWING DISCLAIMER.
    2. REDISTRIBUTIONS IN BINARY FORM MUST REPRODUCE THE ABOVE COPYRIGHT
  NOTICE, THIS LIST OF CONDITIONS AND THE FOLLOWING DISCLAIMER IN
  THE DOCUMENTATION AND/OR OTHER MATERIALS PROVIDED WITH THE
  DISTRIBUTION.

 THIS IS PROVIDED WITHOUT ANY  EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
 BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 A PARTICULAR PURPOSE ARE DISCLAIMED. TO BE USED FOR LEARNING PURPOSE ONLY.  
 IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT OWNER, BE LIABLE FOR ANY DIRECT,
 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ARISING IN ANY WAY OUT OF THE
 USE OF THIS SOURCE CODE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/************************************************************************************/

print "\nWelcome to ElecDude...";
print "\n Enter file name in FULL (header1.h, file1.c,  module1.v, entity1.vhd,...) :";
$finp = <STDIN>;
chomp $finp;
print "\n ";

$char="";
$char1="";

if ($finp =~ m/.[chv]$/i) { #// //
    $char1="// // // // // // // // // // // // // // // // // // // // // // // // // // // // //  // ";
$char="//";
print "\n Adding copyright for C/Verilog..";
} elsif($finp =~ m/.pl$/i) {# # #
$char1="#   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #  # ";
$char="#";
print "\n Adding copyright for PERL..";
} elsif($finp =~ m/.vhd$/i) {# -- --
$char1="--  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  -- ";
$char="--";
print "\n Adding copyright for VHDL..";
} else {
print "Couldn't identify input file type...\n";
exit;
}
# exit;
open($DCR, "<ED_Copyright.txt") or die "Couldn't open file ED_Copyright.txt";
open(DATA_O, ">new_$finp") or die "Couldn't open file new_$finp";

print DATA_O ("$char1\n");
while (!eof($DCR)) 
{
  my $line1 = <$DCR>;
  chomp $line1;
  print DATA_O ("$char $line1\t$char \n");
}
close($DCR);
print DATA_O ("$char1\n");

open($DIN, "<$finp") or die "Couldn't open file $finp.";
print "\n Adding the Source File contents...";
while (!eof($DIN)) 
{
  my $line1 = <$DIN>;
  chomp $line1;
  print DATA_O ($line1, "\n");
}
close($DIN);
close(DATA_O);

print "\n File (new_$finp) with Copyright contents created succesfully";
system "start new_$finp";

print "\n Press ENTER key to end..."; $key = getc(STDIN);


If you enjoyed this post plz let us know your views via comments.
This helps us to do much more better.
Thankyou.


Thursday, 29 January 2015

ElecDude Calculator Using Labview

ElecDude Calculator



Elecdude Calc using Labview . 

This is the Example Coding for Event Structure and String Usage in labview.

Source file is added in this Post . 

 Elecdude CALC

If you enjoyed this post plz let us know your views via comments.
This helps us to do much more better.
Thankyou.

COMMONLY USED VHDL CONSTURCTS

COMMONLY USED VHDL CONSTURCTS

-- ********************** VHDL EXAMPLE CONTRUCTS

******************************************

LIBRARY IEEE;

USE IEEE.STD_LOGIC_1164.ALL;

USE IEEE.NUMERIC_STD.ALL;

USE IEEE.STD_LOGIC_UNSIGNED.ALL;

USE IEEE.STD_LOGIC_SIGNED.ALL;

USE IEEE.STD_LOGIC_TEXTIO.ALL;

USE STD.TEXTIO.ALL;

NUMERIC_STD TOGETHER

use work.my_pckg.all;

-- USE IEEE.STD_LOGIC_ARITH.ALL; --NEVER USE STD LOGIC ARITH &

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~

-- To print current simulation time

report "Current Simulation time @ " & time'image(now);

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~

-- GENERIC EXAMPLE

ENTITY parity_det IS

    GENERIC (n : INTEGER := 7);

    PORT ( input: IN BIT_VECTOR (n DOWNTO 0);

               output: OUT BIT);

END parity_det;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~

-- CLOCK signal generation

signal sys_clk : bit := '0';

constant sys_clk_period : time := 100 ns; -- Clock period definitions

-- Clock process definitions

sys_clk_process :process

 begin

sys_clk <= '0';

wait for sys_clk_period/2;

sys_clk <= '1';

wait for sys_clk_period/2;

 end process;

 -- Clock process definition - Method 2

sys_clk_process :process

 begin

 end process;

sys_clk <= not sys_clk after sys_clk_period/2;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~

--Clock Generator Procedure - Period & Offset defined

procedure clk_gen(signal clk: out std_logic; constant OFS: time; constant PERIOD:

time) is

begin

-- Check the arguments

assert ((PERIOD/2) /= 0 fs) report "clk_plain: High time is zero; time resolution to

large for frequency" severity FAILURE;

-- Generate a clock cycle

 clk <= '0';

 wait for OFS;

 loop

  clk <= '1';

  wait for PERIOD/2;

  clk <= '0';

  wait for PERIOD/2;

 end loop;

end procedure;

clk_gen(clk,12 ns,20 ns); --PERIOD= 20ns

clk_gen(clk,12 ns,(1 sec/100.0E+6)); --Freq= 100MHz

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~

-- FUNCTION EXAMPLE

FUNCTION conv_integer (SIGNAL vector: STD_LOGIC_VECTOR)

RETURN INTEGER IS

VARIABLE result: INTEGER RANGE 0 TO 2**vector'LENGTH-1;

BEGIN

IF (vector(vector'HIGH)='1') THEN

result:=1;

ELSE

result:=0;

END IF;

FOR i IN (vector'HIGH-1) DOWNTO (vector'LOW) LOOP

result:=result*2;

IF(vector(i)='1') THEN

END IF;

END LOOP;

RETURN result;

result:=result+1;

END conv_integer;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~~

-- Stimulus process example

stim_proc: process

begin

 -- hold reset state for 100ms.

 wait for 100 ns;

 --Sample way of setting inputs - reset used as a redundant example.

reset <= '1';

wait for 10 ns;

reset <= '0';

wait for 10 ns;

wait;

end process;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~

-- SOME COMMONLY USED CONTROL STRUCTURE SYNTAXES

------ With WHEN/ELSE -------------------------

outp <= "000" WHEN (inp='0' OR reset='1') ELSE

"001" WHEN ctl='1' ELSE

"010";

---- With WITH/SELECT/WHEN --------------------

WITH control SELECT

output <= "000" WHEN reset,

"111" WHEN set,

UNAFFECTED WHEN OTHERS;

---- with WITH/SELECT/WHEN -----

WITH sel SELECT

   y <= a WHEN "00", -- notice "," instead of ";"

b WHEN "01",

c WHEN "10",

d WHEN OTHERS; -- cannot be "d WHEN "11" "

---- CASE ------------------------

case sel is

when "00"=> y <= a;

when "01"=> y <= b;

when "10"=> y <= c; --when "00"=> y <= a;

when others=> y<=d;

end case;

---- tristate buffer WHEN/ELSE

output <= input WHEN (ena='0') ELSE

  (OTHERS => 'Z');

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~

-- Detect Rising edge

IF RISING_EDGE(clk)

-- Detect falling edge

if falling_edge (clk)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~

--State Machine Declaration

type STATES is (s0,s1,s2);

signal cur,nxt: STATES;

 StateTrans:process (clk, rstb)

 begin

if (rstb = '0') then

cur <= s0;

elsif (RISING_EDGE(clk)) then

cur <= nxt;

end if;

 end process StateTrans;

 FSM_combi:process(cur,<inputs>) begin

case cur is

 when s0=> nxt<=s1;

 when s1=> nxt<=s2;

 when s2=> nxt<=s0;

 when OTHERS=> nxt<=s0;

end case;

 end process FSM_combi;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~

--MEMORY ARRAY - RAM ROM

type mem_array is array (0 to 15) of std_logic_vector (7 downto 0);

constant rom: mem_array := ( “11111011”, “00010010”, “10011011”, “10010011”,

“01011011”, “00111010”,

“00010010”, “10101001”, “00110110”, “11011011”, “01010010”);

data <= rom(address); -- data = STD vector & address= integer

“11111011”, “00010010”, “10100011”, “10011010”, “01111011”,

signal RAM: mem_array := ( “11111011”, “00010010”, “10011011”, “10010011”,

“01011011”, “00111010”,

“00010010”, “10101001”, “00110110”, “11011011”, “01010010”);

“11111011”, “00010010”, “10100011”, “10011010”, “01111011”,

data <= RAM(conv_integer(addrs)); -- data & addrs = STD vector



If you enjoyed this post plz let us know your views via comments.
This helps us to do much more better.
Thankyou.



Friday, 19 December 2014

Labview Formula Node Syntax

If you enjoyed this post plz let us know your views via comments.



This helps us to do much more better.

Thankyou.


Saturday, 13 December 2014

Image resolution Calculation.

Image Resolution: 

        Image  Resolution = (Field of View (FOV) / Number of camera pixels in one direction)  * 2


If the FOV of horizontal direction is 50 mm and the number of sensors in the X direction is 640, the image resolution can be calculated:

                                            = (50 / 640) * 2 = 0.156 mm
                             
                   
If you enjoyed this post plz let us know your views via comments.



This helps us to do much more better.

Thankyou.


The Meaning of HSL - Image Process.

HSL - Hue Saturation Luminance.


Hue defines the color of a pixel such as red, yellow, green, and blue or combination of two of them. It is related to wavelength of a light. 

Saturation refers to the amount of white added to the hue and represents the relative purity of a color. If the saturation increases, color becomes pure. If colors are mixed, the saturation decreases. For example, red has higher saturation compared with pink.

 Luminance is closely related with the brightness of image. Extracting the luminance values of an HSL color image results in a good conversion of a color image to a grayscale representation.

If you enjoyed this post plz let us know your views via comments.



This helps us to do much more better.

Thankyou.

Sunday, 7 December 2014

LED Blinking using Sequential Structure in Labview

 * Here is the simple example of Led Blinking using sequential structure in labview . this Basic Program will       helps lot in advanced programming in labview. 
 * By this example you can understand Local variable creation and delays Usage. 







If you enjoyed this post plz let us know your views via comments.



This helps us to do much more better.
Thankyou.

Thursday, 27 November 2014

VHDL IEEE PACKAGES - DATA TYPES – DATA CONVERSIONS

VHDL IEEE PACKAGES - DATA TYPES – DATA CONVERSIONS
IEEE PACKAGE:
The IEEE library contains several packages, including the following:
  • std_logic_1164: Specifies the STD_LOGIC (8 levels) and STD_ULOGIC (9 levels) multi-valued logic systems.
  • std_logic_arith: Specifies the SIGNED and UNSIGNED data types and related arithmetic and comparison operations. It also contains several data conversion functions, which allow one type to be converted into another: conv_integer(p), conv_unsigned(p, b), conv_signed(p, b), conv_std_logic_vector(p, b).
  • std_logic_signed: Contains functions that allow operations with STD_LOGIC_VECTOR data to be performed as if the data were of type SIGNED.
  • std_logic_unsigned: Contains functions that allow operations with STD_LOGIC_VECTOR data to be performed as if the data were of type UNSIGNED.
  • std_logic_textio: Contains functions text i/o, file read & write, etc.

Pre-Defined Data Types
VHDL contains a series of pre-defined data types, specified through the IEEE 1076 and IEEE 1164 standards. More specifically, such data type definitions can be found in the following packages / libraries:
  • Package standard of library std: Defines BIT, BOOLEAN, INTEGER, and REAL data types.
  • Package std_logic_1164 of library ieee: Defines STD_LOGIC and STD_ULOGIC data types.
  • Package std_logic_arith of library ieee: Defines SIGNED and UNSIGNED data types, plus several data conversion functions, like conv_integer(p), conv_unsigned(p, b), conv_signed(p, b), and conv_std_logic_vector(p, b).
  • Packages std_logic_signed and std_logic_unsigned of library ieee: Contain functions that allow operations with STD_LOGIC_VECTOR data to be performed as if the data were of type SIGNED or UNSIGNED, respectively.




DATA CONVERSIONS:
Several data conversion functions can be found in the std_logic_arith package of
the ieee library. They are:
  • conv_integer(p) : Converts a parameter p of type INTEGER, UNSIGNED, SIGNED, or STD_ULOGIC to an INTEGER value. Notice that STD_LOGIC_VECTOR is not included.
  • conv_unsigned(p, b): Converts a parameter p of type INTEGER, UNSIGNED, SIGNED, or STD_ULOGIC to an UNSIGNED value with size b bits.
  • conv_signed(p, b): Converts a parameter p of type INTEGER, UNSIGNED, SIGNED, or STD_ULOGIC to a SIGNED value with size b bits.
  • conv_std_logic_vector(p, b): Converts a parameter p of type INTEGER, UNSIGNED, SIGNED, or STD_LOGIC to a STD_LOGIC_VECTOR value with size b bits.


The following are the examples for converting interger to std logic vector, unsigned, singed and std logic vector to integer, and integer to real & complex, and integer to string. By converting std logic vector to integer, and that integer value to string, we can convert std logic vector to string.
INTEGER TO SLV/UNSIGNED/SIGNED
num is integer
USE IEEE.NUMERIC_STD.ALL;
dat <=std_logic_vector(to_unsigned(55,dat'length));

use ieee.std_logic_arith.all;--NEVER USE STD LOGIC ARITH & NUMERIC_STD TOGETHER
slv<= conv_std_logic_vector(num,slv’length);
unsignd := conv_unsigned(num,unsignd’length);
signd := conv_signed(num,signd’length);

SLV TO INTEGER
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
variable inte:natural;
--dat= std_logic_vector 11 downto 0
inte:=conv_integer(dat); -- to integer
INTEGER TO STRING
report "dat= " & integer'image(inte); --to string

INTEGER TO REAL/COMPLEX
num is integer
USE IEEE.MATH_REAL.ALL;
real_num := real(inte);
complx := complex(inte);

Coming soon: Basic VHDL Syntaxes & Constructs, Detailed and latest file read write with hexadecimal, octal, binary data types….. Stay tuned.


If you enjoyed this post plz let us know your views via comments.
This helps us to do much more better.
Thankyou.


Thursday, 14 August 2014

Renesas eclipse embedded studio



Renesas eclipse embedded studio, known as e² studio, is a complete development and debug environment based on the popular Eclipse CDT project. Essentially open source, the Eclipse CDT covers build (editor, compiler and linker control) as well as debug phase based on an extended GDB interface




Features


Memory Usage
Visual Expressions
Integrated Code Generation
Eclipse CDT Editor


Target Devices


e² studio has been developed to support the key promotion families of Renesas controllers:
  • RL78 Family
  • RX Family
  • RH850 Family*
  • SuperH Family (SH-2 and SH-2A)
As new devices are released from Renesas, e² studio can easily be updated to add the necessary support files and debugger extensions.
* Note, The working sample for RH850 is supported. (Debug support only)

To know More click here




Saturday, 2 August 2014

POINTERS IN C - Part1

POINTERS IN C - Part1


For any beginner in C programming, the most intriguing and confusing part will be pointers (you can ask any novice C programmer).  The following will be a simple attempt to explain pointers for a beginner.

A pointer in its simplest of terms is a variable which points to the address of other variable.





Let us consider integer variable 'a' and initialize it as follows:

int a=1;

Variable a will be stored in a memory location and as we all know every memory location has an address. Let us assume "a" is stored at address 20.

i.e.,

int a=1; (address of a is 20)

Now we are introducing one more variable ptr, which is declared as:

int *ptr;

Let us see each word separately of the above declaration.

Int represents integer.

*ptr represents a pointer variable, which points to another variable of integer type (bit confusing isnt it? it should be, let us come to this a bit later), we are using * to indicate that what is following * is a pointer variable (to make the compiler understand).

We can store the address of another variable in pointer variable,  i.e., the content of the pointer variable can be the address of another variable.

Let us assume address of variable "ptr" as 30;

And now, let us consider

 ptr = &a;

the above statement indicate the compiler to assign the address of variable 'a' to the variable 'ptr' (just like how we are assigning 1 to variable 'a').

The '&' operator is known as "address of" operator (remember scanf?).

Now let's do some printing.

1. printf("%d",a); 1
2. printf("%d",&a); 20
3. printf("%d,ptr); 20
4. pritnf("%d,&ptr); 30
5. printf("%d",*ptr); 1

Understandably, we do not have any problems with first 2 printf statements.  Problem starts from the third...

The third statement prints the value 20, which is the address of variable 'a' (remember?), this is because we are assigning the address of variable 'a' to 'ptr' (ptr=&a).

Fourth statement is an usual statement which prints the address of the variable 'ptr.'

Fifth one is the most confusing, but important of all, where the printed value is 1, which is actually the value of variable 'a'.  This is happening because of * operator preceds 'ptr' variable.  * is called as derefencing operator.

What is happening here actually?!  When we are using deferencing operator *, the content of variable 'ptr' is considered (by the compiler obviously) as address of another variable and the corresponding value in that address will be printed.

So as per our example, the address of the variable 'a' is stored in variable 'ptr' (remember ptr=&a?), and when the printf statement gets executed, the value stored in address 20 (which is 1) is printed.

we just tried to give a toast of pointers in this introductory part and will explore more of pointers in detail in the coming days...happy programming.

Sakthi
nsakthivelu@gmail.com





Flashing LED Using IC555





Flashing Leds Using IC555


This simple circuit using IC555 will generate on/off signal through which we can do Led blinking . 

the Duty Cycle of the square wave is depending on R1,R2,C1 Values .
 This is kind of one channel pulse generator . If we want more than one channel to generate different square wave signals with different Duty Cycles, we can use IC4017 .
 
  

Friday, 18 July 2014

Standard Resistor & Capacitor values - Table

The following are the Standard Resistor & Capacitor values.
NOTE:  Use this as references for design calculations. Real time application may have differences. These values are std fixed. But actual values may vary depending on the manufacturer's tolerance. 



Friday, 11 July 2014

Steps to Create "God Mode" In Windows 7

Steps to  Create  "God Mode" In Windows 7
1. Create a New folder


2 Rename the New folder in to      " God Mode.{ED7BA470-8E54-465E-825C-99712043E01C}"


3. Here its your God Mode in Windows 7



4. Double Click  the God Mode and you will see the All the Setting control of Windows 7 :-)



Created By
Kali Sankar . V
Ethical Hacking Editor
Elecdude.com

Monday, 7 July 2014

DIFFERENCES IN CMOS 4000 SERIES, 74LS, 74HC, 74HCT SERIES IC

DIFFERENCES OF CMOS 4000 SERIES, 74LS, 74HC, 74HCT SERIES IC

Integrated Circuit (IC) is fastly growing and different technologies have been developed and being developed. Most commonly available IC families are CMOS 4000, 74LS, 74HC, 74HCT. Now let us see the characteristics of those families and their differences.



4000 Series CMOS
        This family of logic ICs is numbered from 4000 onwards, and from 4500 onwards. They have a B at the end of the number (e.g. 4001B) which refers to an improved design introduced some years ago. Most of them are in 14-pin or 16-pin packages. They use CMOS circuitry which means they use very little power and can tolerate a wide range of power supply voltages (3 to 15V) making them ideal for battery powered projects. CMOS is pronounced 'see-moss' and stands for Complementary Metal Oxide Semiconductor. 

       However the CMOS circuitry also means that they are static sensitive. Touching a pin while charged with static electricity (from your clothes for example) may damage the IC. In fact most ICs in regular use are quite tolerant and earthing your hands by touching a metal water pipe or window frame before handling them will be adequate. ICs should be left in their protective packaging until you are ready to use them. For the more sensitive (and expensive!) ICs special equipment is available, including earthed wrist straps and earthed work surfaces.

74LS, 74HC, 74HCT
There are several families of logic ICs numbered from 74xx00 onwards with letters (xx) in the middle of the number to indicate the type of circuitry, eg 74LS00 and 74HC00. The original family (now obsolete) had no letters, eg 7400. 

The 74LS (Low-power Schottky) family (like the original) uses TTL(Transistor-Transistor Logic) circuitry which is fast but requires more power than later families. The 74 series is often still called the 'TTL series' even though the latest ICs do not use TTL! 

The 74HC family has High-speed CMOS circuitry, combining the speed of  TTL with the very low power consumption of the 4000 series. They are CMOS ICs with the same pin arrangements as the older 74LS family. Note that 74HC inputs cannot be reliably driven by 74LS outputs because the voltage ranges used for logic 0 are not quite compatible, use 74HCT instead.

The 74HCT family is a special version of 74HC with 74LS TTL-compatible inputs so 74HCT can be safely mixed with 74LS in the same system. In fact 74HCT can be used as low-power direct replacements for the older 74LS ICs in most circuits. The minor disadvantage of 74HCT is a lower immunity to noise, but this is unlikely to be a problem in most situations. 

The CMOS circuitry used in the 74HC and 74HCT series ICs means that they are static sensitive. Touching a pin while charged with static electricity (from your clothes for example) may damage the IC. In fact most ICs in regular use are quite tolerant and earthing your hands by touching a metal water pipe or window frame before handling them will be adequate. ICs should be left in their protective packaging until you are ready to use them. 

CMOS 4000 series family characteristics:
  • Supply: 3 to 15V, small fluctuations are tolerated.
  • Inputs have very high impedance (resistance), this is good because it means they will not affect the part of the circuit where they are connected. However, it also means that unconnected inputs can easily pick up electrical noise and rapidly change between high and low states in an unpredictable way. This is likely to make the IC behave erratically and it will significantly increase the supply current. To prevent problems all unused inputs MUST be connected to the supply (either +Vs or 0V), this applies even if that part of the IC is not being used in the circuit!
  • Outputs can sink and source only about 1mA if you wish to maintainthe correct output voltage to drive CMOS inputs. If there is no need to drive any inputs the maximum current is about 5mA with a 6V supply, or 10mA with a 9V supply (just enough to light an LED). To switch larger currents you can connect a transistor.
  • Fan-out: one output can drive up to 50 inputs.
  • Gate propagation time: typically 30ns for a signal to travel through a gate with a 9V supply, it takes a longer time at lower supply voltages.
  • Frequency: up to 1MHz, above that the 74 series is a better choice.
  • Power consumption (of the IC itself) is very low, a few µW. It is much greater at high frequencies, a few mW at 1MHz for example.

74HC and 74HCT family characteristics:
  • 74HC Supply: 2 to 6V, small fluctuations are tolerated.
  • 74HCT Supply: 5V ±0.5V, a regulated supply is best.
  • Inputs have very high impedance (resistance), this is good because it means they will not affect the part of the circuit where they are connected. However, it also means that unconnected inputs can easily pick up electrical noise and rapidly change between high and low states in an unpredictable way. This is likely to make the IC behave erratically and it will significantly increase the supply current. To prevent problems all unused inputs MUST be connected to the supply (either +Vs or 0V), this applies even if that part of the IC is not being used in the circuit! Note that 74HC inputs cannot be reliably driven by 74LS outputs because the voltage ranges used for logic 0 are not quite compatible. For reliability use 74HCT if the system includes some 74LS ICs.
  • Outputs can sink and source about 4mA if you wish to maintain the correct output voltage to drive logic inputs, but if there is no need to drive any inputs the maximum current is about 20mA. To switch larger currents you can connect a transistor.
  • Fan-out: one output can drive many inputs (50+), except 74LS inputs because these require a higher current and only 10 can be driven.
  • Gate propagation time: about 10ns for a signal to travel through a gate.
  • Frequency: up to 25MHz.
  • Power consumption (of the IC itself) is very low, a few µW. It is much greater at high frequencies, a few mW at 1MHz for example. 

74LS family TTL characteristics:
  • Supply: 5V ±0.25V, it must be very smooth, a regulated supply is best. In addition to the normal supply smoothing, a 0.1µF capacitor should be connected across the supply near the IC to remove the 'spikes' generated as it switches state, one capacitor is needed for every 4 ICs.
  • Inputs 'float' high to logic 1 if unconnected, but do not rely on this in a permanent (soldered) circuit because the inputs may pick up electrical noise. 1mA must be drawn out to hold inputs at logic 0. In a permanent circuit it is wise to connect any unused inputs to +Vs to ensure good immunity to noise.
  • Outputs can sink up to 16mA (enough to light an LED), but they can source only about 2mA. To switch larger currents you can connect a transistor.
  • Fan-out: one output can drive up to 10 74LS inputs, but many more 74HCT inputs.
  • Gate propagation time: about 10ns for a signal to travel through a gate.
  • Frequency: up to about 35MHz (under the right conditions).
  • Power consumption (of the IC itself) is a few mW.

Also see more:




Search Here...