Friday, 31 January 2014

What is output of this program?




main()
{
float me =1.1;
double you=1.1;
if(me==you)
printf(“i love embedded c”);
else
printf(“i love embeddedgoogle”);
}
Ans
I love emeddedgoogle
Explanation:
For floating poit members (float, double, long double) the values  cannot predicted exactly, Depending on the number of bytes, the precession with of the represented varies,. Float takes bytes and long double takes 10 bytes, so float stores 0.9 with less than long double.
Rule of thumb;
Never compare or at-least be cautious when using floating point numbers with relational operators, (==,>,<,<=,>=,!+)

What is output of this program?
main()
{
int c[]={2,8,3,4,4,6,7,5};
int j,*p=c,*q=c;
for(j=0;j<5;j++)
{
printf(“%d”,*c);
++q;
}
for(j=0;j<5;j++)
          {
printf(“%d”,*p);
++p;
}

}

Ans
2 2 2 2 2 2 2 3 4 6 5
Explanation:
Initially pointer c Is assigned to both p and q. in the first loop, since only q is incremented and not c, the value 2 will ne printed 5 times, in second loop p itself is incremented . so the values 2 3 4 6 5 will be printed.

What is output of this program?


main()
{
char s[]=”man”;
int i;
for(i=0;s[i];i++)
printf(“\n%c%c%c%c,s[i],*(s+i),*(i+s),i[s]”);
}
Ans:
mmmm
aaaa
nnnn
Explanation:
S[i], ],*(s+i),*(i+s),i[s] are all different ways of expressing the same idea, Generally array name is the base address for that array. Here s is the base address. I is thee index number/displacement from the base address. So, indirecting it with * is same as s[i], i[s] may be surprising. But in the case of C, it is same as s[i].

Predict output or errrors in this program

void main()
{
 int const *p=5;
printf("%d",++(*P));
}


Ans,
Compiler error
Because see const keyword nearer to int, so can’t modify constant value,
See here Pointer is the constant pointer

LCD Interface using Mickro C

                       Here we have interfaced LCD with PIC 18f452. LCD has 16 pins, in that 8 pins for data, and 3 pins for controlling lcd.  But in 8051, we have totally 32 pins for interfacing. so if we use 11 pins for LCD interfacing, then only few pins will be available for others. So we interface LCD in 4 bit mode. So We need 4 pins for Data and 2 pins(RS,EN) for controlling.
So that we reduce 5 pins.

Here for pic programming i have used Mickro C pro, this is the easiest development platform, having lot of inbuilt libraries, 

Download Embedded C program for LCD
Download Sim File
Download Hex file

Thursday, 30 January 2014

Start Your first LED Flashing Program in Mickro C

Program using Mickro C;

void main() {
  TRISB=0;
  PORTB=0;                                //Assign Portb as output port
  while(1)
  {
  Led=1;                                //Led ON
  Delay_Ms(1000);                       //Delay of 1 sec
  Led=0;                               //Led OFF
  Delay_Ms(1000);                      //Delay of 1 sec
  }
}

Download C file  here
Download Simulation File here
Download Hex file here

How To Crack Mikroc Pro





First install Mikroc Pro from their official website. You can download Mikroc Pro For PIC v5.8(as I am using this). Install it into the default directory.
Then Go to download section at the top of this page. Download the mikroe.rar file. Extrat this file.
Open the extracted file and go to KeyGen->mikroC PRO for PIC.
You Can find a app named keygen. Copy this app to the installation directory.


Then double click to keygen app it will create mikroC_PRO_PIC.key
file.
Now open the mikroc pro app and look that it is now a registered version. You can now exert a hex more than 2k.
Enjoy!!!!

MickroC Libraries

Download Mickro C Manual and Libraries here

MickroC Libraries pdf

Wednesday, 29 January 2014

What is PLC?

What Is A Programmable Logic Controller (PLC)?

What Is A PLC?

A PROGRAMMABLE LOGIC CONTROLLER (PLC) is an industrial computer control system that continuously monitors the state of input devices and makes decisions based upon a custom program to control the state of output devices.
Almost any production line, machine function, or process can be greatly enhanced using this type of control system. However, the biggest benefit in using a PLC is the ability to change and replicate the operation or process while collecting and communicating vital information.
Another advantage of a PLC system is that it is modular. That is, you can mix and match the types of Input and Output devices to best suit your application.

History of PLCs

The first Programmable Logic Controllers were designed and developed by Modicon as a relay re-placer for GM and Landis.
  • These controllers eliminated the need for rewiring and adding additional hardware for each new configuration of logic.
  • The new system drastically increased the functionality of the controls while reducing the cabinet space that housed the logic.
  • The first PLC, model 084, was invented by Dick Morley in 1969
  • The first commercial successful PLC, the 184, was introduced in 1973 and was designed by Michael Greenberg.

