' ' ピンク電話コントロールソフト ' ' 2005/6/5 Ver.1.5 by T.AZAMI Dim time_count Dim time_set_data tris_RA = 0 RA = &HFF Input RA.Bit0 'RA0 電流検出ピン Input RA.Bit1 'RA0 反転検出ピン Output RA.Bit2 'RA2 反転リレー出力 Output RA.Bit3 'RA3 極性検出回路リレー出力 Output RA.Bit4 'RA4 回線切断リレー出力 Low RA.Bit2 '反転リレー OFF Low RA.Bit3 '極性検出回路リレー OFF Low RA.Bit4 '回線切断リレーリレー OFF Initlcd 'LCD初期化 tris_RD = 0 'LEDのポートを出力モードに RD = &HFF 'LEDを全て消灯 start: 'オープニングタイトル表示 Clearlcd Homelcd Putlcd "Pink Tel Controller" Setpos 0,1 Putlcd " Ver.1.5" Sleep 1000 Clearlcd '-----メインループ----- main_loop: time_set_data = 100 '10秒でコインが落ちる 数値=秒数×10 time_count = time_set_data RD = &hff 'Low RA.Bit3 '極性検出回路 切断 'High RA.Bit4 '局線切断(リセット) 'Sleep 1000 'Low RA.Bit4 Clearlcd Putlcd "コウカヲ イレ ダイアル " Setpos 0,1 Putlcd "シテクダサイ " '-----電流ループ検出----- i_detect_loop: If RA.Bit0 = 1 Then Goto i_detect_loop tuuwa: '受話器を上げた場合の処理 Sleep 100 'チャタリング防止 If RA.Bit0 = 1 Then Goto i_detect_loop '再確認 Clearlcd Putlcd "コウカヲ イレ ダイアル " Setpos 0,1 Putlcd "シテクダサイ O~O " Debug "off hook" Low RD.Bit0 'LED点灯 High RA.Bit3 '極性検出回路 ON '-----反転検出ループ----- rev_detect_loop: If RA.Bit0 = 1 Then Goto on_hook '電流ループ検出(受話器が置かれた場合) If RA.Bit1 = 0 Then Goto hanten '反転検出(反転した場合) Goto rev_detect_loop on_hook: Debug "on hook " Sleep 100 If RA.Bit1 = 0 Then Goto hanten Sleep 500 If RA.Bit0 = 1 Then Goto main_loop '本当に受話器を置いているなら戻る Goto rev_detect_loop hanten: '極性が反転した場合の処理 Debug "hanten " 'Sleep 20 'チャタリング防止 'If RA.Bit1 = 1 Then Goto tuuwa_loop1 '再確認 Clearlcd Putlcd "ツウワチュウ " '-----応答収納信号発生 Low RA.Bit3 '極性検出回路 切 High RA.Bit4 '回路切断 Sleep 200 Low RA.Bit2 '反転リレー OFF Low RA.Bit4 '回路接続 Sleep 1200 High RA.Bit4 '回路切断 High RA.Bit2 '反転リレー ON Sleep 100 Low RA.Bit4 '回路接続 High RA.Bit3 '極性検出回路 ON '-----回線接続後、通話中ループ---- tuuwa_loop: If RA.Bit0 = 1 Then tuuwa_end1 '電流ループOFFの場合(受話器を置いた場合) If RA.Bit1 = 1 Then tuuwa_end2 '極性が反転した場合(相手が切った場合) If time_count = 0 Then Gosub time_up '指定時間がきた場合 Setpos 0,1 Putlcd " " Setpos 0,1 Putlcd "ジカン=",time_count/10 time_count = time_count - 1 Sleep 100 Goto tuuwa_loop '-----通話中収納信号発生 time_up: Low RA.Bit3 '極性検出回路 切 High RA.Bit4 '回路切断 Sleep 50 Low RA.Bit2 '反転リレー OFF Low RA.Bit4 '回路接続 Sleep 1200 High RA.Bit4 '回路切断 High RA.Bit2 '反転リレー ON Sleep 100 Low RA.Bit4 '回路接続 High RA.Bit3 '極性検出回路 ON Sleep 100 time_count = time_set_data Goto tuuwa_loop '-----受話器が置かれた場合(電流ループが途絶えた場合)の処理----- tuuwa_end1: Debug "tuuwa_end1" Sleep 500 'チャタリング防止 If RA.Bit0 = 0 Then Goto tuuwa_loop '再確認 Low RA.Bit2 '反転リレー 切 Setpos 0,0 Putlcd "セツダン " Sleep 5000 Clearlcd Putlcd "ジュワキヲ オイテクダサイ" tuuwa_end1_L: If RA.Bit0 = 0 Then Goto tuuwa_end1_L '受話器が置かれたかを判断 High RD.Bit0 'LED消灯 Goto main_loop '-----相手が切った場合(通話中に反転した場合)----- tuuwa_end2: Debug "tuuwa_end2" Sleep 50 'チャタリング防止 If RA.Bit1 = 0 Then Goto tuuwa_loop '再確認 Low RA.Bit2 '反転リレー 切 Clearlcd Putlcd "アイテガワ セツダン " Setpos 0,1 Putlcd "ジュワキヲ オイテクダサイ " tuuwa_end2_L: If RA.Bit0 = 0 Then Goto tuuwa_end2_L '受話器が置かれたかを判断 High RD.Bit0 'LED消灯 Goto main_loop