+ Post New Thread
Results 1 to 10 of 10
  1. #1
    Junior Member level 1
    Points: 160, Level: 2

    Join Date
    Aug 2018
    Posts
    19
    Helped
    0 / 0
    Points
    160
    Level
    2

    Modbus Communication circuit

    I am trying to communicate modbus communication with PIC16F886/pic18F24k40/pic16F1938.I tested my code with MAX482 AND SN75176A NON isolated version of IC and its working fine . Now i am testing same code with DE controlled using ADM 2483 .In Non isolated version i could not able to communicate.Is there any proven circuit or IC where it has been tested with above controller in Isolated version.

    I have attached my schmatic for reference,

    http://love2007.spaces.eepw.com.cn/a...le/item/100739
    Click image for larger version. 

Name:	Rs485 circuit.JPG 
Views:	12 
Size:	65.3 KB 
ID:	149561

    This circuit i have tested with DISPIC33FJ128GP706(Which is operated 3V3) But not working with PIC16F1938 or similar. I have used pull up resistor 10K instead of 4.7k/4.5k resistor .It didnt worked. I wont get proper request from slave device itself. kindly suggested any proven circuit with above ic.

    •   AltAdvertisment

        
       

  2. #2
    Super Moderator
    Points: 67,706, Level: 63
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    13,843
    Helped
    3158 / 3158
    Points
    67,706
    Level
    63

    Re: Modbus Communication circuit

    Hi,

    use a scope and show the signals.

    Klaus
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



  3. #3
    Member level 4
    Points: 1,611, Level: 9

    Join Date
    May 2012
    Location
    Maryland, USA
    Posts
    74
    Helped
    26 / 26
    Points
    1,611
    Level
    9

    Re: Modbus Communication circuit

    Are you providing the Common connection on the isolated bus side? That would be the GND2 in your schematic. On the non-isolated version you are likely picking it through other means. When you try the isolated version, if that's not there you have no common mode reference point.



  4. #4
    Junior Member level 1
    Points: 160, Level: 2

    Join Date
    Aug 2018
    Posts
    19
    Helped
    0 / 0
    Points
    160
    Level
    2

    Re: Modbus Communication circuit

    Click image for larger version. 

Name:	Before_Connecting ADM2483.jpg 
Views:	4 
Size:	67.8 KB 
ID:	149604




    Click image for larger version. 

