Dan in CA
The function set_output() in the Python program (~line 290) is equivalent to the svc.apply_all_station_bits() function in the micro controller version.
It may be a good idea to explicitly clear everything on start up. Although when the related vars are first defined they are all in a cleared state anyway.
Adding a stop_stations() line just before the timing loop stasrts (~line 973) might help. Actually maybe set_output() instead of stop_stations() would do the trick.