Vladimir Vassilevsky wrote:
> We have to transmit RS-232 by the AC coupled line. Hence the signal has
> to be DC balanced, i.e. have equal amount of ones and zeroes. How many
> bit combinations like that can be made of one byte? How about the
> general case of the block of N bytes?
This is an interesting problem from a mathematical point of view. I'm a
programmer, so I have hacked a small program (see below), which calculates
it for n bits, because this was faster and more safe than when I try to
derive it mathematically. Then I searched the sequence at NJAS and found
this one:
http://www.research.att.com/~njas/sequences/A000984
So for N bytes there are (8*N)!/((4*N)!)^2 possible combinations.
For practical reasons (would be bad to have 10 bytes with 0 and 10 bytes
with 0xff) I would simply use some standard bi-phase encoding, like AES-3
or Manchester.
(loop for bit from 1 to 24 with number = 2
do (loop for i to (1- number) with test = 0
finally (format t "~a ~a~%" bit test)
do (loop for j to bit with sum = 0 and b = i
finally (when (= sum (/ bit 2)) (incf test)) do
(when (= (logand b 1) 1) (incf sum))
(setf b (truncate b 2))))
(setf number (* 2 number)))
--
Frank Buss,
http://www.frank-buss.de,
http://www.it4-systems.de