Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Modbus Communication circuit

Status
Not open for further replies.

nayakajit87

Member level 5
Joined
Aug 13, 2018
Messages
84
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
1,065
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/articles/article/item/100739
Rs485 circuit.JPG

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.
 

Hi,

use a scope and show the signals.

Klaus
 

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.
 

Before_Connecting ADM2483.jpg




After_ADM2483 connected.jpg

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:

Hi,

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

Klaus
 

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
 

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
 

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();  
          }
                
	}
}
Before_Connecting ADM2483.jpg
 

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
 

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
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top