Name:	After_ADM2483 connected.jpg 
Views:	3 
Size:	70.9 KB 
ID:	149603

    Here I have attached Both Waveform Connected before and after connecting ADM2483 circuit.
    In Before circuit i used USB to TTl converter. I am sending Modbus request through modscan32 software where i am getting response.

    Now Usb to TTl converter replaced with USB to RS485 device with TX and Rx line tapped. When i tried to response.I wont get Request from System as shown in figure. With some of resistor pull of network i used to get request in waveform.

    Kindly suggest me What i need to do solve issue.Thats reason I am asking for right comibniation of circuit.

    Attached circuit is already tested with DISPIC33FJ128GP706 meant for 3V3. I created same waveform to achieve this but still not working.
    Last edited by nayakajit87; 20th October 2018 at 05:20.



    •   AltAdvertisment

        
       

  5. #5
    Super Moderator
    Points: 67,706, Level: 63
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    13,843
    Helped
    3158 / 3158
    Points
    67,706
    Level
    63

    Re: Modbus Communication circuit

    Hi,

    To me it seems the DE signal is wrong in timing.
    I don't expect it to change state during any communication.

    Klaus
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



  6. #6
    Junior Member level 1
    Points: 160, Level: 2

    Join Date
    Aug 2018
    Posts
    19
    Helped
    0 / 0
    Points
    160
    Level
    2

    Re: Modbus Communication circuit

    How can Adjust the DE Timing.I am enabling when Receive 8 byte of data and disabling while trasnmit data is completed.
    Do you think is there problem with Hardware or software? DE pin will be high when transmit flag complete refer figure before_ADM2483 connected.
    What might be possible reason It wont meet DE signal timing.In case of DSPIC it working. Based on those timing i created these waveform



  7. #7
    Super Moderator
    Points: 67,706, Level: 63
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    13,843
    Helped
    3158 / 3158
    Points
    67,706
    Level
    63

    Re: Modbus Communication circuit

    Hi,

    I'm not familiar with PIC.

    With other microcontrollers you have multiple flags.
    * one that shows that you may write new data to the buffer (don't use this flag for DE)
    * and the other flag that really shows that all bits has been shifted out (use this flag)

    You need to read the datasheet.

    Klaus
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



    •   AltAdvertisment

        
       

  8. #8
    Junior Member level 1
    Points: 160, Level: 2

    Join Date
    Aug 2018
    Posts
    19
    Helped
    0 / 0
    Points
    160
    Level
    2

    Re: Modbus Communication circuit

    Here is my code.

    I could not able to get below points can you elaborate. For DE i used DigitalPort to trigger it on and off.
    I am enabling only when 8 byte of data received.
    Or I need to enable DE first then receive 8bit data and then do transmission

    With other microcontrollers you have multiple flags.
    * one that shows that you may write new data to the buffer (don't use this flag for DE)
    * and the other flag that really shows that all bits has been shifted out (use this flag)
    Code:
    void Serial_Interrupt()
    
    {
        if((PIE1bits.RCIE==1)&&(PIR1bits.RCIF=1)) 
        {
    		//PIR1bits.RCIF=0;
            for(index=0; index<8; index++) {
    			rxbuf[index] = Serial_Receive_byte();
                
    		}
           __delay_ms(40);
    		if(index>=8) {
    			rec_flag = 1;
    			
    		}
    
    
    		if(index>=20) 
            {
                DE=1;
    			index=0;	
    		}
    
    		if(1==RCSTAbits.FERR)
            { 
               
    			RCSTAbits.SPEN=0;
    			RCSTAbits.SPEN=1;
                // DE=1;
    		}
    		if(1==RCSTAbits.OERR) 
            {
               
    			RCSTAbits.CREN=0;
    			RCSTAbits.CREN=1;
                // DE=1;
    		}  
            
    	}
         CLRWDT(); 
    }
    
    
    
    
    void UART_Transmit()
    {
        
    	if( PIR1bits.TMR2IF ==1)
        {
    		PIR1bits.TMR2IF = 0;
            Disp_count=Disp_count+1;
            Serial_Interrupt();
            
            if(DE=1)
              {
                   serial_access();  
              }
                    
    	}
    }
    Click image for larger version. 

Name:	Before_Connecting ADM2483.jpg 
Views:	1 
Size:	91.3 KB 
ID:	149621



  9. #9
    Super Moderator
    Points: 67,706, Level: 63
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    13,843
    Helped
    3158 / 3158
    Points
    67,706
    Level
    63

    Re: Modbus Communication circuit

    Hi,

    Or I need to enable DE first then receive
    DE means "driver enable" you need to activate it to send (transmit) data.
    It should not be controlled by the serial receiver.

    Activate DE just before you send out data,
    Deactivate DE when all data bits including STOP bit has finished to send out.

    Klaus
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



  10. #10
    Junior Member level 1
    Points: 160, Level: 2

    Join Date
    Aug 2018
    Posts
    19
    Helped
    0 / 0
    Points
    160
    Level
    2

    Re: Modbus Communication circuit

    Thanks for support . Yes its problem with Code . As said i have done code modification. once data being received i adjusted the timing for DE line.
    Then it started working normally.
    I am facing weird while testing it.
    I have 3 Software to make it confirm its working on all software

    1) modscan32
    2) modtester
    3)modbusview

    When i tested with modscan32 & modbus view i used to get proper response with no pole mismatch. If i testing with modtester i got error for illegal response. Is there any possible reason for this



--[[ ]]--