PDA

View Full Version : TCFMAX overflowing


subot.robot
10-14-05, 10:31 AM
Hi ,
I am having a strange problem with overflow. Can the value of TCFMAX overflow beyond 65535. I am firing an array of srf08 sonars from the servopod and reading the values from it once every 65ms. I am getting large number of overflows i.e. TCFOVFLO is counting at high speed. The PERIOD is set to 10000. But still the TCFMAX value is less than 10000. There is only one state machine running which fires sonars every 65ms. I have used a counter to count the values upto 65ms every time the state machine is run and fire sonar when counter reaches maximum value. The program is big so I am not pasting the code here. I can email the code if necessary.
I am pasting performance test results here for 2 sonars connected to servopod.
XPOD_MAIN OK
TCFMAX ? 7759 OK
TCFMIN ? 631 OK
TCFOVFLO ? 4350 OK
TCFAVG ? 631 OK
TCFMAX ? 7759 OK
TCFOVFLO ? 9318 OK
UNINSTALL SONAR_FIRE OK
If TCFMAX can go beyond 65535 then how can we find out the maximum time taken by the state machine to execute? Can we find out the number of times TCFMAX overflows?
Is it possible find out the time taken to execute the words of Isomax, like the number of clock cycles the machine instructions take to execute? It will be helpful to find out the time taken to execute the time critical parts of the program. Thanks

Regards
Subhash.S

RMDumse
10-14-05, 11:04 AM
One TCFOVFLO is too many. It means your program is taking too long to run. You must be using program counter capture loops to delay the program that long, and those break down the operation of all of IsoMax(TM).

The following code is how I measure the length of a single word in the foreground.