What Is Inside A PLC?

inside of a plc
The Central Processing Unit, the CPU, contains an internal program that tells the PLC how to perform the following functions:
  • Execute the Control Instructions contained in the User's Programs. This program is stored in "nonvolatile" memory, meaning that the program will not be lost if power is removed
  • Communicate with other devices, which can include I/O Devices, Programming Devices, Networks, and even other PLCs.
  • Perform Housekeeping activities such as Communications, Internal Diagnostics, etc.

How Does A PLC Operate?

There are four basic steps in the operation of all PLCs; Input Scan, Program Scan, Output Scan, and Housekeeping. These steps continually take place in a repeating loop.
Four Steps In The PLC Operations

1.) Input Scan
  • Detects the state of all input devices that are connected to the PLC
2.) Program Scan
  • Executes the user created program logic
3.) Output Scan
  • Energizes or de-energize all output devices that are connected to the PLC.
4.) Housekeeping
  • This step includes communications with programming terminals,
    internal diagnostics, etc...
programmable logic controller operation
These steps are continually
processed in a loop.

What Programming Language Is Used To Program A PLC?

While Ladder Logic is the most commonly used PLC programming language, it is not the only one. The following table lists of some of languages that are used to program a PLC.
Ladder Diagram (LD) Traditional ladder logic is graphical programming language. Initially programmed with simple contacts that simulated the opening and closing of relays, Ladder Logic programming has been expanded to include such functions as counters, timers, shift registers, and math operations.
Function Block Diagram (FBD) - A graphical language for depicting signal and data flows through re-usable function blocks. FBD is very useful for expressing the interconnection of control system algorithms and logic.
Structured Text (ST) – A high level text language that encourages structured programming. It has a language structure (syntax) that strongly resembles PASCAL and supports a wide range of standard functions and operators. For example;
If Speed1 > 100.0 then
    Flow_Rate: = 50.0 + Offset_A1;
Else
    Flow_Rate: = 100.0; Steam: = ON
End_If;
Instruction List (IL): A low level “assembler like” language that is based on similar instructions list languages found in a wide range of today’s PLCs.
LD
MPC
LD
ST
RESET:
ST
  R1
RESET
PRESS_1
MAX_PRESS
LD    0
A_X43
 
Sequential Function Chart (SFC) A method of programming complex control systems at a more highly structured level. A SFC program is an overview of the control system, in which the basic building blocks are entire program files. Each program file is created using one of the other types of programming languages. The SFC approach coordinates large, complicated programming tasks into smaller, more manageable tasks.

What Are Input/Output Devices?

INPUTS
OUTPUTS
Switches and Pushbuttons
Sensing Devices
  Limit Switches
Photoelectric Sensors
Proximity Sensors
photoelectric sensors
Valves
Motor Starters
Solenoids
Acuators
valves
Conditon Sensors
Encoders
  Pressure Switches
Level Switches
Temperature Switches
Vacuum Switches
Float Switches
amci duracoder
Horns and Alarms
Stack lights
Control Relays
Counter/Totalizer
Pumps
Printers
Fans
stack lights

What Do I Need To Consider When Choosing A PLC?

There are many PLC systems on the market today. Other than cost, you must consider the following when deciding which one will best suit the needs of your application.
  • Will the system be powered by AC or DC voltage?
  • Does the PLC have enough memory to run my user program?
  • Does the system run fast enough to meet my application’s requirements?
  • What type of software is used to program the PLC?
  • Will the PLC be able to manage the number of inputs and outputs that my application requires?
  • If required by your application, can the PLC handle analog inputs and outputs, or maybe a combination of both analog and discrete inputs and outputs?
  • How am I going to communicate with my PLC?
  • Do I need network connectivity and can it be added to my PLC?
  • Will the system be located in one place or spread out over a large area?

PLC Acronyms

The following table shows a list of commonly used Acronyms that you see when researching or using your PLC.
ASCII American Standard Code for Information Interchange
BCD Binary Coded Decimal
CSA Canadian Standards Association
DIO Distributed I/O
EIA Electronic Industries Association
EMI ElectroMagnetic Interference
HMI Human Machine Interface
IEC International Electrotechnical Commission
IEEE Institute of Electrical and Electronic Engineers
I/O Input(s) and/or Output(s)
ISO International Standards Organization
LL Ladder Logic
LSB Least Significant Bit
MMI Man Machine Interface
MODICON MOdular DIgital CONtoller
MSB Most Significant Bit
PID Proportional Integral Derivative (feedback control)
RF Radio Frequency
RIO Remote I/O
RTU Remote Terminal Unit
SCADA Supervisory Control And Data Acquisition
TCP/IP Transmission Control Protocol / Internet Protocol

Download Book to learn PLC

Click Here