三相の方形波信号

ソフトのデバッグに三相の方形波信号が必要になったので、以下のボードを流用してササッと作りました。

BASCOMで5mSecの割り込みを発生させて、割り込み先で以下を実行。
Tint:     ‘timer interrupt routine

        Incr Cnt

        If Pinb.0 = 0 Then

                If Cnt = 33 Then

                      Reset Portc.0

                Elseif Cnt = 66 Then

                       Set Portc.1

                Elseif Cnt = 99 Then

                        Reset Portc.2

                 Elseif Cnt = 132 Then

                         Set Portc.0

                  Elseif Cnt = 165 Then

                          Reset Portc.1

                   Elseif Cnt => 198 Then

                           Set Portc.2

                            Cnt = 0

                    End If

        Else

                    If Cnt = 33 Then

                             Reset Portc.2

                    Elseif Cnt = 66 Then

                             Set Portc.1

                     Elseif Cnt = 99 Then

                              Reset Portc.0

                      Elseif Cnt = 132 Then

                               Set Portc.2

                       Elseif Cnt = 165 Then

                                Reset Portc.1

                        Elseif Cnt => 198 Then

                                 Set Portc.0

                                 Cnt = 0

                         End If

        End If

        Return

スイッチの論理で、UVWの正転かWVUの逆転をシミュレートします。

これで動作チェックを行ったところ動作には問題ありませんでした。

カテゴリー: 未分類 パーマリンク