Darren
02 Dec 05, 02:23 PM
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 :
{ 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 :
{ 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;
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 :
{ 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 :
{ 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;