Pages

Wednesday, May 29, 2013

MCP23S17 based dual 1 of 8 demultiplexer testing OK






















Now I have added the 5V0 version of HC137 beside the 3V3 HC137 decoder.  MCP23S17 Port A GA0 ~ GA5 drives HC137 #1, and Port B drives HC137 #2.

.END

# *****************************************************************************
# Function - TestDemuxV01
# Description - 
#   Disable HC137 all outputs High
#   Enable HC137 any 1 output Low
#   Set HC137 selected output Low
#   Set HC137 output Y0 to Y7 in sequence, hold 1 second
# Sample call - 
#   TestDemuxV01(spiChannelNumber = 0, spiChipEnableNumber = 0, 
#   mcp23s17SubAddress = 0, spiSlaveDeviceNumber = 5)
# *****************************************************************************
  
def TestDemuxV01(spiChannelNumber, spiChipEnableNumber, spiIoxSubAddress, spiSlaveDeviceNumber):

    spiChannel = spidev.SpiDev() 
    spiChannel.open(spiChannelNumber, spiChipEnableNumber)

    DisableDemux(spiChannel, spiIoxSubAddress)
    time.sleep(1)

    EnableDemux(spiChannel, spiIoxSubAddress)
    time.sleep(1)

    for i in range(0, 8, 1):
        SelectSpiSlaveDevice(spiChannel, spiIoxSubAddress, i)
time.sleep(1)

    SelectSpiSlaveDevice(spiChannel, spiIoxSubAddress, spiSlaveDeviceNumber)
    time.sleep(20)

    DisableDemux(spiChannel, spiIoxSubAddress)
    time.sleep(1)

    spiChannel.close()

.END

No comments:

Post a Comment