=====Windows 7 - Mit Python 2.7 über die COM Port Schnittstelle ein M18ST05A VFD Display ansprechen ===== Im Zug eines zufälligen "dump diving" ist mir ein altes VFD Display (M18ST05A) eines alten Medion Rechners (~ Baujahr ~2008) in die Hände gefallen, danke an Herbert. {{ :elektronik:medion_display_v01.png?500 | Medion VFD Display M18ST05A }} === Vorbereitung === Download der Software: * Python 2 => https://www.python.org/downloads/ => python-2.7.9.msi * Python Serial Port Extension => http://sourceforge.net/projects/pyserial/ Installation der Software: * python-2.7.9.msi installieren, Installer starten, alles default, unter D:\Python27 installieren * pyserial-2.7.win32_py3k.exe starten, alles default und installieren === Das Display anschließen === Zum Glück wurde auf dieser Seite die Beschaltung des Medion Display und die Steuer Sequenzen beschrieben * => http://www.hit-karlsruhe.de/aol2mime/medion_md_8800_vfd.htm Einen PL2302HX USB Adapter entsprechend verkabelt (JF LCD 4-Pin-Anschluss?) und damit das Display über den USB Port am PC angeschlossen. Über den Gerätemanager prüfen welcher COM Port für den Adapter vergeben wurden. Ohne dass ein erstes Kommando an das Display geschickt wird, wird allerdings im ersten Schritt NICHTS angezeigt! {{ :elektronik:medion_display_jflcd_anschluss_v01.png?300 | Anschluss des Displays an den USB UART Adapter- JF LCD 4-Pin-Anschluss?}} Das Display wird mit "9600,N,8,1" : „ 9600 baud, keine Parität (None), 8 Datenbits, 1 Stopbit, keine Flussteuerung" angesprochen, es können auf die zwei Zeilen sofort Buchstaben ohne weitere Steuer Sequenzen geschrieben werden. Die COM Ports in der Python Library werde von 0 bis n durchgezählt , daher wird der COM6 um fünften Port! Ein Code Beispiel um das Display anzusprechen und einige der Steuersequenzen zu testen: import serial import struct import binascii import sys import time def printf(format, *args): sys.stdout.write(format % args) #===================================================== # Open the Serial Interface com6 = serial.Serial() com6.port=5 com6.baudrate = 9600 com6.parity=serial.PARITY_NONE com6.rtscts=1 com6.timeout=None com6.stopbits=serial.STOPBITS_ONE com6.bytesize=serial.EIGHTBITS com6.open() #get the status print(com6.isOpen()) #get the settings com6.getSettingsDict() #===================================================== # Write Letters to the first line for i in range(0,16): com6.write("X") time.sleep(0.5) #===================================================== s_send_data = struct.Struct('b b b b') # enable the other elementes with a value > 0 # some of the elements can be dimmed over the value # all normal elements 0x30 for i in range(0,30): for y in range(1,12): printf("Command :: 0x1B 0x30 %d %d \n", i,y) commands=(0x1B, 0x30, i ,y) command_packed_data = s_send_data.pack(*commands) com6.write(command_packed_data) print 'Original values::', commands print 'Format string ::', s_send_data.format print 'Uses ::', s_send_data.size, 'bytes' print 'Packed Value ::', binascii.hexlify(command_packed_data) time.sleep(0.1) # check what happens with 0x31 for i in range(0,30): for y in range(1,12): printf("Command :: 0x1B 0x31 %d %d \n", i,y) commands=(0x1B, 0x31, i ,y) command_packed_data = s_send_data.pack(*commands) com6.write(command_packed_data) print 'Original values::', commands print 'Format string ::', s_send_data.format print 'Uses ::', s_send_data.size, 'bytes' print 'Packed Value ::', binascii.hexlify(command_packed_data) time.sleep(0.1) # check what happens with 0x32 for i in range(0,5): for y in range(1,12): printf("Command :: 0x1B 0x32 %d %d \n", i,y) commands=(0x1B, 0x32, i ,y) command_packed_data = s_send_data.pack(*commands) com6.write(command_packed_data) print 'Original values::', commands print 'Format string ::', s_send_data.format print 'Uses ::', s_send_data.size, 'bytes' print 'Packed Value ::', binascii.hexlify(command_packed_data) time.sleep(0.1) #===================================================== #Switch off the elements # for x in range(0,30): commands=(0x1B, 0x30, x ,0) command_packed_data = s_send_data.pack(*commands) com6.write(command_packed_data) for x in range(0,30): commands=(0x1B, 0x31, x ,0) command_packed_data = s_send_data.pack(*commands) com6.write(command_packed_data) #===================================================== #alternativ #use escaped syntax to pack the data to transmit #Switch on #command="\x1B\x30\x00\x03" #com6.write(command) #Swith off #command="\x1B\x30\x00\x00" #com6.write(command) #===================================================== #Switch to line 2 # command="\x1B\x22" com6.write(command) #Write a letter to line 2 for i in range(0,16): com6.write("W") time.sleep(0.5) #===================================================== # s_send_data = struct.Struct('b b') # #Delete the line commands=(0x1B, 0x50 ) command_packed_data = s_send_data.pack(*commands) com6.write(command_packed_data) #===================================================== #Switch back to line 1 # command="\x1B\x21" com6.write(command) #delete also commands=(0x1B, 0x50 ) command_packed_data = s_send_data.pack(*commands) com6.write(command_packed_data) #===================================================== # Time # #Set the clock 0x1B 0x00 M H T M J J #to set a real date use 2Byte BCD values command="\x1B\x00\x04\x04\x04\x04\x04\x04" com6.write(command) #show the Clock 0x1B 0x05 command="\x1B\x05" com6.write(command) #===================================================== #Close the port com6.isOpen() com6.close() exit() Beim Aufbau des "struct" „s_send_data „ auf das "b" Format achten, damit die 8 Bit Folgen auch so erstellt werden! ==== Quellen ==== * Serial Library => http://pyserial.sourceforge.net/ Einsatz der Library: * => http://pymotw.com/2/struct/ * => http://eli.thegreenplace.net/2009/08/20/frames-and-protocols-for-the-serial-port-in-python * => https://docs.python.org/2/library/struct.html * => http://www.circuitsonline.net/forum/view/118597