本文へスキップ

このページは趣味のアマチュア無線から得た知識を纏めたものです。/ This page summarizes the knowledge gained from my hobby of amateur radio. 

QTH Osaka JAPAN

Zone25-ITU45 Locator PM74tu

Programプログラム

コントロールパネル / Controlle Panel on RaspberryPi

konpane

上の制御パネルについて
@ Input Max Speed : 同じ電圧でも車両によって速度が異なるので列車の最高速度を30〜100の数字を入力して調整する。
A PATERN1及びPATERN2 : このボタンをクリックしたらDのStep1〜Step8の短い走行パターンを組み合わせた全自動運転がスタートする。
B CW Start CW Stop : このボタンをクリックしたら右回りの始動停止の手動運転が出来る。
C CCW Start CCW Stop : このボタンをクリックしたら左回りの始動停止の手動運転が出来る。
D Step_1〜Step_8 : 8種類の短い走行パターンを割り付けたボタン。個々に動作確認をした後、各ステップを組み合わせてPATERN1やPATERN2の ボタンで全自動運手をする。
E Poiont1_1,Point1_2 : このボタンをクリックすることでTOMIX電動ポイントをプラットフォーム1番線側又は2番線側に切り替えることが出来る。
F Poiont2_1,Point2_2 : このボタンをクリックすることでTOMIX電動ポイントを本線側又は車庫側に切り替えることが出来る。
G Poiont3_1,Point3_2 : このボタンをクリックすることでTOMIX電動ポイントを車庫のA線側かB線側に切り替えることが出来る。
H 未使用。
I プログラムを閉じて運転を終了する。

About the above control panel
@ Input Max Speed ??: Input a number between 30 and 100 to adjust the maximum speed of the train because the speed varies depending on the train even if the voltage is the same.
A PATERN1 and PATERN2 : When you click this button, fully automatic operation that combines the short driving patterns of Steps 1 to 8 in D will start.
B CW Start CW Stop : If you click this button, then you can clockwise manual operation.
C CCW Start CCW Stop : If you click this button, you can counterclockwise manual operation.
D Step_1〜Step_8 : Buttons with 8 short running patterns assigned. After checking the operation individually, combine each step and use the PATERN1 and PATERN2 buttons to perform fully automatic operation.
E Poiont1_1,Point1_2 : By clicking this button, you can switch the TOMIX electric point to platform 1st line side or 2nd line side.
F Poiont2_1,Point2_2 : By clicking this button, you can switch the TOMIX electric point to the main line side or the yard side.
G Poiont3_1,Point3_2 : By clicking this button, you can switch the TOMIX electric point to the track-A side or the track-B side of the yard.
H Not used yet.
I Close the program and finish the operation.

プログラム ソースコード(Python) / Program source code(Python)

#--Incorporating libraries for makeing control panels
#--制御パネル作成用ライブラリーの取り込み
import tkinter as tk
import tkinter.ttk as ttk

#--Incorporating libraries for motor control, point control, position sensor
#--モーター速度制御、ポイント制御、位置センサー用ライブラリーの取り込み
from gpiozero import * #Motor, Button
from time import sleep
#--GPIO pin allocation (motor driver TA8428K) ###
#--GPIOピン割り付け(モータドライバTA8428K) ###
motor = Motor(20, 21) # GPIO20(pin38)をIN1へ, GPIO21(pin40)をIN2へ繋ぐ
#--GPIO pin allocation (for Button position sensor)
#--GPIOピン割り付け(Button 位置センサー用)
button1 = Button(7) # 位置センサーをGPIO7(pin26)へ
button2 = Button(8) # 位置センサーをGPIO8(pin24)へ
#button3 = Button(13) # 位置センサーをGPIO13(pin33)へ
button4 = Button(16) # 位置センサーをGPIO16(pin36)へ
button5 = Button(25) # 位置センサーをGPIO25(pin22)へ
button6 = Button(26) # 位置センサーをGPIO26(pin37)へ
button7 = Button(27) # 位置センサーをGPIO27(pin13)へ
#--GPIO pin allocation (Motor driver TA8428K is used to the point switching)
#--GPIOピン割り付け( モータドライバTA8428Kをポイント切り替えに使用)
point1 = Motor(22, 23) # pin15, 16( GPIO22, GPIO23)
point2 = Motor(17, 18) # pin11, 12(GPIO17, GPIO18)
point3 = Motor(5, 6) # pin29, 31( GPIO5, GPIO6)

