Which CRBasic instruction is used to activate the 7321 relay?

Either the PortSet() or the WriteIO() instruction can be used to open and close the 7321 relay. These instructions are commonly used in conjunction with an IfThen/EndIf construction.

In this first example, the program closes the relay at the top of a 60 second interval and then opens the relay after ten seconds:

BeginProg

            Scan (1,Sec,0,0)

                        If IfTime (0,60,Sec) Then

                                    PortSet(1,1)

                        ElseIf IfTime (10,60,Sec) Then

                                    PortSet(1,0)

                        EndIf

            NextScan

EndProg

 

In this second example, the WriteIO() instruction is used to close the 7321 relay based on the measured panel temperature:

Public PTemp

BeginProg

            Scan (1,Sec,0,0)

                        PanelTemp (PTemp,_60Hz)

                        If PTemp > 25 Then

                                    WriteIO (&B00000001,&B00000001)

                        Else

                                    WriteIO (&B00000001,&B00000000)

                        EndIf

            NextScan

EndProg

This was helpful

FAQs Home