Product ID Calculations

Needed for ProductID Register of Ethercat Core

  • Product ID 3 = 16 Bit MSB of Version
  • Product ID 2 = 16 Bit LSB of Version
  • Product ID 1 = Product Type
  • Product ID 0 = Image Type

In [3]:
def gen_product_id(version="1.2.3", product_type="Ricoh", image_type="User"):
  version_norm = version.lower()
  product_type = product_type.lower()
  image_type   = image_type.lower()
  
  # Calculate Version
  version_split = version_norm.split(".")
  version_int = int(version_split[0])*1000000 + int(version_split[1])*1000 + int(version_split[2])*1
  version_hex = hex(version_int)[2:]
  
  version_msb = version_hex[:-4]
  version_lsb = version_hex[-4:]
  
  print("Ethercat Product ID Registers")
  print("-----------------------------")
  # Product ID 3
  print("Product Version = {:09}  : Product ID 3: 0x0000000{:}".format(version_int,version_msb))
    
  # Product ID 2
  print("                             : Product ID 2: 0x0000{}".format((version_lsb)))
  
  # Product ID 1
  if product_type == "ricoh":
    print("Product Type = Ricoh         : Product ID 1: 0x00005249")
  elif product_type == "konicaminolta":
    print("Product Type = KonicaMinolta : Product ID 1: 0x00004B4D")
  elif product_type == "kyocera":
    print("Product Type = Kyocera       : Product ID 1: 0x00004B59")
  elif product_type == "generic":
    print("Product Type = Generic       : Product ID 1: 0x00004745")
  elif product_type == "xaar":
    print("Product Type = Xaar          : Product ID 1: 0x00005841")
  else:
    print("Product Type = Unknown       : Product ID 1: 0x0000????")
  # Product ID 0
  if image_type == "user":
    print("Image Type   = User          : Product ID 0: 0x00005355")
  elif image_type == "factory":
    print("Image Type   = Factory       : Product ID 0: 0x00004146")
  else:
    print("Image Type   = Unknown       : Product ID 0: 0x0000????")
  print("")

def gen_system_manager(version="1.2.3.0", product_type="Kyocera", printhead_type="KJ4B_QA06NTB_STDV_4B", image_type="User"):
  version_norm   = version.lower()
  product_type   = product_type.lower()
  image_type     = image_type.lower()
  printhead_type = printhead_type.lower()
  
  # Calculate Version
  version_split = version_norm.split(".")
  version_int = int(version_split[0])*2**24 + int(version_split[1])*2**16 + int(version_split[2])*2**8 + int(version_split[3])*2**0
  
  print("System Management Registers")
  print("---------------------------")
  
  # FPGA Version
  print("FPGA Version : 0x{:08X}".format(version_int))
  # Product Type
  if product_type == "generic":
    product_type_msb = 0
  elif product_type == "kyocera":
    product_type_msb = 1
  elif product_type == "konicaminolta":
    product_type_msb = 2
  elif product_type == "ricoh":
    product_type_msb = 3
  elif product_type == "xaar":
    product_type_msb = 4
  else:
    product_type_msb = -1
    
  if printhead_type == "generic":
    product_type_lsb = 0
  elif printhead_type == "kj4b_qa06ntb_stdv_4b":
    product_type_lsb = 0
  elif printhead_type == "kj4b_qg06ntt_pt1v":
    product_type_lsb = 1
  elif printhead_type == "kj4b_yh06wst_stdv":
    product_type_lsb = 2
  elif printhead_type == "kj4b_1200_008st_wfg1":
    product_type_lsb = 3
  elif printhead_type == "km1024i_kmdb" or printhead_type == "km1024_kmdb":
    product_type_lsb = 0
  elif printhead_type == "km1024i_hib" or printhead_type == "km1024_hib":
    product_type_lsb = 1
  elif printhead_type == "gen5":
    product_type_lsb = 0
  elif printhead_type == "gen4":
    product_type_lsb = 1
  elif printhead_type == "xaar_1003_hib" or printhead_type == "xaar_1002_hib":
    product_type_lsb = 0
  else:
    product_type_lsb = -1
    
  if (product_type_msb != -1 and product_type_lsb != -1):
    product_type_int = product_type_msb * 2**16 + product_type_lsb * 2**0
    print("Product Type : 0x{:08X}".format(product_type_int))
  else:
    print("Product Type : 0x????????")
    
  # Image Type
  if image_type == "user":
    print("Image Type   : 0x00005355")
  elif image_type == "factory":
    print("Image Type   : 0x00004146")
  else:
    print("Image Type   : 0x0000????")
  print("")

