diff options
Diffstat (limited to 'doc/en')
-rw-r--r-- | doc/en/Makefile.am | 7 | ||||
-rw-r--r-- | doc/en/circuits.docbook | 84 | ||||
-rw-r--r-- | doc/en/debugging.docbook | 35 | ||||
-rw-r--r-- | doc/en/faq.docbook | 68 | ||||
-rw-r--r-- | doc/en/flowcode.docbook | 52 | ||||
-rw-r--r-- | doc/en/index.docbook | 56 | ||||
-rw-r--r-- | doc/en/microbe.docbook | 422 | ||||
-rw-r--r-- | doc/en/picprograms.docbook | 44 | ||||
-rw-r--r-- | doc/en/quick.docbook | 42 |
9 files changed, 810 insertions, 0 deletions
diff --git a/doc/en/Makefile.am b/doc/en/Makefile.am new file mode 100644 index 0000000..65e8484 --- /dev/null +++ b/doc/en/Makefile.am @@ -0,0 +1,7 @@ +KDE_DOCS = ktechlab +# KDE_MANS = ktechlab +KDE_LANG = en +# KDE_DOCS = AUTO + +kde_docs_KDEDOCS = debugging.docbook circuits.docbook flowcode.docbook \ + quick.docbook faq.docbook picprograms.docbook diff --git a/doc/en/circuits.docbook b/doc/en/circuits.docbook new file mode 100644 index 0000000..fb7619a --- /dev/null +++ b/doc/en/circuits.docbook @@ -0,0 +1,84 @@ +<!-- kate: tab-width 2; indent-mode xml; --> +<chapter id="circuits"> + <title>Circuits</title> + + <sect1 id="placing_components"> + <title>Placing components</title> + <para>On the left, you'll find the Components tab.</para> + + <para>Dragging a component from the sidebar into the circuit will place it under the mouse cursor. Alternatively, you can double click on an item in the Components sidebar to repeatedly add it to the circuit. In this mode, a copy of the selected component will be placed repeatedly on mouse left-clicking until either Escape is pressed, or the mouse is right-clicked.</para> + + <para>To reposition a component, left-click and drag. You'll find it snapping to the underlying grid. If you drag the component out of the right or bottom edges of the workarea, the workarea will resize itself to accomodate.</para> + + <para>All components have a notion of orientation; 0, 90, 180 and 270 degrees. Those that aren't symmetrical about an axis can also be flipped. To rotate a selection of components, either right click and select from the Orientation menu, or click on the rotate buttons in the toolbar. The latter can also be accessed by pressing the "[" and "]" keys (familiar to Inkscape users). The Item sidebar (on the right) provides a powerful method of setting the orientation by providing previews of the components. Flipping components is also only possibly via the Item sidebar.</para> + </sect1> + + <sect1 id="connecting_components"> + <title>Connecting Components</title> + <para>There are two modes for creating connections (wires): automatic, and manual. These modes are selected via the "Connection Routing Mode" pulldown menu in the toolbar. Experiment with both - automatic routing is often better for small circuits, whereas more complex circuits may need manual routing.</para> + + <para>In automatic mode, create a connection by dragging from either a component pin or an existing connection, and releasing the mouse over the desired pin or connection. You'll see the straight-line being drawn turn orange when a valid connection will be created on mouse release. If the line you're drawing is black, it's either because there's nothing beneath the mouse cursor, or you're attempting to connect together two items which are already connected. When flowcharting, the criteria for a valid connection are more complex - but we'll get to that later.</para> + + <para>The best way to get a feel for manual connection routing is by experimenting with it. Click on the starting pin or connection, and then extend the proto-connector by moving the mouse away from where you clicked. To place a corner, left-click. To cancel drawing the connection, either press escape, or right-click the mouse.</para> + + <para>&kappname; tries its best to maintain the routes your connections take. However, if dragging a component results in the end points of a connection moving relative to each other, &kappname; will be forced to redraw the connection using auto-routing. Before moving a component, you can see which connectors will have to be rerouted - as they will turn grey on clicking.</para> + + <para>To remove an existing connection, select it by drawing a small select-rectangle over part of the connector, and hit delete.</para> + </sect1> + + <sect1 id="component_attributes"> + <title>Component Attributes</title> + <para>Most components will have editable attributes, such as the resistance for resistors. By default, you can edit simple attributes in the toolbar, when a group of the same type of components are selected. If your selection contains a mixture of different types of components (such as resistors and capacitors), then no attributes will be displayed for editing.</para> + + <para>Some components have more advanced attributes which are not accesible via the toolbar. These are found in the Item sidebar on the right. The diode, for example, has a variety of behavioural characteristics that you can edit here.</para> + + <para>If your selection of components have different values for their attributes (for example, different resistances for a selection of resistors), the Item sidebar will have the disagreeing attributes greyed-out. You can enable these by clicking the "Merge properties" button.</para> + + <para>The "Defaults" button will reset the component attributes to the ones it had on creation.</para> + + <para>There is one type of attribute that cannot be editable by either the toolbar or Item sidebar - multiline text. Double clicking on the item will bring up a dialog box where the text can be entered.</para> + </sect1> + + <sect1 id="circuit_simulation"> + <title>Simulation</title> + <para>By default, the simulation will be running when you create a new circuit. The status of the simulation is displayed in the lower right of a circuit view, and can be changed via the Tools menu. Firstly - a little explanation on how the Simulator works. This should allow you to make the most out of it.</para> + + <para>When a circuit is created or modified, the affected areas are partitioned up into groups of pins and connections that can be considered independent. Each group is then simulated as a seperate entity (although still interacting via the components), with the simulation provided dependent on the group's complexity. Complex groups, such as those involving nonlinear components like LEDs, are slow to simulate. Groups that contain only logic pins, of which only one controls the value on those pins, are the fastest to simulate.</para> + + <para>The results of the simulation are provided through several graphical means.</para> + + <para>The pins on the components will display voltage sidebars. These are coloured orange for positive voltage, and blue for negative voltage. Their length depends on the voltage level, and their width on the amount of current flowing through the pin. These can be turned off in the Work Area tab of the Configuration dialog.</para> + + <para>Hovering the mouse over a pin or connection will display a small tooltip showing the voltage and current at that point in the circuit. Several components also provide graphical feedback - for example, LEDs and voltmeters or ammeters.</para> + + <para>Lastly, there is the oscilloscope, discussed in the next section.</para> + </sect1> + + <sect1 id="oscilloscope"> + <title>Oscilloscope</title> + <para>The oscilloscope can record logic, voltage and current data. The logic probe is optimized for storing boolean samples, and so should be used instead of the voltage probe when measuring logic.</para> + + <para>To collect data, create a new probe component, and attach it to an appropriate point in the circuit. You'll see the output immediately drawn in the oscilloscope. Adding more probes will squash the outputs next to each other - you can reposition these by dragging the arrows on the left of the oscilloscope view, and change their colours via the probe's attributes.</para> + + <para>For voltage and current probes, the range of input values can be adjusted in the "Item Editor" sidebar on the right.</para> + + <para>Zooming is controlled by a slider. The scaling is logarithmic; for every few pixels that the slider moves along, the zoom factor will be multipled by a constant. &kappname; simulates logic to a maximum precision of 1 microsecond, and at maximum zoom level, one microsecond is represented by 8 pixels.</para> + + <para>When the scrollbar is dragged to the end, it will remain there as new data is recorded. Otherwise, the position of the scrollbar remains fixed in time. The oscilloscope view can also be moved forwards and backwards by left-clicking and dragging the view. Due to limitations of the underlying widget system, scrolling will be very granular at maximum zoom.</para> + + <para>Right-clicking on the oscilloscope view brings up a menu where you can control the number of times the oscilloscope view is updated. This allows for either a smoother display, or reducing CPU usage.</para> + </sect1> + + <sect1 id="subcircuits"> + <title>Subcircuits</title> + <para>Subcircuits offer a reusable and tidy way of using a circuit, when you're only interested in interacting with external connections to the circuit. The subcircuit is creating as an IC, with the pins acting as the interaction with the internal circuit.</para> + + <para>First, the circuit to be used in as a template for creating a subcircuit from must be constructed. The points of interaction are defined via "External Connection" components. These must be connected up, and positioned where you want the pin to be positioned on the subcircuit IC.</para> + + <para>Next, select the group of components and external connections to be turned into a subcircuit, and select "Create Subcircuit" from the right-click menu. You'll be offered to enter a name for the subcircuit. Once created, the name will popup in the Component selector under the Subcircuits selection. This can be treated as any normal component - with the additional option of removing it by right-clicking on the item and selecting Remove.</para> + </sect1> + +</chapter> + + + diff --git a/doc/en/debugging.docbook b/doc/en/debugging.docbook new file mode 100644 index 0000000..af1a864 --- /dev/null +++ b/doc/en/debugging.docbook @@ -0,0 +1,35 @@ +<!-- kate: tab-width 2; indent-mode xml; --> +<chapter id="debugging"> + <title>Debugging</title> + + <sect1 id="starting_debugger"> + <title>Starting the Debugger</title> + + <para>Debugging support is provided for Assembly, SDCC and Microbe, when they are open as a text document. From here, stepping is controlled via the Debug menu. There are two methods of starting the debugger.</para> + + <para>If the PIC program is already running in a circuit, then double-clicking on the PIC component will open up the program. For assembly PIC programs, the debugger for that text document will be linked into the PIC component. In this case, the debug menu cannot stop the PIC program - as this is owned by the PIC component.</para> + + <para>If the assembly file is already opened, then the debugger can be run via the Debug menu. After compiling the program, the debugger will be ready, with the PIC program paused at the first instruction. Note that when debugging high level languages, the current execution point will not be shown if there is no line that corresponds to the first assembly instruction to be executed. In this case, clicking next will bring the execution point to the first line in the program.</para> + </sect1> + + <sect1 id="controlling_debugger"> + <title>Controlling the Debugger</title> + + <para>The debugger can be in one of two modes: running, and stepping. While running, the PIC program will be simulated in realtime. To allow stepping, the PIC program must be paused - either by clicking on Interrupt in the Debug menu, or clicking on the pause button on the PIC component.</para> + + <para>In stepping mode, a green arrow in the margin of the text document indicates the next line to be executed (familiar to KDevelop users). It may be useful to turn on the icon border via the View menu (it can be permanently turned on via the Editor Settings dialog).</para> + + <para>There are three types of stepping:</para> + + <itemizedlist> + <listitem><para>Step into - This executes the current instruction. The green arrow is moved onto the next line to be executed.</para></listitem> + <listitem><para>Step over - If the next instruction to be executed is a call, or similar, then this will "step over" the call, returning to stepping mode once the call has returned. Otherwise, stepping over an instruction behaves identically to step. To put it technically - the initial stack level is recorded, and the program execution is paused once the stack level returns to its initial level.</para></listitem> + <listitem><para>Step out - If the current execution is inside a call, or similar, then this will wait until the call returns. Similarly to stepping over, this is equivalent to waiting until the stack level returns to one less than the initial level, if the initial level is greater than zero.</para></listitem> + </itemizedlist> + + <para>Breakpoints allow the execution to be paused when the PIC program reaches a given instruction. To toggle a breakpoint on the line containing the cursor, either use the Debug menu, or click on the icon border of the text document.</para> + + <para>The "Symbol Viewer" sidebar on the right shows the values of the Special Function Registers. To find out the value of a variable in the General Purpose Registers, you can hover your mouse over the variable name in an instruction that operates on that register. Note that the radix selection in the Symbol Viewer also controls how the value is displayed when hovering over a variable.</para> + </sect1> + +</chapter> diff --git a/doc/en/faq.docbook b/doc/en/faq.docbook new file mode 100644 index 0000000..a68e46e --- /dev/null +++ b/doc/en/faq.docbook @@ -0,0 +1,68 @@ +<!-- kate: tab-width 2; indent-mode xml; --> +<chapter id="faq"> +<title>FAQ</title> + +<qandaset> + <qandaentry> + <question> + <para>Configure can't find gpsim</para> + </question> + + <answer> + <para>Configure will attempt to compile several files to test for gpsim presence; testing for versions 0.21.4, 0.21.11 and 0.21.12. These files uses part of the gpsim API, that is also used by &kappname;, and was introduced in the respective gpsim versions. If it fails in compiling this program, it will display the warning to the user, and PIC simulation support will not be compiled into &kappname;. There are a number of possibly reasons for finding gpsim to fail:</para> + + <itemizedlist> + <listitem><para>gpsim >= 0.21.4 is not installed. &kappname; does not support gpsim-0.21.2 or gpsim-0.20.14 (or any earlier versions). Later versions may work; but this cannot be tested before they are released. The latest gpsim can be obtained from the <ulink url="http://www.dattalo.com/gnupic/gpsim.html">gpsim website</ulink>.</para></listitem> + <listitem><para>Gpsim is installed, but the header files could not be found. If gpsim is installed in a non-standard location, you may need to specify the location of the header files with "./configure --with-extra-includes=DIR". It is also likely you'll need to specify a library location with the configure option "--with-extra-lib" if the includes are in a non-standard location.</para></listitem> + <listitem><para>Gpsim is installed and the headers are somewhere where configure can find them, but there is some other glib craziness occuring.</para></listitem> + </itemizedlist> + + <para>Configure generates the file <computeroutput>config.log</computeroutput> which will contain details of exactly what went wrong. Searching for gpsim in this log should help you decide what's happened. As an example, here is part of the config.log file where one of the gpsim header files is missing:</para> + + <example><title>Possible config.log output where gpsim detection failed</title> + <programlisting> +configure:30956: checking for gpsim 0.21.4 availability +configure:31009: g++ -c -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include +-DQT_THREAD_SUPPORT -O3 -march=athlon-xp -mcpu=athlon-xp -D_REENTRANT +conftest.cc >&5 +conftest.cc:48:35: gpsim/gpsim_interface.h: No such file or directory</programlisting> + </example> + + <para>If the config.log doesn't help, please contact the &kappname; developers with the relevant parts of config.log attached.</para> + </answer> + </qandaentry> + <qandaentry> + <question> + <para>&kappname; crashes when running a PIC program</para> + </question> + + <answer> + <para>Version 0.21.11 of gpsim contains a bug that may cause &kappname; to crash on the second running of a PIC program. This bug has since been fixed in gpsim-cvs. The &kappname; website provides a <ulink url="http://ktechlab.org/download/gpsim.php">patched version</ulink> of the stable release of gpsim that fixes this bug.</para> + </answer> + </qandaentry> + + <qandaentry> + <question> + <para>High Level Language (HLL) debugging does not work</para> + </question> + + <answer> + <para>Version 0.21.11 of gpsim contains a bug preventing HLL debugging from working. This bug has since been fixed in gpsim-cvs. The &kappname; website provides a <ulink url="http://ktechlab.org/download/gpsim.php">patched version</ulink> of the stable release of gpsim that fixes this bug.</para> + </answer> + </qandaentry> + + <qandaentry> + <question> + <para>&kappname; uses lots of CPU</para> + </question> + + <answer> + <para>There are several possible causes. Simulation of circuits that contain both reactive and nonlinear components (such as capacitors and transistors) take a lot of CPU time to simulate. You can pause and resume the simulation via the Tools menu.</para> + + <para>Drawing of the work area (in particular, redrawing lots of rapidly updating voltage bars on pins) is also CPU intensive. You can reduce the refresh rate or turn off the voltage bars via the Settings dialog. The refresh rate of the Oscilloscope can also be reduced by right clicking on its display.</para> + + <para>Note that the next major release of &kappname; will be a lot faster in both displaying the work area and simulating reactive and nonlinear components.</para> + </answer> + </qandaentry> +</qandaset> +</chapter> diff --git a/doc/en/flowcode.docbook b/doc/en/flowcode.docbook new file mode 100644 index 0000000..d3af461 --- /dev/null +++ b/doc/en/flowcode.docbook @@ -0,0 +1,52 @@ +<!-- kate: tab-width 2; indent-mode xml; --> +<chapter id="flowcode"> + <title>&flowcode;</title> + + <sect1 id="flowcode_introduction"> + <title>Introduction</title> + + <para>&flowcode; allows for very quick and easy construction of a PIC program. After the user has constructed a flowchart from the program parts available, &kappname; can then convert the flowchart into a number of formats. To output hex, for example, the following chain of conversions takes place:</para> + + <orderedlist> + <listitem><para>The &flowcode; is converted to µbe;; a high-level language whose compiler is distributed with &kappname;.</para></listitem> + <listitem><para>The <command>microbe</command> executable then compiles the µbe; file to PIC assembly.</para></listitem> + <listitem><para>Finally, <command>gpasm</command> takes the PIC assembly file, and outputs the hex for the program.</para></listitem> + </orderedlist> + + <para>Of course, if you don't have gputils installed - with which <command>gpasm</command> is distributed - then the last step can't be performed.</para> + + </sect1> + + <sect1 id="flowcode_creation"> + <title>Creating a Program</title> + + <para>Every &flowcode; program needs a unique starting point - this is the place where your program will be run from on PIC startup. To define this point, open up the FlowParts sidebar on the left, and drag across the Start part. &kappname; will only allow you to use one of these.</para> + + <para>You can then construct your program by using the predefined parts on the left - or insert code of your own (in assembly or µbe; format) via the Embed part. The flow of the program is controlled via the connections between the FlowParts - <xref linkend="connecting_components"/> offers more detail on creating connections.</para> + + <para>&flowcode; imposes limitations in addition to those of Circuits on what can be connected. For example, each FlowPart can only have one output connection. Additional limitations are described in <xref linkend="nestling_flowcode"/>.</para> + </sect1> + + <sect1 id="pic_settings"> + <title>PIC Settings</title> + + <para>When you create a new &flowcode; document, you'll notice a picture of the PIC you're using in the top-left corner of the work area. This represents the initial settings of the PIC.</para> + + <para>Each pin shown on the picture of the PIC shows the initial type of pin (input or output), and its initial state (high or low). You can change these by dragging the pin to set the type, and clicking on it to toggle its state.</para> + + <para>The Settings dialog, invoked by clicking on the Settings button, also allows you to edit the initial pin types and states - in this case, by editing the binary values written to the PORT and TRIS registers. As well as pin settings though, the dialog allows editing of the initial values of variables in the PIC program.</para> + + <para>At the bottom, there is a list of currently defined pin maps, as well as buttons to manipulate them. Pin maps are used to specify how a seven segment or a keypad is connected to a PIC. To use the Seven Segment or the Keypad &flowcode; parts, you will need to define a pin map here first.</para> + + </sect1> + + <sect1 id="nestling_flowcode"> + <title>Nestling &flowcode;</title> + + <para>Many FlowParts, such as subroutines and loops, can contain code of their own. After creating such a container, FlowParts can be added by either dragging or dropping them into the container. The container will be highlighted to indicate that it will become the new parent of the FlowPart.</para> + + <para>The container takes responbility for FlowParts nestled inside. If the expand button is unclicked, all contained FlowParts will be hidden - and likewise, the contents will be shown when the expand button is clicked again. Connections cannot be made between FlowParts in different containers, and the contents of a container will be moved about along with the container.</para> + + </sect1> + +</chapter> diff --git a/doc/en/index.docbook b/doc/en/index.docbook new file mode 100644 index 0000000..707dd17 --- /dev/null +++ b/doc/en/index.docbook @@ -0,0 +1,56 @@ +<?xml version="1.0" ?> +<!-- kate: tab-width 2; indent-mode xml; --> +<!DOCTYPE book PUBLIC "-//KDE//DTD DocBook XML V4.1.2-Based Variant V1.1//EN" "dtd/kdex.dtd" [ + <!ENTITY ktechlab "ktechlab"> + <!ENTITY ktechlab-quick SYSTEM "quick.docbook"> + <!ENTITY ktechlab-pic-programs SYSTEM "picprograms.docbook"> + <!ENTITY ktechlab-circuits SYSTEM "circuits.docbook"> + <!ENTITY ktechlab-flowcode SYSTEM "flowcode.docbook"> + <!ENTITY ktechlab-microbe SYSTEM "microbe.docbook"> + <!ENTITY ktechlab-debugging SYSTEM "debugging.docbook"> + <!ENTITY ktechlab-faq SYSTEM "faq.docbook"> + <!ENTITY kappname "KTechlab"> + <!ENTITY microbe "Microbe"> + <!ENTITY flowcode "FlowCode"> + <!ENTITY % addindex "IGNORE"> + <!ENTITY % English "INCLUDE"> +]> + +<book lang="&language;"> + <bookinfo> + <title>The KTechlab Handbook</title> + <authorgroup> + <author> + <firstname>David</firstname> + <surname>Saxton</surname> + <affiliation><address><email>david@bluehaze.org</email></address></affiliation> + </author> + <author> + <firstname>Daniel</firstname> + <surname>Clarke</surname> + </author> + </authorgroup> + <date>2005-12-27</date> + <releaseinfo>0.3</releaseinfo> + <abstract> + <para>KTechlab is an IDE for microcontrollers and electronics.</para> + </abstract> + <keywordset> + <keyword>KTechlab</keyword> + <keyword>KDE</keyword> + <keyword>Development</keyword> + <keyword>Electronics</keyword> + <keyword>Simulation</keyword> + <keyword>PICs</keyword> + <keyword>Microbe</keyword> + </keywordset> + </bookinfo> + + &ktechlab-quick; + &ktechlab-pic-programs; + &ktechlab-circuits; + &ktechlab-flowcode; + &ktechlab-microbe; + &ktechlab-debugging; + &ktechlab-faq; +</book> diff --git a/doc/en/microbe.docbook b/doc/en/microbe.docbook new file mode 100644 index 0000000..8f5fd13 --- /dev/null +++ b/doc/en/microbe.docbook @@ -0,0 +1,422 @@ +<!-- kate: tab-width 2; indent-mode xml; --> +<chapter id="microbe"> +<title>µbe;</title> +<sect1> + <title>Introduction and General Syntax</title> + <para> + <application>Microbe</application> compiles programs written in the custom language for PICs, as a companion program to <application>&kappname;</application>. The syntax has been designed to suit a &flowcode; program. + + The syntax for running <command>microbe</command> from the commandline is: + + <programlisting>microbe [options] [input.microbe] [output.asm]</programlisting> + + where options are: + <itemizedlist> + <listitem><para><function>--show-source</function> - Puts each line of µbe; source code as a comment in the assembly output before the assembly instructions themselves for that line.</para></listitem> + <listitem><para><function>--no-optimize</function> - Prevent optimization of the instructions generated from the source. Optimization is usually safe, and so this option is mainly used for debugging.</para></listitem> + </itemizedlist> + + The .microbe input file must identify the target PIC by inserting the PIC name at the top of the .microbe file; e.g. the name of a PIC16F84 is "P16F84". + + <example><title>Simple complete µbe; program</title> + <programlisting role="correct"> +P16F84 + +a = 0 +repeat +{ + PORTA = a + a = a + 1 +} +until a == 5 + +end</programlisting> + </example> + </para> + + <sect2 id="namingconventions"> + <title>Naming conventions</title> + <para> + The following rules apply to variable names and labels: + <itemizedlist> + <listitem><para>They can only contain alphanumerical characters [a..z][A..Z][0..9] and the underscore "_".</para></listitem> + <listitem><para>They are case-sensitive.</para></listitem> + <listitem><para>They cannot start with a number.</para></listitem> + <listitem><para>They should not start with "__" (double underscore), as this is reserved for use by the compiler.</para></listitem> + </itemizedlist> + </para> + </sect2> + + <sect2 id="bracingconventions"> + <title>Bracing conventions</title> + <para> + Curly braces, {}, indicate the start and end of a code block. + + They can appear anywhere before the start and after the end of the code block. + + Examples of acceptable code blocks: + <programlisting role="correct"> +statement1 { + some code +}</programlisting> + <programlisting role="correct"> +statement2 { + other code }</programlisting> + + <programlisting role="correct"> +statement3 +{ + other code +}</programlisting> + + <programlisting role="correct"> +statement5 { + code block +} statement6</programlisting> + </para> + </sect2> + <sect2 id="commenting"> + <title>Commenting</title> + <para> + Commenting is similar to C. // comments out the rest of the line. /* and */ denote a multiline comment. + <programlisting role="correct"> +// This is a comment +x = 2 +/* As is this +multiline comment */</programlisting> + </para> + </sect2> + + <sect2 id="structure"> + <title>Program Structure</title> + <para> + The PIC id must be inserted at the top of the program. The end of the main program is denoted with "end". Subroutines must placed after "end". + </para> + </sect2> + + <sect2 id="subroutines"> + <title>Subroutines</title> + <para> + A subroutine can be called from anywhere in the code. Syntax: + </para> + <programlisting role="correct"> +sub SubName +{ + // Code... +}</programlisting> + <para>The subroutine is called with "call SubName".</para> + </sect2> +</sect1> + +<sect1 id="languagereference"> + <title>µbe; language reference</title> + <sect2 id="if"> + <title>if</title> + <para>Conditional branching. + + Syntax: + <programlisting role="correct">if [expression] then [statement]</programlisting> + or + <programlisting role="correct"> +if [expression] then +{ + [statement block] +}</programlisting> + + Similarly for else: + <programlisting role="correct">else [statement]</programlisting> + or + <programlisting role="correct"> +else +{ + [statement block] +}</programlisting> + </para> + + <example><title>if</title> + <programlisting role="correct"> +if porta.0 is high then +{ + delay 200 +} +else +{ + delay 300 +}</programlisting> + </example> + </sect2> + + <sect2 id="alias"> + <title>alias</title> + <para>Aliases one string to another. Syntax: + <programlisting role="correct">alias [from] [to]</programlisting> + </para> + </sect2> + + <sect2 id="repeat"> + <title>repeat</title> + <para>Executes the statement block repeatedly until expression evaluates to true. + + The evaluation of the expression is performed after the statement block, so the statement block will always be executed at least once. Syntax: + <programlisting role="correct"> +repeat +{ + [statement block] +} +until [expression]</programlisting> + </para> +</sect2> + +<sect2 id="while"> +<title>while</title> + <para> + Similar to repeat, this repeatedly executes the statement block. However, the expression is evaluated before execution, not after. So if the expression evaluates to false on the first pass, then the statement block will not get executed. + + Syntax: + <programlisting role="correct"> +while [expression] +{ + [statement block] +}</programlisting> + </para> +</sect2> + + +<sect2 id="goto"> + <title>goto</title> + <para> + This causes execution of the code to continue at the next statement after the label specified. + + Goto syntax: + <programlisting role="correct"><function>goto</function> [labelname]</programlisting> + + Label syntax: + <programlisting role="correct"><function>labelname:</function></programlisting> + + It is often considered good programming practice to avoid the use of goto. Use of control statements and subroutines will result in a much more readable program. + </para> + + <example><title>goto</title> + <programlisting role="correct"> +goto MyLabel + +... + +[MyLabel]: +// Code will continue at this point</programlisting> + </example> + </sect2> + + <sect2 id="call"> + <title>call</title> + <para> + Calls a subroutine. + + Syntax: + <programlisting role="correct"><function>call</function> [SubName]</programlisting> + where SubName is the name of the subroutine to be called. + </para> + </sect2> + + <sect2 id="delay"> + <title>delay</title> + <para> + This causes the code execution to stop for the given period of time. The interval is in milliseconds. + + Syntax: + <programlisting role="correct"><function>delay</function> [interval]</programlisting> + + <note><para>At present, µbe; assumes that the PIC is operating at a frequency of 4Mhz - i.e. each instruction takes 1 microsecond to execute. If this is not the case, the interval must be adjusted proportionately.</para></note> + </para> + </sect2> + + <sect2 id="sevenseg"> + <title>sevenseg</title> + <para>This is used to define the pin mapping for a (common cathode) seven segment display connected to the PIC. Syntax: + <programlisting role="correct"><function>sevenseg</function> [name] [a] [b] [c] [d] [e] [f] [g]</programlisting> + + where [a]...[g] are the PIC pins to which the respective segments of the seven segment display are attached. The pins can be written either as PORTX.N or RXN. + </para> + + <para>To display a number on the seven segment, the pin mapping is treated as a write only variable. + <example> + <title>Defining and outputting to a seven segment</title> + <programlisting role="correct"> +sevenseg seg1 RB0 RB1 RB2 RB3 RB4 RB5 RB6 +seg1 = x + 2</programlisting> + </example> + </para> + </sect2> + + <sect2 id="keypad"> + <title>keypad</title> + <para>This is used to define the pin mapping for a keypad connected to the PIC. Syntax: + <programlisting role="correct"><function>keypad</function> [name] [row 1] ... [row 4] [column 1] ... [column n]</programlisting> + + where [row 1] ... [row 4] and [column 1] ... [column n] are the PIC pins to which the respective rows and columns of the keypad are attached (at the moment, the number of rows is not changeable). See <xref linkend="sevenseg"/> (above) for more information on pin mappings. + </para> + + <para>The columns of the keypad should be pulled down via 100k resistors to ground. The row pins must be configured as outputs and the column pins as inputs. Once the keypad has been defined, it is treated as a read only variable. + <example> + <title>Defining and reading from a keypad</title> + <programlisting role="correct"> +keypad keypad1 RB0 RB1 RB2 RB3 RB4 RB5 RB6 +x = keypad1</programlisting> + </example> + </para> + + <para> + By default, the values returned for a keypad are: + <itemizedlist> + <listitem><para>The value of the number if it is a numeric key (1 to 3 along top row; hexadecimal A to D down the fourth column and continuing for each extra column).</para></listitem> + <listitem><para>253 for the key in row 4, column 1.</para></listitem> + <listitem><para>254 for the key in row 4, column 3.</para></listitem> + </itemizedlist> + These values can be redefined by using the alias command, where the name of the key in row x, column y (rows and columns starting at 1), is Keypad_x_y. For example, to give the star key on a 4x3 keypad the value zero, the following alias would be used: + <example> + <title>Aliasing a keypad key to a value</title> + <programlisting role="correct">alias Keypad_4_1 0</programlisting> + </example> + </para> + </sect2> +</sect1> + +<sect1 id="picio"> +<title>PIC I/O</title> + + <sect2 id="tristate"> + <title>Port Direction</title> + <para> + The port direction is set by assigning a value to TRIS*, where * is the port letter. For example: + </para> + <example><title>Setting port directions</title> + <programlisting role="correct">TRISB = b'01111001'</programlisting> + </example> + <para> + The above sets pins RB1, RB2 and RB7 on PORTB as outputs, and the other pins on PORTB as inputs. In this example, b'01111001' is a binary representation of the output type. The 1 on the right represents an output on RB0, and the 0 on the left represents an input on RB7. + </para> + </sect2> + + <sect2 id="ports"> + <title>Port I/O</title> + <para> + The port can be treated as a variable. For example: + </para> + + <example><title>Writing to a port</title> + <programlisting role="correct">x = PORTA</programlisting> + </example> + + <para> + The above assigns the value of PORTA to the variable x. + </para> + </sect2> + + <sect2 id="pins"> + <title>Pin I/O</title> + <para> + Each pin on a port is obtained by prefixing the pin number by the port name; e.g. Pin 2 (starting from Pin 0) on PORTA is known as + <emphasis>PORTA.0</emphasis>. + + The syntax to set a pin state is: + <programlisting role="correct">PORTX.N = <emphasis>STATE</emphasis></programlisting> + where <emphasis>STATE</emphasis> can be <emphasis>high</emphasis> or <emphasis>low</emphasis>. + + The syntax to test a pin state is: + <programlisting role="correct"><function>if</function> PORTX.N is <emphasis>STATE</emphasis> <function>then</function></programlisting> + + Combining these examples, we have: + </para> + <example><title>Setting and testing pin state</title> + <programlisting role="correct"> +TRISA = 0 +TRISB = 255 +<function>if</function> PORTA.3 is <function>high</function> <function>then</function> +{ + PORTB.5 = <function>low</function> +} +<function>else</function> +{ + PORTB = PORTA + 15 +}</programlisting> + </example> + </sect2> +</sect1> + +<sect1 id="variables"> +<title>Variables</title> + <para> + All variables are 8-bit unsigned integers, giving a range from 0 to 255. + + <application>µbe;</application> supports the typical unary operations (acting on one variable) and binary operations (acting on two variables) that are supported by the PIC. In addition, µbe; also supports division and multiplication. + </para> + <sect2 id="unary"> + <title>Unary Operations</title> + <para> + <itemizedlist> + <listitem><para><emphasis>rotateleft x</emphasis> - Rotates the variable x left through carry.</para></listitem> + <listitem><para><emphasis>rotateright x</emphasis> - Rotates the variable x right through carry.</para></listitem> + <listitem><para><emphasis>increment x</emphasis> - Increments the variable x. If x has a value of 255, then x wraps round to 0.</para></listitem> + <listitem><para><emphasis>decrement x</emphasis> - Decrements the variable x. If x has a value of 0, then x wraps round to 255.</para></listitem> + </itemizedlist> + </para> + </sect2> + + <sect2 id="arithmetic"> + <title>Arithmetic</title> + <para> + Supported operations: + <itemizedlist> + <listitem><para><emphasis>Addition:</emphasis> x + y</para></listitem> + <listitem><para><emphasis>Subtraction:</emphasis> x - y</para></listitem> + <listitem><para><emphasis>Multiplication:</emphasis> x * y</para></listitem> + <listitem><para><emphasis>Division:</emphasis> x / y</para></listitem> + <listitem><para><emphasis>Binary XOR:</emphasis> x XOR y</para></listitem> + <listitem><para><emphasis>Binary AND:</emphasis> x AND y</para></listitem> + <listitem><para><emphasis>Binary OR:</emphasis> x OR y</para></listitem> + </itemizedlist> + </para> + </sect2> + + <sect2 id="comparison"> + <title>Comparison</title> + <para> + Supported operations: + <itemizedlist> + <listitem><para><emphasis>Equals:</emphasis> x == y</para></listitem> + <listitem><para><emphasis>Does not equal:</emphasis> x != y</para></listitem> + <listitem><para><emphasis>Is greater than:</emphasis> x > y</para></listitem> + <listitem><para><emphasis>Is less than:</emphasis> x < y</para></listitem> + <listitem><para><emphasis>Is greater than or equal to:</emphasis> x >= y</para></listitem> + <listitem><para><emphasis>Is less than or equal to:</emphasis> x <= y</para></listitem> + </itemizedlist> + + For example: + </para> + <example><title>Comparison</title> + <programlisting role="correct"> +<function>if</function> PORTA >= 5 <function>then</function> +{ + ... +}</programlisting> + </example> + </sect2> +</sect1> + +<!-- +<sect1 id="interrupts"> +<title>Interrupts</title> + <para> + There are several types of events, and some of these take an optional parameter making + the condition under which the routine is called more specific. + <itemizedlist> + <listitem><para><emphasis>changed <pin name></emphasis> + - Occurs when the state of the specified pin changes. Pin name is in the usual syntax of PORTX.n, e.g. <programlisting>interrupt changed PORTB.4</programlisting></para></listitem> + <listitem><para><emphasis>triggered</emphasis> - Rotates the variable x right through carry.</para></listitem> + <listitem><para><emphasis>timer</emphasis> - ///TODO</para></listitem> + <listitem><para><emphasis>write_complete</emphasis> - ///TODO</para></listitem> + </itemizedlist> + </para> +</sect1> +--> +</chapter> diff --git a/doc/en/picprograms.docbook b/doc/en/picprograms.docbook new file mode 100644 index 0000000..e9e3306 --- /dev/null +++ b/doc/en/picprograms.docbook @@ -0,0 +1,44 @@ +<!-- kate: tab-width 2; indent-mode xml; --> +<chapter id="pic_programs"> + <title>PIC Programs</title> + + <sect1 id="manipulation"> + <title>Manipulation</title> + + <para>When you create a FlowCode or a Text document, you'll notice a drop down menu in the toolbar with a rocket icon. From here, you can manipulate your PIC program; changing it to different forms.</para> + + <itemizedlist> + <listitem><para>Convert to µbe; - This is used only in &flowcode; documents. This is explained further in <xref linkend="flowcode"/>.</para></listitem> + + <listitem><para>Convert to Assembly - This can be used in four contexts. When a &flowcode; document is open, it will output the &flowcode; as assembly instructions. When a µbe; document is open, it will invoke the <command>microbe</command> program distributed with &kappname; to compile the program. Similarly, if a C program is open, it will attempt to compile it via SDCC. When a text document containing PIC hex is open, it will invoke <command>gpdasm</command> to disassemble the hex.</para></listitem> + + <listitem><para>Convert to Hex - This can also be used in four contexts. As with Convert to Assembly, this can be used with &flowcode;, µbe; and C documents. It will also be enabled when an assembly document is open to assemble it via <command>gpasm</command>.</para></listitem> + + <listitem><para>Upload to PIC - This assembles the PIC program currently being edited, and uploads it using the programmer that the user has selected.</para></listitem> + </itemizedlist> + + <para>None of these actions require the current document to be saved - very useful for when a quick program is required. For non-PIC targets, the Output Dialog invoked on clicking on one of these actions can either output the result (always text in the above three cases) to a fresh document, or to a file. If the output is saved to file, it also provides options to load the file after creation, and adding the newly created file to the open project (if one is open).</para> + + <para>Note that you can make &kappname; always use the same view for displaying the outputed content by selecting the option under General Settings.</para> + </sect1> + + <sect1 id="uploading"> + <title>Uploading</title> + + <para>&kappname; uses third-party programmers to upload programs to PICs. A variety of common programmers come predefined. Others can be added via the Settings dialog. See the <ulink url="http://ktechlab.org/pic_programmers.php">&kappname; website</ulink> for more information.</para> + + <para>The list of ports is obtained from scanning for serial and parallel ports that are readable and writable. Serial ports are looked for in: + <itemizedlist> + <listitem><para>/dev/ttyS<emphasis>[0..7]</emphasis></para></listitem> + <listitem><para>/dev/tts/<emphasis>[0..7]</emphasis></para></listitem> + <listitem><para>/dev/ttyUSB<emphasis>[0..7]</emphasis></para></listitem> + <listitem><para>/dev/usb/tts/<emphasis>[0..7]</emphasis></para></listitem> + </itemizedlist> + Parallel ports are looked for in: + <itemizedlist> + <listitem><para>/dev/usb/parport<emphasis>[0..7]</emphasis></para></listitem> + <listitem><para>/dev/usb/parports/<emphasis>[0..7]</emphasis></para></listitem> + </itemizedlist> + </para> + </sect1> +</chapter> diff --git a/doc/en/quick.docbook b/doc/en/quick.docbook new file mode 100644 index 0000000..3785ba7 --- /dev/null +++ b/doc/en/quick.docbook @@ -0,0 +1,42 @@ +<!-- kate: tab-width 2; indent-mode xml; --> +<chapter id="quick"> + <title>Quick Tour</title> + + <sect1 id="introduction"> + <title>Introduction</title> + + <para>&kappname; is an IDE for electronic circuits and microcontrollers. It can perform simulation a variety of components (logic, integrated, linear, nonlinear and reactive), simulation and debugging of PIC microcontrollers via gpsim, and comes with its own closely-linked and complementary high level languages: &flowcode; and µbe;.</para> + + <para>It has been designed to be as easy to use and unintrusive as possible; all components and FlowParts have context sensitive help, and simulating electronics is as simple as dragging components onto the work area and creating connectors that autoroute themselves between their pins. &flowcode; allows users new to PICs to instantly create their own programs, while the electronic simulation allows stepping through a PIC's assembly program inside a circuit.</para> + </sect1> + + <sect1 id="documents"> + <title>Documents</title> + <para>To get started in &kappname;, you will need to create a new document, whose type will depend on your task: + + <itemizedlist> + <listitem><para>&flowcode; Document - Construct a PIC program via flowcharting.</para></listitem> + <listitem><para>Circuit Document - Simulate electronics circuits and microcontrollers.</para></listitem> + <listitem><para>µbe; Document - High level language for PICs, also used by &flowcode; to generate assembly.</para></listitem> + <listitem><para>Assembly Document - Start writing a PIC assembly program.</para></listitem> + </itemizedlist> + + &kappname; uses a Document-View model, in that the Document logic is completely seperate from open views of the document. This allows several views of the same file.</para> + + <para>On creating a new document, the view is created in a seperate tab. Each tab can support any number of views, tiled in any arbitary pattern. This allows, for example, simulating a PIC program in circuit, while stepping through the program in an assembly document in the same tab.</para> + + <para>The contents of tabs can be duplicated by dragging the tab to an empty area on the tab bar. They can be inserted into an existing tab by dragging it onto that tab.</para> + + <para>Detailed instructions on the above documents can be found in their own respective chapters.</para> + </sect1> + + <sect1 id="drawing"> + <title>Drawing</title> + + <para>In Circuit and &flowcode; documents, there are several drawing tools available, including text. These are available by clicking on the paintbrush icon in the toolbar. To draw, drag the mouse to form either a shape or a line appropriate to the drawing tool in use.</para> + + <para>When a drawing is selected, it can be resized by dragging its handles. Holding down shift while dragging will snap the handle to the underlying grid. Each tool has basic options accessible from the toolbar, such as colours. There are also more advanced options found in the Item sidebar, such as line and cap styles.</para> + + </sect1> + +</chapter>
\ No newline at end of file |