HEX
0C00 CONSTANT SYS_BASE EEWORD ( use 0C00 for '803,'805 )
SYS_BASE 158 + CONSTANT TMRD3_BASE EEWORD ( tD 178 older isomax,TC 158 newer
TMRD3_BASE CONSTANT TMR_CMP1 EEWORD
TMRD3_BASE 5 + CONSTANT TMR_CNTR EEWORD

DECIMAL 28 CONSTANT T0 EEWORD

: T' ( i*x -- j*x n ) ' CFA
TMR_CNTR @ >R EXECUTE TMR_CNTR @ R> ( end start )
2DUP U< IF - TMR_CMP1 @ + ELSE - THEN T0 -
; EEWORD

Use it like

1 2 T' + . DROP

This puts 1 and 2 on the stack, necessary for the operation of +, then T' executes and times +, . prints the result, and we drop the unneeded 3 result form the stack.

subot.robot
10-14-05, 03:33 PM
Thanks for the reply.
Is it possible for TCFMAX to go beyond 65535 and back to 0 and start over all again? Because in as posted in my previous post, TCFMAX is less than 10000. I am not using any program counter capture loops in programas far as I know. I am not able to find out the source of overflow. Most probably it is because I am firing and reading array of sonar. I am using servopod.
I'll try the code u have given to measure the time taken to execute by the word. Thanks.

Regards
Subhash.S

RMDumse
10-14-05, 05:33 PM
Yes, the TCMAX counter, TCFOVFLO's (etc.) incrememnt up, and as such, will overflow and wrap back around to small numbers.

There's no way to catch how many times they wrap, (well, maybe capture TCFOVFLO as the SCHEDULE-RUNS starts, and just before it finishes maybe) because there is no real need to. IF you have wrap, you have a problem, and you must fix it. The system is corrupted.

As far as program counter captures... do you have any DO LOOPs of BEGIN UNTILs or BEGIN WHILE REPEATs in your code? All those have backwards branches which capture the program counter in a specific piece of code, and do not let other processes receive service (and also cause the TCFOVFLO flag to go up). I'm sure you must have them.

subot.robot
11-26-05, 10:14 AM
Hi RMDumse,

HEX
0C00 CONSTANT SYS_BASE EEWORD ( use 0C00 for '803,'805 )
SYS_BASE 158 + CONSTANT TMRD3_BASE EEWORD ( tD 178 older isomax,TC 158 newer
TMRD3_BASE CONSTANT TMR_CMP1 EEWORD
TMRD3_BASE 5 + CONSTANT TMR_CNTR EEWORD

DECIMAL 28 CONSTANT T0 EEWORD

: T' ( i*x -- j*x n ) ' CFA
TMR_CNTR @ >R EXECUTE TMR_CNTR @ R> ( end start )
2DUP U< IF - TMR_CMP1 @ + ELSE - THEN T0 -
; EEWORD


Can you please explain how the above code works to measure the time taken to execute. I am using isopod v2 with isomax version 0.6. Is this older isomax or newer isomax. I ran above code as it is. When I tested for '+' execution time I got the following result.

1 2 T' + . DROP -28 OK
1 2 T' + . -28 OK
. 3 OK
1 2 T' + U. 65508 OK
1 2 T' * U. 65508 OK
. 2 OK
. 3 OK
9 12 T' * U. 65508 OK

is this ok. Will + take 65508 clock cycles to execute. I think it is too large.

: T' ( i*x -- j*x n ) ' CFA
what does ( i*x -- j*x n ) indicate. It shows the state of top of stack before and after execution of T'. But I did not get what are they. I will be really greatful if you can explain the working of this code. Thanks

Regards
Subot.robot

nmitech
12-01-05, 03:43 PM
HEX
0C00 CONSTANT SYS_BASE EEWORD ( use 0C00 for '803,'805 )
SYS_BASE 158 + CONSTANT TMRD3_BASE EEWORD ( tD 178 older isomax,TC 158 newer
TMRD3_BASE CONSTANT TMR_CMP1 EEWORD
TMRD3_BASE 5 + CONSTANT TMR_CNTR EEWORD

DECIMAL 28 CONSTANT T0 EEWORD

: T' ( i*x -- j*x n ) ' CFA
TMR_CNTR @ >R EXECUTE TMR_CNTR @ R> ( end start )
2DUP U< IF - TMR_CMP1 @ + ELSE - THEN T0 -
; EEWORD


1. To use the code above on your V0.6, you need to change the SYS_BASE offset address to 178 instead.
SYS_BASE 178 + CONSTANT TMRD3_BASE EEWORD ( tD 178 older isomax,TC 158 newer

2. You must start the IsoMax clock befor you execute T'
ISOMAX-START
1 2 T' + . DROP

For IsoMax V0.76 or latest,
SYS_BASE 158 + CONSTANT TMRC3_BASE EEWORD
and replace all TMRD3_BASE with TMRC3_BASE


what does ( i*x -- j*x n ) indicate

As Randy explained this from the previous post,

Use it like
1 2 T' + . DROP
This puts 1 and 2 on the stack, necessary for the operation of +, then T' executes and times +, . prints the result, and we drop the unneeded 3 result form the stack.

subot.robot
12-02-05, 05:58 AM
Thanks a lot for taking ur time off to guide me. I was able to measure the execution time of various WORDs.
I found out that I2C communication routines are taking lots of time to compute. I am using i2c communication program from the programs provided by on the website.
I2COUTBYTE is taking 19687 clock cycles to execute. This in turn is causing huge overflow when used to fire and read srf08 sonars. How can we reduce the execution time, and why is it taking so much time to execute. I am using isopod v2 with isomax 0.6.
Even simple function like : SDA? PA1 ON? ; EEWORD is taking 505 clock cycles to execute. Why? is it possible to reduce the execution time. We are planning to connect 10 srf08 sonars which communicate through i2c bus to isopod. it takes more than 65535 clock cycles just to fire a single sonar let alone reading back the range from it.
Time taken to fire sonar = 13475 which is less than time taken for I2COUTBYTE which is 19687. the function to fire sonar uses I2COUTBYTE 3 times apart from other WORDs. so it clearly indicates that it wraps around 65535. Can u let us know how we can reduce this huge execution time?
Thanks

Regards
subot.robot

nmitech
12-02-05, 09:44 AM
Definitely you need an upgrade IsoMax V0.82

If you already signed the IsoMax license and own a JTAG-Cable-10P then simply email to nmisales@newmicros.com to obtain a V0.82 srecord file. If you have not sign the license agreement or do not have a JTAG-Cable-10P, you can either send the unit back to get a free upgrade, or sign up and/or purchase the Jtag cable to upgrade by yourself. Here is the link for the license, also Jtag cable
http://www.newmicros.com/cgi-bin/store/order.cgi?form=prod_detail&part=IsoMax%5BPod%5D

subot.robot
01-19-06, 04:46 AM
Hi nmitech,
0C00 CONSTANT SYS_BASE EEWORD ( use 0C00 for '803,'805 )
What value should we use as SYS_BASE for '807 i.e. servopod. Isomax version is 0.76.

Thanks and Regards
Subot.Robot

nmitech
01-19-06, 09:26 AM
HEX
1000 CONSTANT SYS_BASE EEWORD ( for ServoPod )