• PicŪ Basic


  • A Simple State Machine

    There is a lot of theory about State Machines (SM) that is sometimes very complicated to put into practice. In this little tutorial I have tried to convey my way of applying a complex theory to simple, practical use for PDS user projects.

    History:
    A few years ago I applied a special SM system to some projects. I found this system so effective that I wanted to use it for large programs. So I set up another State Machine structure described in my Spanish tutorials.

    Reviewing my SM projects, I realized that it was possible to extend the automatic functions of the structure to make it easier for the user to create his code. Here is the result. It would be very useful to refresh your pre-processor knowledge, please read the PDS manual.

    When the code runs with a PIC of the K-series (FOSC = 64Mhz), its efficiency is seen. I have tried with the K20 and FOSC series = 80Mhz and it works very well. As well, I use my 80Mhz bootloader for the K20 series.

    I have accompanied the manuals with sample code so you can try this system. The structure of the machine is designed so that the user can take advantage of the dead times in a program such as during delays, to work in the background without using interrupts. Code is written for the Amicus18 Board; but it is easily applied to any PIC project.

    12/04/2017 - Update State Machine Tutorial Part 4.
    Where I have done a complete project of a Clock/Calendar with the programming of the Contrast, Date/Time and 2 alarms. It is an easily expandable project thanks to its state machine structure.
    Please use the last State Machine library version to develop your project. (STMachine01.inc)
    More SM commands have been added.

    05/06/2017 - Update State Machine Tutorial Part 5. A Simple Multitasking System
    Using the same project I have written a code to make a small multitasking system. Also I have kept the code of State Machine #1. It's a very simple system, you will see that you can reuse a lot of code for other projects. You will be able to see some tricks to reduce the lines of codes so that the system works faster. I have been able to test this project with an Amicus18 Board at 80 Mhz, it is wonderful.

    Your success will only depend on your imagination! Enjoy working with a State Machine.

    Download the manuals and code HERE.

    Alberto Freixanet
    April 2017
  • Recent Activity

    towlerg-21522

    VHBexplorer problem

    Thread Starter: John Drew

    Is anyone else having trouble using ISIS? When I try to run ISIS from the Plugin menu I get the following error message: "Access violation at...

    towlerg Today, 00:58 Go to last post
  • Tag Cloud