Chủ Nhật, 28 tháng 9, 2014

Ladder logic for PIC and AVR

LD MICRO

Download here
Pass : sieuphat.blogspot.com

Note : Clic in skip ad  ,and then download .



INTRODUCTION
============
LDmicro generates native code for certain Microchip PIC16 and Atmel AVR microcontrollers. Usually software for these microcontrollers is written in a programming language like assembler, C, or BASIC. A program in one of these languages comprises a list of statements. These languages are powerful and well-suited to the architecture of the processor, which internally executes a list of instructions. PLCs, on the other hand, are often programmed in `ladder logic.' A simple program might look like this:
   ||                                                                    ||
   ||    Xbutton1           Tdon           Rchatter           Yred       ||
 1 ||-------]/[---------[TON 1.000 s]-+-------]/[--------------( )-------||
   ||                                 |                                  ||
   ||    Xbutton2           Tdof      |                                  ||
   ||-------]/[---------[TOF 2.000 s]-+                                  ||
   ||                                                                    ||
   ||                                                                    ||
   ||                                                                    ||
   ||    Rchatter            Ton             Tnew           Rchatter     ||
 2 ||-------]/[---------[TON 1.000 s]----[TOF 1.000 s]---------( )-------||
   ||                                                                    ||
   ||                                                                    ||
   ||                                                                    ||
   ||------[END]---------------------------------------------------------||
   ||                                                                    ||
   ||                                                                    ||

(TON is a turn-on delay; TOF is a turn-off delay. The --] [-- statements are inputs, which behave sort of like the contacts on a relay. The --( )-- statements are outputs, which behave sort of like the coil of a relay. Many good references for ladder logic are available on the Internet and elsewhere; details specific to this implementation are given below.)
A number of differences are apparent:
          * The program is presented in graphical format, not as a textual list of statements. Many people  will  initially find this easier to  understand.
          * At the most basic level, programs look like circuit diagrams, with relay contacts (inputs) and coils   (outputs). This is intuitive to  programmers with knowledge of electric circuit theory.
           * The ladder logic compiler takes care of what gets calculated  where. You do not have to write code to determine when the outputs have to get recalculated based on a change in the inputs or a timer event, and you do not have to specify the order in which these calculations must take place; the PLC tools do that for you.
LDmicro compiles ladder logic to PIC16 or AVR code. The following processors are supported:
    * PIC16F877
    * PIC16F628
    * PIC16F876 (untested)
    * PIC16F88 (untested)
    * PIC16F819 (untested)
    * PIC16F887 (untested)
    * PIC16F886 (untested)
    * ATmega128
    * ATmega64
    * ATmega162 (untested)
    * ATmega32 (untested)
    * ATmega16 (untested)
    * ATmega8 (untested)
It would be easy to support more AVR or PIC16 chips, but I do not have any way to test them. If you need one in particular then contact me and I will see what I can do.
Using LDmicro, you can draw a ladder diagram for your program. You can simulate the logic in real time on your PC. Then when you are convinced that it is correct you can assign pins on the microcontroller to the program inputs and outputs. Once you have assigned the pins, you can compile PIC or AVR code for your program. The compiler output is a .hex file that you can program into your microcontroller using any PIC/AVR programmer.
LDmicro is designed to be somewhat similar to most commercial PLC programming systems. There are some exceptions, and a lot of things aren't standard in industry anyways. Carefully read the description


of each instruction, even if it looks familiar. This document assumes basic knowledge of ladder logic and of the structure of PLC software (the execution cycle: read inputs, compute, write outputs).
                                                              Read more

Không có nhận xét nào:

Đăng nhận xét