?? ladder logic for pic and avr.mht
字號:
really=20
great. None of this matters much until you're trying to run =
dozens=20
of rungs of logic with fast cycle times.</P>
<P>I support the A/D converter, PWM unit, and UART on those=20
microcontrollers that provide them. That means that you can =
write=20
ladder logic that reads analog inputs, and that sends and =
receives=20
characters over serial (for example to a PC, if you add a =
suitable=20
level-shifter like a MAX232, or to a character LCD). It is =
possible=20
to send arbitrary strings over serial, as well as the values =
of=20
integer variables, as ASCII text. Finally, I now support =
=91preserved=20
variables=92 on devices with EEPROM; you can indicate that a =
particular variable should be auto-saved to nonvolatile =
memory=20
whenever it changes, so that its value is persistent across =
power-on=20
resets.</P>
<H3>Limitations, and Disclaimer</H3>
<P>Of course a microcontroller with this software can't do=20
everything that a PLC will. Most PLC environments offer more =
features and predefined blocks than my tool does. The PLC =
hardware=20
is better too; usually the inputs and outputs are designed =
to=20
withstand incredible electrical abuse. You can get a =
PIC16F877 on a=20
carrier board for ten or twenty USD, though, and you'll pay =
a fair=20
bit more for a PLC with the same capabiltities.</P>
<P>So far I have received very few bug reports compared to =
the=20
number of people with questions or feature requests. There =
is still=20
great possibility for defects, especially in the targets for =
microcontrollers that I do not physically have (and =
therefore cannot=20
test). Certainly do not use LDmicro for anything =
safety-critical, or=20
anything that would break something expensive if it =
failed.</P>
<P>As noted above, the code that it generates is far from =
optimal.=20
Also, not all of the data RAM in PIC16 devices is available =
to the=20
ladder logic program. This is because I have not implemented =
very=20
much support for all the paging nonsense. I do, however, =
support the=20
program memory paging, which is necessary to access program =
memory=20
locations in the PIC16 beyond 2k.</P><A name=3Ddl></A>
<H3>Download</H3>
<P>The software is tested under Windows XP. Unconfirmed =
reports=20
suggest that it works under Windows 98. The download is a =
.exe file;=20
there are no other files required, so there is no =
installation=20
program. Save it somewhere on your computer and just run it, =
and it=20
will work. The manual is included in the .exe file, but you =
can=20
download it separately if you want.</P>
<P>The compiler generates Intel IHEX files. Most of the =
programming=20
software that I have seen expects this. Of course you need =
some sort=20
of programming gadget to get the hex file into the chip. For =
the=20
AVRs, I recommend an STK300-type parallel port dongle, like =
<A=20
href=3D"http://www.olimex.com/">Olimex</A> sells. For the =
PICs, I=20
recommend Microchip's PICkit 2, which is available from =
their <A=20
href=3D"http://buy.microchip.com/">web store</A>.=20
<P>I would appreciate any bug reports. The following chips =
are=20
supported and tested:</P>
<P>
<UL>
<LI>PIC16F877=20
<LI>PIC16F876=20
<LI>PIC16F628=20
<LI>ATmega64=20
<LI>ATmega128 </LI></UL>
<P></P>
<P>The following chips are supported but not tested; they =
should=20
work, but no guarantees. If you try one and it works then I =
would=20
appreciate a success report: </P>
<P>
<UL>
<LI>PIC16F88=20
<LI>PIC16F819=20
<LI>ATmega162=20
<LI>ATmega32=20
<LI>ATmega16=20
<LI>ATmega8 </LI></UL>
<P></P>
<P>It is also possible to generate C code from the ladder =
program.=20
That is less convenient, but you could use it on any =
processor for=20
which you have a C compiler.</P>
<P>LDmicro can generate interpretable byte code. If you are =
willing=20
to write an interpreter then you can use this to run your =
ladder=20
code on any kind of target. There is not very much =
documentation on=20
this, but I provide a sample interpreter in mostly-portable =
C.</P>
<P>Here is the program:</P>
<P>
<UL>
<LI><A =
href=3D"http://cq.cx/dl/ldmicro.exe">ldmicro.exe</A>=20
(program, release 1.5)=20
<LI><A =
href=3D"http://cq.cx/dl/ldmicro.txt">ldmicro.txt</A> (manual)=20
<LI><A =
href=3D"http://cq.cx/dl/ldmicro-changes.txt">feature/bugfix=20
history</A>=20
<LI>sample: <A href=3D"http://cq.cx/dl/traffic.ld">a =
simplified=20
traffic light</A>=20
<LI>sample: <A =
href=3D"http://cq.cx/dl/7seg-display.ld">how to drive=20
a seven-segment display</A>=20
<LI>sample: <A href=3D"http://cq.cx/dl/hello.ld">=91hello, =
world;' it=20
prints the string over serial</A>=20
<LI><A href=3D"http://cq.cx/dl/ldinterpret.c">sample =
bytecode=20
interpreter</A> / <A =
href=3D"http://cq.cx/dl/intcode.h">needed=20
header</A> </LI></UL>
<P></P>
<P>(right-click to save any of these files)</P>
<P><B>Please report any defects.</B> This is freeware, with =
no=20
department in charge of quality control. I do not even have =
the=20
hardware to test many of the targets myself. A bug that is =
not=20
reported is unlikely to ever be fixed.</P>
<P>I have a <A=20
=
href=3D"http://cq.cx/ladder-tutorial.pl"><B>tutorial,</B></A> in which=20
I describe how to enter a simple ladder diagram, simulate =
it, and=20
then generate an IHEX file and program it into a PIC. That =
is=20
probably the easiest way to get started with this =
software.</P>
<P>The source code for LDmicro is not generally available. =
If you=20
would like access to the source code, or if you are =
interested in a=20
customized version of LDmicro, then please <A=20
href=3D"http://cq.cx/contact.pl">contact me</A> with your=20
requirements.</P>
<P><I>April 2007, Cambridge MA</I></P>
<P></P><BR><IMG height=3D10=20
src=3D"http://cq.cx/pics/shim.png"></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=3D0 cellPadding=3D0 border=3D0>
<TBODY>
<TR>
<TD width=3D163><IMG class=3Dshim height=3D1=20
src=3D"http://cq.cx/pics/shim.png" width=3D163></TD>
<TD width=3D15 bgColor=3Dblack height=3D1><IMG class=3Dshim =
height=3D1=20
src=3D"http://cq.cx/pics/shim.png"></TD></TR>
<TR>
<TD height=3D10></TD>
=
<TD></TD></TR></TBODY></TABLE></TR></TBODY></TABLE></BODY></HTML>
------=_NextPart_000_0000_01C77B90.6FB24690
Content-Type: image/png
Content-Transfer-Encoding: base64
Content-Location: http://cq.cx/pics/shim.png
iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAMAAAAoyzS7AAAABGdBTUEAAK/INwWK6QAAABl0RVh0
U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAAGUExURf///wAAAFXC034AAAABdFJOUwBA
5thmAAAADElEQVR42mJgAAgwAAACAAFPbVnhAAAAAElFTkSuQmCC
------=_NextPart_000_0000_01C77B90.6FB24690
Content-Type: image/png
Content-Transfer-Encoding: base64
Content-Location: http://cq.cx/pics/ladder-sample.png
iVBORw0KGgoAAAANSUhEUgAAAqcAAAM6CAIAAAAzCH16AAA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4ljFIyCUTAKRsEw61YAq+Ef4KXvv/4wQCvsP6BK
+u8fRmid+w80Gf8PPCX/H9T1BtXYzEyMDIgOCYoh3bli+K0MqXiB1ZD/wLr81w8Q4/cvfRcTeUO1
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -