Other NPN connetion WEMOS with Optocoupler isalotor

Discussion in 'B4R Questions' started by mtd, Apr 8, 2019.

  1. mtd

    mtd Member

    I want to 2 NPN sensor connect to WEMOS board.
    How can connection digrams? our trial is fail.
    sensor1 effect sensor 2 :(



    Product Introduction Detail:
    1. Driving Port Signal Voltage:3.6-24V
    2. Output Port Voltage Port:3.6-30V
    3. Jumper Cap Can Achieve Output Port Is High POtential Or Pull Down Output
    4. Onboard 4-Channel 817 Are Independent:can achieve different voltage control at then same time
    NOTE:
    The input port is shared with GND;
    The output ports are independent of each other


    [​IMG]

    [​IMG]


    upload_2019-4-8_14-53-42.png
     
  2. tigrot

    tigrot Well-Known Member Licensed User

    Add a 3.3v a weak pullup on wemos 1 and 2.
     
  3. tigrot

    tigrot Well-Known Member Licensed User

    You will get a inverse signal on then
     
  4. mtd

    mtd Member

    Thank you for reply @tigrot ;
    I am not technician (elktronic/automation). Therefore your comment is high level for me.:oops::oops: soryy

    I showed simply it. I connected like under below. And i read code like under below. After I cheked logs....
    Some time; Its wrong. 2 Port(d3 &d4) is open, but its not change !!!!

    upload_2019-4-9_9-55-52.png upload_2019-4-9_9-56-41.png

    Where is the problem? if preoblem has my connections; Please updateb it.



    upload_2019-4-9_9-44-48.png

    Code:
    Sub Process_Globals
        
    Public Serial1 As Serial
        
    Public WiFi As ESP8266WiFi
        
    Public esp As ESP8266
        
    Private eeprom As EEPROM
        
    Private const MAGIC_EEPROM As Byte = 123
        
    Private bc As ByteConverter
        
    Public ww As Boolean
        
    Public Timers As Timer
        
    Private wemos As D1Pins
        
    Public Pin1 As Pin
        
    Public Pin2 As Pin
        
    Public Pin3 As Pin
        
    Public Pin4 As Pin
        
    Public Pin5 As Pin
        
    Public Pin6 As Pin
        
    Public Pin7 As Pin
     
        
    Public P1 As Boolean
        
    Public P2 As Boolean
        
    Public P3 As Boolean
        
    Public P4 As Boolean
        
    Public P4_EX As Boolean
        
    Public P5 As Boolean
        
    Public P6 As Boolean
        
    Public P7 As Boolean
        
    Public durum  As String
        
    Public sayac As Int
    End Sub


     

    Private Sub PIN1_Changed (State As Boolean)
        
    'Log("1--*********pin1 changed",State)
        P1=State
        pinler(
    True)
    End Sub

    Private Sub PIN2_Changed (State As Boolean)
        
    'Log("2--*********pin2 changed",State)
        P2=State
        pinler(
    True)
    End Sub

    Private Sub PIN7_Changed (State As Boolean)
        
    'Log("7--*********pin7 changed",State)
        P7=State
        pinler(
    True)
    End Sub


    'ön kapı
    Private Sub PIN3_Changed (State As Boolean)
        
    'Log("3--*********pin3 changed",State)
        P3=State
        pinler(
    True)
    End Sub

    'home poziyon
    Private Sub PIN4_Changed (State As Boolean)
        
    'Log("4--*********pin4 changed",State)
        P4=State
        pinler(
    True)
        
    Return
        
    If P4<>State Then
            
    'P4=State
            P4=State
            
    If P3=True And P5=False And P6=False Then
                
    'sistem otomatikte
                sayac=sayac+1
            
    End If
         
        
    End If
     
    End Sub


    'Motor
    Private Sub PIN5_Changed (State As Boolean)
        
    'Log("5 --*********pin5 changed",State)
        P5=State
        pinler(
    True)
    End Sub

    'yesiş lamba
    Private Sub PIN6_Changed (State As Boolean)
        
    'Log("6--*********pin6 changed",State)
        P6=State
        pinler(
    True)
    End Sub

    Private Sub pinler(x As Boolean)
        
    If x Then
            
    Log(P1,"-",P2,"-",P3,"-",P4,"-",P5,"-",P6,"-",P7,"  ",Rnd(11,99))',"-",P1,"-",P1,"-",
        Else
            
    Log(P1,"-",P2,"-",P3,"-",P4,"-",P5,"-",P6,"-",P7,"  XXXXX ",Rnd(11,99))',"-",P1,"-",P1,"-",
        End If
    End Sub


    Private Sub AppStart
        Serial1.Initialize(
    115200)
        
    Log("AppStart")
        ww=
    True
        
    Log("step1")
        WiFiServer.Start
    '    Return
    '    Log("step2")
    '    ConnectToNetwork
     
        P3=
    False
        P4=
    False
        P5=
    False
        P6=
    False
        P4_EX=
    False
     
        sayac=
    0
        Pin1.Initialize(wemos.D1,Pin1.MODE_INPUT_PULLUP)
        Pin2.Initialize(wemos.D2,Pin2.MODE_INPUT_PULLUP)
        Pin3.Initialize(wemos.D3,Pin3.MODE_INPUT_PULLUP)
        Pin3.Initialize(wemos.D3,Pin3.MODE_INPUT_PULLUP)
        Pin4.Initialize(wemos.D4,Pin4.MODE_INPUT_PULLUP)
        Pin5.Initialize(wemos.D5,Pin5.MODE_INPUT_PULLUP)
        Pin6.Initialize(wemos.D6,Pin6.MODE_INPUT_PULLUP)
        Pin7.Initialize(wemos.D7,Pin7.MODE_INPUT_PULLUP)
     
        P1=Pin1.DigitalRead
        P2=Pin2.DigitalRead
        P3=Pin3.DigitalRead
        P4=Pin4.DigitalRead
        P5=Pin5.DigitalRead
        P6=Pin6.DigitalRead
        P4_EX=P4
     
        Pin1.AddListener(
    "PIN1_Changed")
        Pin2.AddListener(
    "PIN2_Changed")
        Pin3.AddListener(
    "PIN3_Changed")
        Pin4.AddListener(
    "PIN4_Changed")
        Pin5.AddListener(
    "PIN5_Changed")
        Pin6.AddListener(
    "PIN6_Changed")
        Pin7.AddListener(
    "PIN7_Changed")
        Timers.Initialize(
    "T_tick",5000)
        Timers.Enabled=
    True
     
    End Sub

    Private Sub PINx_Changed (State As Boolean)
        
    'Log("5 --*********pin5 changed",State)
        P1=Pin1.DigitalRead
        P2=Pin2.DigitalRead
        P3=Pin3.DigitalRead
        P4=Pin4.DigitalRead
        P5=Pin5.DigitalRead
        P6=Pin6.DigitalRead
        P7=Pin7.DigitalRead
        pinler(
    True)
    End Sub
    private Sub T_Tick
        
    'Log("Timers")
        P1=Pin1.DigitalRead
        P2=Pin2.DigitalRead
        P3=Pin3.DigitalRead
        P4=Pin4.DigitalRead
        P5=Pin5.DigitalRead
        P6=Pin6.DigitalRead
        P7=Pin7.DigitalRead
        pinler(
    False)
    End Sub
     
    Last edited: Apr 9, 2019
  5. tigrot

    tigrot Well-Known Member Licensed User

    The issue is that pullup is not present on all Wemos pins. So most pins are unable to detect open/close of optocouplers. Add a resistor for each coupler
     
    Last edited: Apr 9, 2019
  6. tigrot

    tigrot Well-Known Member Licensed User

  7. tigrot

    tigrot Well-Known Member Licensed User

    The resistor network is a little unbalanced, but should work well.
    In case it doesn't work short circuit 3k resistor on V1 side.
     
    Last edited: Apr 9, 2019
    mtd likes this.
  8. mtd

    mtd Member

    some times read voltage
    Wemos D3 for 3.35V(led off) 1.0V (led on)
    Wemos D4 for 3.12V(led off) 0,8v (led on)

    is it normal?
     
  9. mtd

    mtd Member

    thank you for sharing
    4,3Kohm resistor for all wemos pin? or only pullup pins?
     
    Last edited: Apr 9, 2019
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice