Software > Software

2d Mapping Timing Errors

(1/3) > >>

DomoArigato:
I'm having some difficulties with timing error.  I was hoping someone with more experience might be able to shed some light on the issue.  I read the IR tutorial, and it looks to me like I have the exact shift in my 2d mapping that the article describes.  I can eliminate it only by making the servo go ridiculously slow like nearly a second or two for a complete scan.  The servo is going in 61 degree sweeps, and it is supposed to move 60 degrees in .1 seconds.  It looks like it can move that quickly with no problem.  Does anyone know what else could be causing this problem?  Or some suggestions for debugging it?  My code works like this:

When a the timer interrupt is generated, start an ADV conversion.  at the ADC interrupt, store the value and set servo moving to the next location.  I do this for every degree int he 61 degree sweep.

Admin:
Two suggestions . . .

reduce sweep angle
(I do this by adding additional IR sensors to take readings at the same time)

OR

In your code, shift the map by the amount of timing error you get. For example, if a clockwise scan is off by one reading because of timing, in your array shift everything by one byte. Then just trim the array at the far ends.

DomoArigato:
Do you know roughly what kind of delay you had on your servo doing 2d mapping?  Whats a normal delay look like?  Would around 5ms be enough of a delay to read the ADC and let the IR Rangefinder refresh?

Admin:
Hmmm I dont remember the time . . . but I do remember my shift being about 15 degrees off.

Just do your scanner without delay compensation and output the data to your computer. Then you can decide if compensating is worth the trouble . . .

DomoArigato:
So I found the solution to the shifting problem I was having.  The problem was that under no load, the servo would overshoot the desired angle by 10 degrees.  So I was able to get the timing down to 2ms delay for the servo and 5ms delay for the IR Rangefinder and ADC to do their work.  Basically when the servo was moving from left to right it would scan from 10 degrees to 70 degrees, and from right to left it would scan from 50 degrees to -10 degrees.  So I went through my array like normal, storing values in locations 0 to 60, but when I moved from left to right I actually positioned the servo at the degree I was storing the value into -10, and I did +10 when the servo was moving from right to left.  The faster the servo was moving, the futher it would overshoot the desired angle.
Attached is a picture of the output the red line represents the data points moving left to right without compensation.  The green represents the scan moving from right to left without compensation.  The two lines in the middle are the lines with compensation.  The rangefinder was scanning a wall at an angle.

Navigation

[0] Message Index

[#] Next page

Go to full version