Each PCB will have a simple firmware the does something like this:
def setup():
# determine where in the 200-character sequence this 5-character PCB is
my_position = read_from_dip_switches()
def loop():
while True:
signal = read_from_rs485()
# the first few bits of the signal matched this PCB, so perform the action
if signal.startswith(my_position):
for letter_num in range(5):
action, desired_letter = get_action(signal, letter_num)
if action == "reset":
start_reset(letter_num)
else:
rotate_to_letter(letter_num, letter)
# if there is a motor step to send to a character, send it
do_motor_steps()
# when the reset switch fires on a letter, stop rotating that letter's stepper motor
def respond_to_interrupt(register):
for letter_num in range(5):
if read_interrupt(register) == letter_num:
stop_reset(letter_num)
Basically, we're always reading what comes in on RS485. We're looking for bits that look like this:
6 bits
5 bits
5 bits
5 bits
5 bits
5 bits
DIP switch
Letter 1
Letter 2
Letter 3
Letter 4
Letter 5
There are no more than 30 letters in a character's carousel, so 5 bits is enough to enumerate them all. There are 5 rows * 8 PCBs (controlling five characters each) = 40 PCBs, so 6 bits is enough to specify which PCB is being spoken to (2^6 = 64). A single 32-bit int is enough to tell 5 letters what to do. Forty of these 32-bit ints, or 160 bytes, can reset the entire board.
If the six DIP switches on the PCB are ON-ON-OFF-ON-OFF-OFF then we will only perform actions when the first 6 bits of data coming in over the wire are 110100. Non-matching data will be ignored. If the 5 bits specifying a letter are 11111 (i.e., the number 31 in base 10), that's the signal to reset the character.
Each PCB will have a simple firmware the does something like this:
Basically, we're always reading what comes in on RS485. We're looking for bits that look like this:
There are no more than 30 letters in a character's carousel, so 5 bits is enough to enumerate them all. There are 5 rows * 8 PCBs (controlling five characters each) = 40 PCBs, so 6 bits is enough to specify which PCB is being spoken to (
2^6 = 64
). A single 32-bit int is enough to tell 5 letters what to do. Forty of these 32-bit ints, or 160 bytes, can reset the entire board.If the six DIP switches on the PCB are
ON-ON-OFF-ON-OFF-OFF
then we will only perform actions when the first 6 bits of data coming in over the wire are110100
. Non-matching data will be ignored. If the 5 bits specifying a letter are11111
(i.e., the number 31 in base 10), that's the signal to reset the character.