Mydin-Class-TwoRelay3Mod

De MCHobby - Wiki
Sauter à la navigation Sauter à la recherche

Pico3Mod class

Raspberry-Pi Pico based controler for 3 modules DIN case.

Mydin-Class-TwoRelay3Mod-in-case.jpg

The implementation of the class is closely tied to the features of the backplane bpard

Features

Mydin-Class-TwoRelay3Mod-features-01.jpg

Board schematic

Schematic shows how the hardware is wired to the connector.

Mydin-Class-TwoRelay3Mod-schematic-01.png

Mydin-Class-TwoRelay3Mod-schematic-02.png

Mydin-Class-TwoRelay3Mod-schematic-03.png

Mydin-Class-TwoRelay3Mod-schematic-04.png

Examples

The TwoRelay3Mod repository contains many useful examples.

Your knowledge will quickly progress by reading and understanding them.

The following example show how the din object offers the access to the various inputs/outputs of the backplane (the two relays in the present case).

from mydin import configure
from mydin.pico import Pico3Mod
from mydin.backplane.relays import TwoRelay3Mod 
import time

din = configure( Pico3Mod, TwoRelay3Mod )

print( "Manipulate the relays" )
din.rel1.on()
print( "Rel1 is", din.rel1.value() )
time.sleep(1)

din.rel2.on()
print( "Rel2 is", din.rel2.value() )
time.sleep(1)

print( "All relays off" )
for relay in din.relays:
	relay.off()

print( "relays state", [relay.value() for relay in din.relays] )

Class Header

Ancestor none
Class TwoRelay3Mod
Module relays
DIN Size 3 Modules
Descr Backplane with 2 relays (for 3 modules DIN case).

Attributes

out1, out2 : Pin

References to the Pin object controling the Relay.

The names are identicals to those used on the controler connector.

Mydin-Class-TwoRelay3Mod-connector.png

rel1 : Pin

Property returning the out1 reference (controlling the rel1).

rel2 : Pin

Property returning the out2 reference (controlling the rel2).

relays : list

Property returning the list [out1, out2] (list of relays).

Methods

__init__()

Constructor of the TwoRelay3Mod class, specialized class controling two relays for a 3 modules DIN case.

def __init__( self ):

attach()

Creates the required instances (out1 & out2).

Attach the reference & properties to the controler object.

def attach( self, controler ):