🗐 電装工芸日記 - 舞台照明機器の製作とか -

能登半島地震で被災された方々にお見舞い申し上げます。

or 管理画面へ

No.724

Icon of admin
 Python で Open DMX USB を動かすことに成功しました。
 setbreakon と setbreakoff の挙動は予想の通りでした。
 以下がテストソースです。
 slot1 と slot512 を 0 から255 までカウントして終了します。
### Open DMX USB test ###
import ftd2xx as ftd
import time

if __name__ == '__main__' :
 baudrate = 250000
 word_length = 8
 stop_bit = 2
 parity = 0
 purge_tx = 2
 try :
  d = ftd.open( 0 ) # Open first FTDI device
  d.setBaudRate( baudrate )
  d.setDataCharacteristics( word_length, stop_bit, parity )
  d.purge( purge_tx )
  channelVals = bytearray( [ 0 ] * 513 )
  channelVals[ 0 ] = 0 # start code
  for i in range( 256 ) :
   try :
    channelVals[ 1 ] = i
    channelVals[ 512 ] = i
    channelbytes = bytes( channelVals )
    # Send Slot
    cstart = time.perf_counter_ns( )
    d.write( channelbytes )
    while time.perf_counter_ns( ) - cstart < 22800000 :
     pass
    # Break Time
    d.setBreakOn( )
    cstart = time.perf_counter_ns( )
    while time.perf_counter_ns( ) - cstart < 192000 :
     pass
    # Mark After Break
    d.setBreakOff( )
    cstart = time.perf_counter_ns( )
    while time.perf_counter_ns( ) - cstart < 12000 :
     pass
   # Press Ctl+C to Exit
   except KeyboardInterrupt :
    break
  d.close( )
 except :
  print( 'No Device' )

 time.sleep() は求める精度に足りないので time.perf_counter_ns() を用いています。
 0 から 255 のカウントが5.9秒強で終わるので 43fps くらい。ほぼ規格最大値です。
 本当にコレでいいのかわからんけど、モヤモヤしてたのがスッキリした。

#Python #器具の製作

■当面の課題

桜のライトアップの季節です。花粉症の季節でもあります。
自分は平気ですが、花粉症の部下は死にそうな顔をしています。

編集

■複合検索:

  • 投稿者名:
  • 投稿年月:
  • #タグ:
  • カテゴリ:
  • 出力順序:

■日付検索:

■カレンダー:

2023年9月
12
3456789
10111213141516
17181920212223
24252627282930

■カテゴリ:

■最近の投稿:

最終更新日時:
2024年5月4日(土) 05時49分51秒