Video Circles on TinyTv

 

TinyTv is a framework for generating ntsc video using two programmed i/o pins of an Atmel AVR AtTiny12 microcontroller to drive a resistor network serving as an digital to analog converter.

 

 

We will use a second order polynomial in x and y to describe a circle. The following spreadsheet explores the incremental evaluation of the polynomial as a series of addition operations on its coefficients.

 

http://c2.com/doc/Codosome-2/VideoCircles.xls

 

On Sheet2 of this workbook we work out a sample calculation by both direct evaluation (with a polynomial in each cell) and incrementally (with an sum of neighbors in each cell). The two methods are shown to produce the same results. Here are the coefficients for the sample:

 

TinyTv.Coefficients

a

-1

b

-1

c

10

d

20

e

-50

 

And here are the values that we compute from the polynomial. The formulas before each table are the formulas in the spreadsheet cells.

 

 

The y coefficients are only computed once per horizontal scan. References (y2, y1 and y0) are to values from the previous horizontal scan.

 

startVert = b, startHorz = y2

TinyTv.Values

y2

-2

-2

-2

-2

 

startVert = b + d, startHorz = y2+y1

TinyTv.Values

y1

19

17

15

13

 

startVert = e, startHorz = y1+y0

TinyTv.Values

y0

-50

-31

-14

1

 

The x coefficients are computed throughout the horizontal scan. Note x0 depends on y0 which is assumed to be already computed for the current row. Other references (x2, x1 and x0) are to values from the previous horizontal increment.

 

startHorz = 2a, incHorz = x2

TinyTv.Values

x2

-2

-2

-2

-2

-2

-2

-2

-2

-2

-2

-2

-2

-2

-2

-2

-2

 

startHorz = a+c, incHorz = x2+x1

TinyTv.Values

x1

9

7

expected
9 actual

5

expected
9 actual

3

expected
9 actual

9

expected
5 actual

7

expected
3 actual

5

expected
1 actual

3

expected
-1 actual

9

expected
-5 actual

7

expected
-7 actual

5

expected
-9 actual

3

expected
-9 actual

9

expected
-13 actual

7

expected
-15 actual

5

expected
-17 actual

3

expected
-17 actual

 

startHorz = y0, incHorz = x1+x0

TinyTv.Values

x0

-50

-41

expected
-50 actual

-34

expected
-50 actual

-29

expected
-50 actual

-31

expected
-34 actual

-22

expected
-29 actual

-15

expected
-26 actual

-10

expected
-25 actual

-14

expected
-29 actual

-5

expected
-34 actual

2

expected
-41 actual

7

expected
-50 actual

1

expected
-70 actual

10

expected
-83 actual

17

expected
-98 actual

22

expected
-115 actual

 

 

Note that the origin is in the upper-left hand corner of the results. This value, for x=0 and y=0, is simply the constant term, e=-50.

 

Note also that the spreadsheet computes in floating point while TinyTv operates with 8-bit integer arithmetic. For the purposes of this test we have chosen integer coefficients that do not drive the calculation out of range over the small section of interest.

 

Finally Note that the TinyTv implementation increments e on each frame in order to effect an animation that is beyond the capability of the spreadsheet model.