Back at the university one of the professors stated,
after having gone through a lot of mathematics and found that the sign
of the final expression was wrong, that "the sign is found
experimentally". How many times have I proven him right? |
timer by 10.000 every 1ms, for final stamping. Then, we add the number of 100ns ticks passed since last 1ms timer interrupt whenever a pulse input interrupt is happening. The 1ms interrupt has a lower priority than the pulse interrupt, which means that we have to read the 1ms timer interrupt interrupt pending flag to see if there should have been a 1ms interrupt. We get a critical code segment in there, so we read the flag twice and compared. If the 1ms timer had overflowed I naturally added 10.000 to the time. It cost me days to spot this error. Yes, it was an error. When the final A/D curves were shown in the client's window, we saw that with minutes in between, the curve appeared too far to the left. One of the pulses we read is a reference pulse, so getting it wrong would position the curve wrongly. The curve was 15.5deg wrong, and I could not spot the error until I saw that this corresponded to suspicious exactly 2ms. I then started to look inside the timer/counter & DMA code, expensive code it took me weeks to program. I showed it to a colleague, |
I had subtracted in a similar situation, but at this place I added, because the test program had required no times to become negative. My colleague suggested that if you subtract 1ms instead of add 1ms, you have 2ms? I tried this, and it worked! Now comes the missing previous chapter: Sigma/delta converters have a group delay, where every sample is delayed before they enter the DMA machine. There too, I had subtracted 25 sample times to get it right, until I found out that I had to add that time instead. When this was fixed, I understood the reason for the first mentioned problem, that I had to add to keep time from becoming negative. My problem was that I hadn't figured out and done the group delay compensation when I wrote the counter/timer logic. Had I done this, I just might not have gone into any of these (de)sign/coding errors. The next time I will try to find code which does what I need, or try to have my university teacher's word more mentally present. But then, maybe he is right, that in any case, the sign must be established experimentally? 01.2004 |
Other publications at http://www.teigfam.net/oyvind/pub/pub.html