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.

• startVert = the upper left cell (start of vertical scan)
• startHorz = the left edge cells (start of horizontal scan)
• incHorz = subsequent cells (advancing across a horizontal scan)

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 5 3 9 7 5 3 9 7 5 3 9 7 5 3

startHorz = y0, incHorz = x1+x0

 TinyTv.Values x0 -50 -41 -34 -29 -31 -22 -15 -10 -14 -5 2 7 1 10 17 22

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.