Product Info Creation

Ricoh GEN5


In [4]:
gen_product_id("2.0.0", "Ricoh", "User")
gen_system_manager("2.0.0.0", "Ricoh", "Gen5", "User")


Ethercat Product ID Registers
-----------------------------
Product Version = 002000000  : Product ID 3: 0x00000001e
                             : Product ID 2: 0x00008480
Product Type = Ricoh         : Product ID 1: 0x00005249
Image Type   = User          : Product ID 0: 0x00005355

System Management Registers
---------------------------
FPGA Version : 0x02000000
Product Type : 0x00030000
Image Type   : 0x00005355

Ricoh GEN4


In [5]:
gen_product_id("1.0.1", "Ricoh", "User")
gen_system_manager("1.0.1.0", "Ricoh", "Gen4", "User")


Ethercat Product ID Registers
-----------------------------
Product Version = 001000001  : Product ID 3: 0x0000000f
                             : Product ID 2: 0x00004241
Product Type = Ricoh         : Product ID 1: 0x00005249
Image Type   = User          : Product ID 0: 0x00005355

System Management Registers
---------------------------
FPGA Version : 0x01000100
Product Type : 0x00030001
Image Type   : 0x00005355

Kyocera KJ4B 30kHz PT1V


In [6]:
gen_product_id("1.1.0", "Kyocera", "User")
gen_system_manager("1.1.0.0", "Kyocera", "KJ4B_QG06NTT_PT1V", "User")


Ethercat Product ID Registers
-----------------------------
Product Version = 001001000  : Product ID 3: 0x0000000f
                             : Product ID 2: 0x00004628
Product Type = Kyocera       : Product ID 1: 0x00004B59
Image Type   = User          : Product ID 0: 0x00005355

System Management Registers
---------------------------
FPGA Version : 0x01010000
Product Type : 0x00010001
Image Type   : 0x00005355

Kyocera KJ4B 30kHz STDV


In [7]:
gen_product_id("1.0.0", "Kyocera", "User")
gen_system_manager("1.0.0.0", "Kyocera", "KJ4B_QA06NTB_STDV_4B", "User")


Ethercat Product ID Registers
-----------------------------
Product Version = 001000000  : Product ID 3: 0x0000000f
                             : Product ID 2: 0x00004240
Product Type = Kyocera       : Product ID 1: 0x00004B59
Image Type   = User          : Product ID 0: 0x00005355

System Management Registers
---------------------------
FPGA Version : 0x01000000
Product Type : 0x00010000
Image Type   : 0x00005355

Kyocera KJ4B 40kHz


In [8]:
gen_product_id("2.0.3", "Kyocera", "User")
gen_system_manager("2.0.3.1", "Kyocera", "KJ4B_YH06WST_STDV", "User")


Ethercat Product ID Registers
-----------------------------
Product Version = 002000003  : Product ID 3: 0x00000001e
                             : Product ID 2: 0x00008483
Product Type = Kyocera       : Product ID 1: 0x00004B59
Image Type   = User          : Product ID 0: 0x00005355

System Management Registers
---------------------------
FPGA Version : 0x02000301
Product Type : 0x00010002
Image Type   : 0x00005355

Kyocera KJ4B 64kHz


In [9]:
gen_product_id("1.0.1", "Kyocera", "User")
gen_system_manager("1.0.1.0", "Kyocera", "KJ4B_1200_008ST_WFG1", "User")


Ethercat Product ID Registers
-----------------------------
Product Version = 001000001  : Product ID 3: 0x0000000f
                             : Product ID 2: 0x00004241
Product Type = Kyocera       : Product ID 1: 0x00004B59
Image Type   = User          : Product ID 0: 0x00005355

System Management Registers
---------------------------
FPGA Version : 0x01000100
Product Type : 0x00010003
Image Type   : 0x00005355

KonicaMinolta 1024i

Version KMDB


In [10]:
gen_product_id("2.0.0", "KonicaMinolta", "User")
gen_system_manager("2.0.0.0", "KonicaMinolta", "KM1024i_KMDB", "User")


Ethercat Product ID Registers
-----------------------------
Product Version = 002000000  : Product ID 3: 0x00000001e
                             : Product ID 2: 0x00008480
Product Type = KonicaMinolta : Product ID 1: 0x00004B4D
Image Type   = User          : Product ID 0: 0x00005355

System Management Registers
---------------------------
FPGA Version : 0x02000000
Product Type : 0x00020000
Image Type   : 0x00005355

Version Calmar HIB


In [11]:
gen_product_id("0.0.0", "KonicaMinolta", "User")
gen_system_manager("1.0.0.0", "KonicaMinolta", "KM1024i_HIB", "User")


Ethercat Product ID Registers
-----------------------------
Product Version = 000000000  : Product ID 3: 0x0000000
                             : Product ID 2: 0x00000
Product Type = KonicaMinolta : Product ID 1: 0x00004B4D
Image Type   = User          : Product ID 0: 0x00005355

System Management Registers
---------------------------
FPGA Version : 0x01000000
Product Type : 0x00020001
Image Type   : 0x00005355

Xaar 1002 & 1003


In [12]:
gen_product_id("1.0.0", "Xaar", "User")
gen_system_manager("1.0.0.0", "Xaar", "Xaar_1003_HIB", "User")


Ethercat Product ID Registers
-----------------------------
Product Version = 001000000  : Product ID 3: 0x0000000f
                             : Product ID 2: 0x00004240
Product Type = Xaar          : Product ID 1: 0x00005841
Image Type   = User          : Product ID 0: 0x00005355

System Management Registers
---------------------------
FPGA Version : 0x01000000
Product Type : 0x00040000
Image Type   : 0x00005355

Generic


In [13]:
gen_product_id("1.0.1", "Generic", "Factory")
gen_system_manager("1.0.1.0", "Generic", "Generic", "Factory")


Ethercat Product ID Registers
-----------------------------
Product Version = 001000001  : Product ID 3: 0x0000000f
                             : Product ID 2: 0x00004241
Product Type = Generic       : Product ID 1: 0x00004745
Image Type   = Factory       : Product ID 0: 0x00004146

System Management Registers
---------------------------
FPGA Version : 0x01000100
Product Type : 0x00000000
Image Type   : 0x00004146

Get Product Info


In [16]:
import binascii
def get_product_id(version="000F4628", product_type="4B4D", image_type="5355"):
  version_norm = version.lower()
  product_type_norm = product_type.lower()
  image_type_norm = image_type.lower()
  
  # Calculate Version
  version_int = int(version_norm,16)
  version_int_string = str(version_int)
    
  # Calculate Product 
  #product_type_ascii = product_type_norm.decode("hex").lower() # py2
  product_type_ascii = product_type_norm.lower()
  
  # Calculate Image
  #image_type_ascii = image_type_norm.decode("hex").lower() # py2
  image_type_ascii = image_type_norm.lower()
  
  # Print Version
  print("Version: {}.{}.{}".format(version_int_string[-9:-6], version_int_string[-6:-3], version_int_string[-3:]))
  
  # Print Product
  if product_type_ascii == "ri":
    print("Product: Ricoh")
  elif product_type_ascii == "km":
    print("Product: KonicaMinolta")
  elif product_type_ascii == "ky":
    print("Product: Kyocera")
  elif product_type_ascii == "ge":
    print("Product: Generic")
  elif product_type_ascii == "xa":
    print("Product: Xaar")
  else:
    print("Product: Unknown")

  # Print Image
  if image_type_ascii == "su":
    print("Image: User")
  elif image_type_ascii == "af":
    print("Image: Factory")
  else:
    print("Image: Unknown")

In [17]:
get_product_id("000f4628", "4b59", "5355")


Version: 1.001.000
Product: Unknown
Image: Unknown