In [1]:
def dec_conv(decimal=5, number=10):
print(" i | Decimal | Binary | Hexadecimal")
print("-----+------------+----------------------------------+-------------")
for i in range(number):
print("{0:4} | {1:10d} | {1:032b} | {1:11X}".format(i,decimal+i))
dec_conv(decimal=2000,number=10)
In [2]:
def bin_conv(binary='10011010', number=10):
dec = int(binary, 2)
print(" i | Decimal | Binary | Hexadecimal")
print("-----+------------+----------------------------------+-------------")
for i in range(number):
print("{0:4} | {1:10d} | {1:032b} | {1:11x}".format(i,dec+i))
bin_conv(binary='10011010', number=10) # binary without 0b
In [3]:
def conv_hex(hexa='a', number=10):
dec = int(hexa, 16)
print(" i | Decimal | Binary | Hexadezimal")
print("-----+------------+----------------------------------+-------------")
for i in range(number):
print("{0:4} | {1:10d} | {1:032b} | {1:11x}".format(i,dec+i))
conv_hex(hexa='a', number=10) # hexa without 0x
In [2]:
import numpy as np
# Pixel convert to um
def px_conv(pixel=10, subpixel_resolution=32):
resolutions = [150, 360, 600, 720, 1200, 2400, 4800] # dpi
inch2cm = 2.54 # cm/inch
pixel_pitch = np.empty(shape=[len(resolutions)], dtype=np.float64) # um
for i in range(len(resolutions)):
pixel_pitch[i] = (inch2cm/resolutions[i])*10000 # in um
subpixel = pixel*subpixel_resolution
um = np.empty(shape=[len(resolutions)], dtype=np.float64) # um
for i in range(len(resolutions)):
um[i] = (pixel*pixel_pitch[i])
print(" Pixel | Subpixel | um @ {}dpi | um @ {}dpi | um @ {}dpi | um @ {}dpi | um @ {}dpi".format(resolutions[0], resolutions[1], resolutions[2], resolutions[3], resolutions[4]))
print("---------+----------+--------------+---------------+----------------+----------------+----------------")
print("{0:6}px | {1:8} | {2:10.3f}um | {3:>10.3f}um | {4:>10.3f}um | {5:>10.3f}um | {6:>10.3f}um".format(pixel, subpixel, um[0], um[1], um[2], um[3], um[4]))
print("")
# mm convert to Pixel
def mm_conv(mm=10, subpixel_resolution=32):
resolutions = [150, 360, 600, 720, 1200, 2400, 4800] # dpi
inch2cm = 2.54 # cm/inch
pixel_pitch = np.empty(shape=[len(resolutions)], dtype=np.float64) # um
for i in range(len(resolutions)):
pixel_pitch[i] = (inch2cm/resolutions[i])*10 # in mm
pixel = np.empty(shape=[len(resolutions)], dtype=np.float64)
subpixel = np.empty(shape=[len(resolutions)], dtype=np.float64)
for i in range(len(resolutions)):
pixel[i] = mm/pixel_pitch[i]
subpixel[i] = pixel[i]*subpixel_resolution
print(" mm | Px @ {}dpi | Px @ {}dpi | Px @ {}dpi | Px @ {}dpi | Px @ {}dpi".format(resolutions[0], resolutions[1], resolutions[2], resolutions[3], resolutions[4]))
print("---------+--------------+---------------+----------------+----------------+----------------")
print("{0:6}mm | {1:10.3f}px | {2:>10.3f}px | {3:>10.3f}px | {4:>10.3f}px | {5:>10.3f}px".format(mm, pixel[0], pixel[1], pixel[2], pixel[3], pixel[4]))
print("")
In [6]:
px_conv(pixel=256)
mm_conv(mm=3.1)
px_conv(pixel=3007)
px_conv(pixel=279)
px_conv(pixel=292)
px_conv(pixel=3009)
px_conv(pixel=4961)
px_conv(pixel=16441)
px_conv(pixel=12)
px_conv(pixel=279)
px_conv(pixel=50)
px_conv(pixel=100)
px_conv(pixel=1024)
#px_conv(pixel=1000)
#px_conv(pixel=10000)
#px_conv(pixel=1642)
#px_conv(pixel=682)
mm_conv(mm=1)
mm_conv(mm=2.5)
mm_conv(mm=10)
mm_conv(mm=100)
#mm_conv(mm=1000)
mm_conv(mm=2000)
mm_conv(mm=50)
mm_conv(mm=90)
## Xaar Printhead
#mm_conv(mm=(1.41+0.0235*2))
#mm_conv(mm=(4.74))
## Print Env Dropwatcher
#mm_conv(mm=279.4)
#mm_conv(mm=0.847)
#px_conv(pixel=384)
## Xaar Printhead definitions
#mm_conv(mm=4.798)
#mm_conv(mm=5.298)
px_conv(pixel=13)
px_conv(pixel=279)
px_conv(pixel=292)
px_conv(pixel=1280)
px_conv(pixel=5000)
px_conv(pixel=2000)
px_conv(pixel=10000)
px_conv(pixel=4252)
px_conv(pixel=3118)
px_conv(pixel=3971)
px_conv(pixel=2014)
px_conv(pixel=16536)
px_conv(pixel=24460)
mm_conv(mm=18)
mm_conv(mm=4)
mm_conv(mm=11.9)
mm_conv(mm=0.931+0.931+0.931+0.931+1.016)
px_conv(pixel=3118)
In [16]:
px_conv(pixel=1024*2-32)
px_conv(pixel=1024*3-2*32)
mm_conv(mm=1)
In [6]:
def speed_conversion(speed_mm_sec = None, speed_m_sec = None, speed_m_min = None, speed_km_h = None):
if not(speed_mm_sec == None):
speed_mm_sec = float(speed_mm_sec)
speed_m_sec = float(speed_mm_sec)/1000.0
speed_m_min = float(speed_mm_sec)/1000.0*60.0
speed_km_h = float(speed_m_min)/1000.0*60.0
speed_mph = float(speed_km_h)*0.6214
speed_ft_sec = float(speed_mph)*1.467
elif not(speed_m_sec == None):
speed_mm_sec = float(speed_m_sec)*1000.0
speed_m_sec = float(speed_m_sec)
speed_m_min = float(speed_mm_sec)/1000.0*60.0
speed_km_h = float(speed_m_min)/1000.0*60.0
speed_mph = float(speed_km_h)*0.6214
speed_ft_sec = float(speed_mph)*1.467
elif not(speed_m_min == None):
speed_mm_sec = float(speed_m_min)/60.0*1000.0
speed_m_sec = float(speed_m_min)/60.0
speed_m_min = float(speed_m_min)
speed_km_h = float(speed_m_min)/1000.0*60.0
speed_mph = float(speed_km_h)*0.6214
speed_ft_sec = float(speed_mph)*1.467
elif not(speed_km_h == None):
speed_m_min = float(speed_km_h)*1000/60.0
speed_mm_sec = float(speed_m_min)/60.0*1000.0
speed_m_sec = float(speed_m_min)/60.0
speed_km_h = float(speed_km_h)
speed_mph = float(speed_km_h)*0.6214
speed_ft_sec = float(speed_mph)*1.467
print("| {:>8.5} mm/s | {:>8.5} m/s | {:>8.5} m/min | {:>8.5} km/h | {:>8.5} mph | {:>9.5} ft/s |".format(speed_mm_sec, speed_m_sec, speed_m_min, speed_km_h, speed_mph, speed_ft_sec))
print("| Speed Conversions |")
print("|---------------+--------------+----------------+---------------+--------------+----------------+")
speed_conversion(speed_mm_sec=1) # mm/sec
speed_conversion(speed_m_sec=0.001) # m/sec
speed_conversion(speed_m_min=0.06) # m/min
speed_conversion(speed_km_h=0.0036) # km/h
speed_conversion(speed_m_sec=0.5) # m/s
speed_conversion(speed_m_min=2) # m/min
speed_conversion(speed_m_min=150) # m/min
speed_conversion(speed_m_min=60) # m/min
speed_conversion(speed_m_min=30) # m/min
speed_conversion(speed_m_min=15) # m/min
speed_conversion(speed_m_min=10) # m/min
print("|---------------+--------------+----------------+---------------+--------------+----------------+")
In [13]:
speed = 0.5 # m/s
dpi = 600 # dpi
inch2mm = 25.4 # mm/inch
speed_mm_s = speed*1000 # mm/s
pixel_pitch = (inch2mm/dpi) # mm
fire_freq = speed_mm_s/pixel_pitch # Hz
fire_period = 1/fire_freq
print("Calculating Fire Frequency / Time")
print("----------------------------------")
print("Speed = {} m/s".format(speed))
print("DPI = {}".format(dpi))
print("----------------------------------")
print("Pixel Pitch = {:>5.3} mm = {:>5.4} um".format(pixel_pitch, pixel_pitch*1000))
print("Fire Period = {:>5.2} s = {:>5.3} ms = {} us".format(fire_period, fire_period*1000, fire_period*1000*1000))
print("Fire Frequency = {:>5.2} Hz = {:>5.4} kHz = {} MHz".format(fire_freq, fire_freq/1000, fire_freq/(1000*1000)))