The Idea in this Production Quality Programmer is to use TxD to control an analog voltage. The analog voltage is controled by the average of the TxD signal.
The Average is controled by transmitting two different bytes. The first byte has N bits high (or N+1 with startbit) and the second has N+1 bits high (or N+2 with startbit).
The Average is Vavg = ((N+1)/10*(1-v) + (N+2)/10*v)*13V where v is in range from 0 to 1.
As example:
N0 = 0000000c (000h)- has (0+c) bits high = (1+c)/10*13V = 1.3V to 2.6V N1 = 0001000c (010h)- has (1+c) bits high = (2+c)/10*13V = 2.6V to 3.9V N2 = 0100100c (048h)- has (2+c) bits high = (3+c)/10*13V = 3.9V to 5.2V N3 = 0101010c (054h)- has (3+c) bits high = (4+c)/10*13V = 5.2V to 6.5V N4 = 1010101c (0AAh)- has (4+c) bits high = (5+c)/10*13V = 6.5V to 7.8V N5 = 1101101c (0DAh)- has (5+c) bits high = (6+c)/10*13V = 7.8V to 9.1V N6 = 1111011c (0F6h)- has (6+c) bits high = (7+c)/10*13V = 9.1V to 10.4V N7 = 1111111c (0FEh)- has (7+c) bits high = (8+c)/10*13V = 10.4V to 11.7VThe values has been chosen for as high signal frequence as possible. The last bit (D0) has been reseved for 'carry' to make it easy to generate Vx+1 value.
A value between 5.2V and 6.5V is obtained by chosing the value 0101010c = $54+c and adding a carry. The carry is generated by a standard 16 bit ADD instruction:
ADD X,v*65536
If v is zero, then carry will never apear, else it apears in (v*65536)/65536 instructions. When adding CF to $54 from the table, and send it to the serial output, will a precise value between 5.2V and 6.5V be selected.
When using TxD for generating an analog voltage is it importent to care about a constant voltage swing due to the low rise time of TxD. If the offset, or if the voltage amplitude changes, then it will affect the duty cycle, and the analog voltage too.