How to run more logic in a PAC

Discussion in 'Pascal Logic Code Examples' started by Darren, Dec 2, 2005.

  1. Darren

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    The PAC is designed to run small amounts of logic. Unfortunately, at the moment "small" is hard to define.

    It is possible to write code that will physically fit in the PAC, but takes too long to run. In this case, the PAC will reset itself. Currently, the only way to know for sure whether a particular set of code will run is to try it and see (the status LED will show if the logic engine is resetting). This will be improved in the future.

    If you find that you have too much code for the PAC to run, one solution is to make different bits of code run on different loops to reduce the total time taken on any one loop. The downside of this is that it introduces delays, so it is only suitable for non-time-critical code.

    The easiest way is to put delays between chunks of code in a module :

    Code:
    { chunk of code }
    delay(1);
    { chunk of code }
    delay(1)'
    {chunk of code }
    delay(1);
    
    An alternative way which will run a little faster is as follows :

    Code:
    { variables section }
    LoopCount : integer;
    
    { initialisation section }
    LoopCount := 1;
    
    { Module code }
    case LoopCount of 
      1 : { chunk of code };
      2 : { chunk of code };
      3 : { chunk of code };
      4 : { chunk of code };
    end;
    LoopCount := LoopCount + 1;
    if LoopCount = 5 then
      LoopCount := 1;
    
     
    Last edited by a moderator: Dec 2, 2005
    Darren, Dec 2, 2005
    #1
  2. Darren

    Josh

    Joined:
    Aug 25, 2004
    Messages:
    240
    Likes Received:
    0
    Location:
    Pretoria, South Africa
    Local Variables

    Does the PAC support local variables?

    Lookin at the above code, you would have to define a global variable for each module that has chunk of code. If a local variable is defined (or allowed in PAC) it might be a bit easier to maintain. Just my opinion.
     
    Josh, Dec 2, 2005
    #2
  3. Darren

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    No it doesn't. There are certainly benefits for adding local variables, but it is unlikely to happen soon.
     
    Darren, Dec 5, 2005
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.