#------------Check the state of the GPIO pin allocated when the program starts---------------#
#------------プログラム起動時に割り付けたGPIOピンの状態をチェック---------------#
print('*****MOTOR*****')
print('motor.value(pin20, 21)= ' ,motor.value)

print('*****SENCER*****')
print('button1.value(pin26)= ' ,button1.value)
print('button2.value(pin24)= ' ,button2.value)
print('button3.value(pin33)= *****' )
print('button4.value(pin36)= ' ,button4.value)
print('button5.value(pin35)= ' ,button5.value)
print('button6.value(pin37)= ' ,button6.value)
print('button7.value(pin13)= ' ,button7.value)

print('*****POINT*****')
print('point1.value(pin22,23)= ' ,point1.value)
print('point2.value(pin17,18)= ' ,point2.value)
print('point3.value(pin29,31)= ' ,point3.value)
#------------------Acceleration----------------------- #
def l_acc():
    maxspeed = int(text_32.get())
    adj = int(maxspeed//20)
    i=0
    print('Train start from Yard to Main Track')
    for i in range(0, maxspeed, adj):
       speed=i/100
       motor.backward(speed)
       sleep(0.3)

    return()
def r_acc():
    maxspeed = int(text_32.get())
    adj = int(maxspeed//20)
    for i in range(0, maxspeed, adj):
       speed=i/100
       motor.forward(speed)
       sleep(0.3)
    return()
#-----------------Decelerate------------------------ #####
def decr_1(): # CW減速1段目
    maxspeed = int(text_32.get())
    adj = int(maxspeed//20)
    reduce=int(maxspeed*0.7)
    i=0
    for i in range(maxspeed, reduce, -adj):
       speed=i/100
       motor.forward(speed)
       sleep(0.1)
    return()
def decr_2(): # CW減速2段目
    maxspeed = int(text_32.get())
    adj = int(maxspeed//20)
    reduce=int(maxspeed*0.7)
    i=0
    for i in range(reduce, 0, -adj):
       speed=i/100
       motor.forward(speed)
       sleep(0.08)
    return()
def decl_1(): # CCW減速1段目
    maxspeed = int(text_32.get())
    adj = int(maxspeed//20)
    reduce=int(maxspeed*0.7)
    i=0
    for i in range(maxspeed, reduce, -adj):
       speed=i/100
       motor.backward(speed)
       sleep(0.1)
    return()
def decl_2(): # CCW減速2段目
    maxspeed = int(text_32.get())
    adj = int(maxspeed//20)
    reduce=int(maxspeed*0.7)
    i=0
    for i in range(reduce, 0, -adj):
       speed=i/100
       motor.backward(speed)
       sleep(0.08)
    return()
#---- ---------------P_All_1------------------------------#
def p_all_1():
    p1() # step1
    p2() # step2
    p3() # step3
    p4() # step4
    p7() # step7
    p8() # step8
    return()
#---- ---------------P_All-_2-----------------------------#
def p_all_2():
    p1() # step1
    p2() # step2
    p3() # step3
    p4() # step4
    p5() # step5
    p6() # step6
    p7() # step7
    p8() # step8
    return()
#---- ---------------P_All-_3-----------------------------#
def p_all_3():
    return()
#---- ---------------P_All-_4-----------------------------#
def p_all_4():
    return()
#---- ---------------Plan1------------------------------#
def p1():
    point3_2() # ポイントを操作場のB線へ切替
    print('Point is switched to Yard_B')
    point2_2() # ポイントを操作場切替
    print('Pont is switched to Yard')
    sleep(1)
    print('Train start(CW) from Yard to Main Track')
    r_acc()
    button1.wait_for_press() # 位置センサー(1)を検出したら
    print('**********Sencer1 is detected for Plat-home_1 **********', button1.value)
    point1_1()
    sleep(1.5) # 回送電車がセンサー1を検出して1番線に停車させる調整時間
    r_stop_1() # 回送電車が1番線に入線して停車
    return()
# -------------Plan2---------------------------- #####
def p2():
    point2_2() # ポイントを操作場へ切替
    print('Pont is switched to 2_2')
    sleep(1)
    point1_2() # ポイントを2番ホームへ切替
    print('Point is switched to Plat-home_2')
    sleep(1)
    point3_1() # ポイントを操作場のA線へ切替
    print('Point is switched to Yard_A')
    sleep(1)
    r_acc() # CW加速
    button1.wait_for_press() # 位置センサー(1)を検出したら
    print('*********Sencer1 is detected for Plat-home_2 **********', button1.value)
    sleep(1.5)
    r_stop_2() # 回送電車が2番線に入線して停車
    print('Then Train will stop at Station(Plat-home_1)')
    return()
#-------------Plan3---------------------------- #####
def p3():
    point2_1() # ポイントを本線に切り替えて
    print('Point is switched to Main-Track')
    sleep(1)
    point1_1() # ポイントを1番線に切り替えると
    print('Point is switched to Plat-home_1')
    point3_1() # ポイントを操作場A線に切り替える
    print('Point is changed to Yard_A')
    sleep(1)
    sleep(2) # しばらくして
    print('After while,Train will start(CCW) from Plat-Home_1')
    l_acc() # CCW加速
    button2.wait_for_press() # 位置センサー(2)を検出して
    print('**********Sencer2 is detected for Plat-home_1 **********', button1.value)
    l_stop_1() # 先ほど発車した電車が再び1番線に停車する
    sleep(1)
    return()
#-------------Plan4---------------------------- #####
def p4():
    point1_2()
    print('Point is changed to Plat-home_2')
    sleep(1)
    print('Then Train start')
    r_acc() # CW加速
    button1.wait_for_press() # 位置センサー(1)を検出したら
    print('********** Sencer1 is detected for Plathome_2 **********', button1.value)
    #point1_2()
    #print('Point is changed to Plathome_2')
    sleep(1)
    r_stop_2() # 電車が2番線に入線して停車
    sleep(1)
    return()
#-------------Plan5---------------------------- #####
def p5():
    point1_1()
    print('Point is changed to Plat-home_2')
    sleep(1)
    print('Then Train start')
    r_acc() # CW加速
    button1.wait_for_press() # 位置センサー(1)を検出したら
    print('********** Sencer1 is detected for Plathome_2 **********', button1.value)
    sleep(1)
    r_stop_1() # 電車が2番線に入線して停車
    sleep(1)
    return()
#-------------Plan6---------------------------- #####
def p6():
    point1_2() # ポイントを1番線に切り替えると
    print('Point is switched to Plat-home_1')
    point3_1() # ポイントを操作場A線に切り替える
    print('Point is changed to Yard_A')
    sleep(1)
    sleep(2) # しばらくして
    print('After while,Train will start(CCW) from Plat-Home_1')
    l_acc() # CCW加速
    button2.wait_for_press() # 位置センサー(2)を検出して
    print('**********Sencer2 is detected for Plat-home_1 **********', button1.value)
    l_stop_2() # 先ほど発車した電車が再び1番線に停車する
    sleep(1)
    return()
#-------------Plan7---------------------------- #####
def p7():
    point1_1()
    print('Pont is switched to 1_1')
    sleep(1)
    point2_2() # ポイントをYardへ切替
    print('Pont is switched to Tard')
    sleep(1)
    point3_1() # ポイントをYardのA線へ切替
    print('Point is changed to Yard_A')
    sleep(1
)     l_acc() # CCW加速
    button1.wait_for_press() # 位置センサー(1)を検出したら
    print('**********Sencer1 is detected for Yard_A **********', button1.value)
    sleep(0.1) # センサー1検出からセンサー6検出までの時間調整
    l_stop_3() # 減速してYardのA線停車
    sleep(1)
    return()
#-------------Plan8---------------------------- #####
def p8():
    point1_2()
    print('Pont is switched to 1_1')
    sleep(1)
    point2_2() # ポイントをYardへ切替
    print('Pont is switched to Tard')
    sleep(1)
    point3_2() # ポイントをYardのA線へ切替
    print('Point is changed to Yard_A')
    sleep(1)
    l_acc() # CCW加速
    button1.wait_for_press() # 位置センサー(1)を検出したら
    print('**********Sencer1 is detected for Yard_A **********', button1.value)
    sleep(0.1) # センサー1検出からセンサー6検出までの時間調整
    l_stop_4() # 減速してYardのA線停車
    sleep(1)
    return()
#-------------Plan9---------------------------- #####
def p9():
    point3_2() # ポイントを操作場のB線へ切替
    print('Point is switched to Yard_B')
    point2_2() # ポイントを操作場切替
    print('Pont is switched to Yard')
    sleep(1)
    print('Train start(CW) from Yard to Main Track')
    r_acc()
    button1.wait_for_press() # 位置センサー(1)を検出したら
    print('**********Sencer1 is detected for Plat-home_1 **********', button1.value)
    point1_1()
    sleep(1.5) # 回送電車がセンサー1を検出して1番線に停車させる調整時間
    r_stop_1() # 回送電車が1番線に入線して停車
#**********************************************
    point2_1() # ポイントを本線に切り替えて
    print('Point is switched to Main-Track')
    sleep(2) # しばらくして
    print('After while,Train will start(CCW) from Plat-Home_1')
    r_acc() # CCW加速
    button1.wait_for_press() # 位置センサー(2)を検出して
    print('**********Sencer1 is detected for Plat-home_1 **********', button1.value)
    point1_2()
    r_stop_2() # 先ほど発車した電車が再び1番線に停車する
    sleep(1)
    p10()
    return()
#-------------Plan10---------------------------- #####
def p10():
    point3_1() # ポイントを操作場のB線へ切替
    print('Point is switched to Yard_B')
    point2_2() # ポイントを操作場切替
    print('Pont is switched to Yard')
    sleep(1)
    point1_1()
    sleep(1)
    print('Train start(CW) from Yard to Main Track')
    r_acc()
    button1.wait_for_press() # 位置センサー(1)を検出したら
    print('**********Sencer1 is detected for Plat-home_1 **********', button1.value)
    sleep(1.5) # 回送電車がセンサー1を検出して1番線に停車させる調整時間
    r_stop_1() # 回送電車が1番線に入線して停車
#
    point1_2()
    print('Pont is switched to Plathome_2')
    sleep(1)
    point2_2() # ポイントをYardへ切替
    print('Pont is switched to Yard')
    sleep(1)
    point3_2() # ポイントをYardのB線へ切替
    print('Point is changed to Yard_B')
    sleep(1)
    l_acc() # CCW加速
    button1.wait_for_press() # 位置センサー(1)を検出したら
    print('**********Sencer1 is detected for Yard_B **********', button1.value)
    sleep(0.3) # センサー1検出からセンサー7検出までの時間調整
    l_stop_4() # 減速してYardのB線停車
    sleep(1)
    p11()
    return()
#-------------Plan11---------------------------- #####
def p11():
    point2_1() # ポイントを本線に切り替えて
    print('Point is switched to Main-Track')
    sleep(1)
    point1_1() # ポイントを1番線に切り替えると
    print('Point is switched to Plat-home_1')
    point3_1() # ポイントを操作場A線に切り替える
    print('Point is changed to Yard_A')

    sleep(1)
    sleep(2) # しばらくして
    print('After while,Train will start(CCW) from Plat-Home_1')
    l_acc() # CCW加速
    button2.wait_for_press() # 位置センサー(2)を検出して
    print('**********Sencer2 is detected for Plat-home_1 **********', button1.value)
    l_stop_1() # 先ほど発車した電車が再び1番線に停車する
    sleep(1)
    p12()
    return()
#-------------Plan12---------------------------- #####
def p12():
    point3_1() # ポイントを操作場のB線へ切替
    print('Point is switched to Yard_B')
    point2_2() # ポイントを操作場切替
    print('Pont is switched to Yard')
    sleep(1)
    point1_1()# ポイントを1切替
    sleep(1)
    print('Train start(CW) from Platform1')
    r_acc()
    button2.wait_for_press() # 位置センサー(1)を検出したら
    print('***** Sencer2 is detected then train stop *****', button1.value)
    sleep(1.5) # 回送電車がセンサー2を検出して停車させる調整時間

    decr_1() # 減速1段目
    sleep(0.05)
    decr_2() # 減速2段目
    sleep(0.05)
    motor.stop()
#
    point1_2()
    print('Pont is switched to Plathome_2')
    sleep(1)
    point2_1() # ポイントをYardへ切替
    print('Pont is switched to Main track')
    sleep(1)
    point3_2() # ポイントをYardのB線へ切替
    print('Point is changed to Yard_B')
    sleep(1)
    l_acc() # CCW加速
    button2.wait_for_press() # 位置センサー(1)を検出したら
    print('***** Sencer2 is detected for Yard_B *****', button2.value)
    sleep(0.3) # センサー1\2検出からセンサー5検出までの時間調整
    l_stop_5() # 減速してYardのB線停車
    sleep(1)
    #p11
    return()
#-------------Plan13---------------------------- #####
走行パターンを追加する予定
#-------------Plan14---------------------------- #####
走行パターンを追加する予定
#-----------------右回り1番線停止用2段減速------------#
def r_stop_1():
    decr_1() # 減速1段目
    button4.wait_for_press()
    print('Sencer4 detected', button4.value)
    decr_2() # 減速2段目
    sleep(0.05)
    motor.stop()
    return()
#----------右回り2番線停止用段減速--- ----#
def r_stop_2():
    decr_1() # 減速1段目
    button5.wait_for_press()
    print('Sencer5 detected', button5.value)
    decr_2() # 減速2段目
    sleep(0.05)
    motor.stop()
    return()
#-------------------左回り1番線停止用2段減速-------------------#
def l_stop_1():
    decl_1() # 減速1段目
    button4.wait_for_press()
    print('Sencer4 detected', button4.value)
    decl_2() # 減速2段目
    sleep(0.05)
    motor.stop()
    return()
#-------------------左回り2番線停止用2段減速------------------#
def l_stop_2():
    decl_1() # 減速1段目
    button5.wait_for_press()
    print('Sencer5 detected', button5.value)
    decl_2() #減速2段目
    sleep(0.1)
    motor.stop()
    return()
#-- ------左回り操作場A線停車用2段減速--- ----#
def l_stop_3():
    decl_1() # 減速1段目
    button6.wait_for_press()
    print('********** Sencer6 detectedfor stop Yard_A *********')
    sleep(0.05)
    decl_2()
    sleep(0.1)
    motor.stop()
    return()
#-- ------左回り操作場B線停車用2段減速--- ----#
def l_stop_4():
    decl_1() # 減速1段目
    button7.wait_for_press()
    print('**********Sencer7 detected for stop Yard_B *********')
    sleep(0.03)
    decl_2()
    sleep(0.1)
    motor.stop()
    return()
#---------------- ---point1-1---1番線用---------------------- #
def point1_1():
    point1.backward(1.0) # 上りポイント切り替え
    sleep(0.3)
    point1.stop() # point.forward(0.0)
    sleep(0.2)
    return()
#--------------- ---point1-2---2番線用------------------------ #
def point1_2():
    point1.forward(1.0) # 2番線へポイント切り替え
    sleep(0.5)
    point1.stop()
    sleep(0.2)
    return()
#------------------point2-1---操作場から本線へ--------------#
def point2_1():
    point2.backward(1.0) # 本線へポイント切り替え
    sleep(0.5)
    point2.stop()
    sleep(0.2)
    return()
#-------------------point2-2---本線から操作場へ-------------- #
def point2_2():
    point2.forward(1.0) # ヤードへポイント切り替え
    sleep(0.5)
    point2.stop() # point.backward(0.0)
    sleep(0.2)
    return()
#------------------- ---point3-1---操作場A線用------------------ #
def point3_1():
    point3.forward(1.0) # 操作場A線へポイント切り替え
    sleep(0.5)
    point3.stop()
    sleep(0.2)
    return()
#--------------------poin3-2---操作場B線用---------------------- #
def point3_2():
point3.backward(1.0) # 操作場B線へポイント切り替え
sleep(0.5)
point3.stop()
sleep(0.2)
return()
#--------------------右回り走行(手動)----------------------------- #
def r_manual():
    maxspeed = int(text_32.get())     print('Manual Inbound Train Start-CW')
    adj = int(maxspeed//20)
    i=0
    for i in range(0, maxspeed, adj):
    speed=i/100
    motor.forward(speed)
    sleep(0.01)
# ---------------右回り走行停止(手動)--------------------------- #
def r_stop_manual():
    maxspeed = int(text_32.get())
    adj = int(maxspeed//20)
    i=0
    for i in range(maxspeed, 10, -adj):
       speed=i/100
       motor.forward(speed)
       sleep(0.01)
    motor.stop()
#---------------l_manual--------------------------- #
def l_manual():
    maxspeed = int(text_32.get())
    print('Manual Inbound Train Start-CCW')
    adj =int(maxspeed//20)
    i=0
    for i in range(0, maxspeed, adj):
       speed=i/100
       motor.backward(speed)
       sleep(0.01)
#---------------l_stop_manual---------------------------#
def l_stop_manual():
    maxspeed = int(text_32.get())
    adj = int(maxspeed//20)
    i=0
    for i in range(maxspeed, 10, -adj):
       speed=i/100
       motor.backward(speed)
       sleep(0.01)
    motor.stop()
#------------------------------------------------------------------------------------
# rootメインウィンドウの設定
root = tk.Tk()
root.title("Raspberery Pi によるNゲージ運転制御")
root.geometry("500x360")
# メインフレームの作成と設置
frame = ttk.Frame(root)
frame.grid(pady=20) # pack(fill = tk.BOTH, padx=20,pady=10)
# StringVarのインスタンスを格納する変数textの設定
text_1 = tk.StringVar(frame)
text_1.set("右回り始動")
text_2= tk.StringVar(frame)
text_2.set("右回り停止")
text_3 = tk.StringVar(frame)
text_3.set("左回り始動")
text_4 = tk.StringVar(frame)
text_4.set("左回り停止")
text_5 = tk.StringVar(frame)
text_5.set("Step_1")
text_6= tk.StringVar(frame)
text_6.set("Step_2")
text_7 = tk.StringVar(frame)
text_7.set("Step_3")
text_8 = tk.StringVar(frame)
text_8.set("Step_4")
text_9 =tk.StringVar(frame)
text_9.set("Step_5")
text_10 =tk.StringVar(frame)
text_10.set("Step_6")
text_11 =tk.StringVar(frame)
text_11.set("Step_7")
text_12 =tk.StringVar(frame)
text_12.set("Step_8")
text_13 = tk.StringVar(frame)
text_13.set("Point1_1")
text_14 = tk.StringVar(frame)
text_14.set("Point1_2")
text_15 = tk.StringVar(frame)
text_15.set("Point2_1")
text_16 = tk.StringVar(frame)
text_16.set("Point2-2")
text_17 = tk.StringVar(frame)
text_17.set("Point3-1")
text_18 = tk.StringVar(frame)
text_18.set("Point3-2")
text_19 = tk.StringVar(frame)
text_19.set("PATERN_1")
text_20 = tk.StringVar(frame)
text_20.set("PATERN_2")
text_21= tk.StringVar(frame)
text_21.set("PATERN_3")
text_22 = tk.StringVar(frame)
text_22.set("PATERN_4")
text_31 = tk.StringVar(frame)
text_31.set("最高速度入力")
text_32 = tk.StringVar(frame)
text_32.set("")
text_e = tk.StringVar(frame)
text_e.set("閉じる")

# 各種ウィジェットの作成
button_1 = tk.Button(frame, activeforeground='red', textvariable=text_1, command=r_manual)#右回り試運転
button_2 = tk.Button(frame, activeforeground='red', textvariable=text_2, command=r_stop_manual)#右回り試運転終了
button_3 = tk.Button(frame, activeforeground='red', textvariable=text_3, command=l_manual)#左回り試運転
button_4 = tk.Button(frame, activeforeground='red', textvariable=text_4, command=l_stop_manual)#左回り試運転
button_5 = tk.Button(frame, textvariable=text_5, fg='blue', activeforeground='red', command=p1) #運行プラン1
button_6 = tk.Button(frame, textvariable=text_6, fg='blue', activeforeground='red', command=p2) #運行プラン2
button_7 = tk.Button(frame, textvariable=text_7, fg='blue', activeforeground='red', command=p3) #運行プラン3
button_8 = tk.Button(frame, textvariable=text_8, fg='blue', activeforeground='red', command=p4) #運行プラン4
button_9 = tk.Button(frame, textvariable=text_9, fg='blue', activeforeground='red', command=p5) #運行プラン5
button_10 = tk.Button(frame, textvariable=text_10, fg='blue', activeforeground='red', command=p6) #運行プラン6
button_11 = tk.Button(frame, textvariable=text_11, fg='blue', activeforeground='red', command=p7) #運行プラン7
button_12 = tk.Button(frame, textvariable=text_12, fg='blue', activeforeground='red', command=p8) #運行プラン8
button_13 = tk.Button(frame, activeforeground='red', textvariable=text_13, command=point1_1)#1番線用ポイント
button_14 = tk.Button(frame, activeforeground='red', textvariable=text_14, command=point1_2)#2番線用ポイント
button_15 = tk.Button(frame, activeforeground='red', textvariable=text_15, command=point2_1)#本線用ポイント
button_16 = tk.Button(frame, activeforeground='red', textvariable=text_16, command=point2_2)#操作場用ポイント
button_17 = tk.Button(frame, activeforeground='red', textvariable=text_17, command=point3_1)#操作場A線用ポイント
button_18 = tk.Button(frame, activeforeground='red', textvariable=text_18, command=point3_2)#操作場B線用ポイント
button_19 = tk.Button(frame, textvariable=text_19, fg='blue', activeforeground='red', command=p_all_1)#
button_20 = tk.Button(frame, textvariable=text_20, fg='blue', activeforeground='red', command=p_all_2)#
button_21 = tk.Button(frame, textvariable=text_21, fg='blue', activeforeground='red', command=p9)#
button_22 = tk.Button(frame, textvariable=text_22, fg='blue', activeforeground='red', command=p10)#
button_e = tk.Button(frame, textvariable=text_e, fg='red', command=quit)# root.destroy)#プログラム終了
label_1 = ttk.Label(frame, textvariable=text_31)
entry_1 = ttk.Entry(frame,textvariable=text_32)

# 各種ウィジェットの設置
label_1.grid(column=1, row=0, padx=10, pady=10) #, pady=(10, 10))#inpitmaxspeed
entry_1.grid(column=2, row=0) # inputmaxspeed
button_1.grid(column=0, row=3, padx=10, pady=10) # r_manual_start
button_2.grid(column=1, row=3, padx=(10, 10)) # l_manual_stop
button_3.grid(column=2, row=3, padx=(10, 10)) # r_manual_starat
button_4.grid(column=3, row=3, padx=(10, 10)) # u_manual_stop
button_5.grid(column=0, row=5, padx=(10, 10)) # plan1
button_6.grid(column=1, row=5, padx=(10, 10)) # plan2
button_7.grid(column=2, row=5, padx=(10, 10)) # plan3
button_8.grid(column=3, row=5, padx=(10, 10)) # plan4
button_9.grid(column=0, row=7, padx=(10, 10)) # plan5
button_10.grid(column=1, row=7, padx=(10, 10)) # plan6
button_11.grid(column=2, row=7, padx=(10, 10)) # plan7
button_12.grid(column=3, row=7, pady=(10, 10)) # plan8
button_13.grid(column=1, row=9, padx=(10, 10)) # point1_1
button_14.grid(column=2, row=9, padx=(10, 10)) # point1_2
button_15.grid(column=1, row=10, padx=(10, 10)) # point2_1
button_16.grid(column=2, row=10, padx=(10, 10)) # point2_2
button_17.grid(column=1, row=11, padx=(10, 10)) # point3_1
button_18.grid(column=2, row=11, padx=(10, 10)) # point3_2
button_19.grid(column=0, row=2, padx=(10, 10)) # ALL Plan1
button_20.grid(column=1, row=2, padx=(10, 10)) # ALL Plan2
button_21.grid(column=2, row=2, padx=(10, 10)) # ALL Plan3
button_22.grid(column=3, row=2, padx=(10, 10)) # ALL Plan4

button_e.grid(column=3, row=13, pady=(10, 10)) # close

root.mainloop()