CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Modbus RTU communication with OPC server
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
temtronic



Joined: 01 Jul 2010
Posts: 9097
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed May 30, 2018 6:39 pm     Reply with quote

hhm, since you say you've used this program before and it's good, then you MUST have a hardware problem.
ufkyldrm



Joined: 21 May 2018
Posts: 27

View user's profile Send private message

PostPosted: Thu May 31, 2018 1:38 am     Reply with quote

I think problem is pic issue. My devices were other type of processors.
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Thu May 31, 2018 3:35 am     Reply with quote

Seriously, you are not 'using the same program' then, which you claimed to have done. Sad
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Thu May 31, 2018 3:47 am     Reply with quote

Looking at your posted picture again, I can't see any connection to pin 40 on the PIC. There are two visible empty holes to the right of this pin. Now the code you post, has pin B7 (40) selected as the RX enable pin....
ufkyldrm



Joined: 21 May 2018
Posts: 27

View user's profile Send private message

PostPosted: Thu May 31, 2018 4:07 am     Reply with quote

I ve changed it, now it has Smile can be problem compiler version;?
temtronic



Joined: 01 Jul 2010
Posts: 9097
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu May 31, 2018 4:49 am     Reply with quote

It's highly unlikey to be a compiler bug. Since the modbus driver is at least 15 years old, and the compiler has worked 100% for the 877 for at least 20+ years if there were ANY 'compiler' problems we would have seen them long before now. As the program 'stalls' at the point of serial traffic, I suspect either a wiring error or no data actually being sent.
If you have an oscilloscope, put it on the serial pin and see what is being sent. If you try my 'test RS-485' suggestion, that would prove the PIC and RS-485 driver chip are functional.If no scope is available, set the baudrate for as low as possible, attach an LED logic probes and watch the LEDs for proper data.
While I don't use MODBUS, enough here do and ANY issues with the driver would be common knowledge and posted. The 877 is a mid80s PIC(obsolete now) and I have some originals still running today. RS485 is a robust design and very well proven. It sure looks like a miswiring issue to me.

Jay
ufkyldrm



Joined: 21 May 2018
Posts: 27

View user's profile Send private message

PostPosted: Thu May 31, 2018 5:26 am     Reply with quote

There are warnings on while loop.

1 Inturrup disabled during call yo prevent re entrancy @GETCH_BUİ_1

2 Inturrup disabled during call yo prevent re entrancy MODBUS_ENABLE_TİMEOUT

3 Inturrup disabled during call yo prevent re entrancy
MODBUS_CALS_CRC

Is that a problem for compling program and for modbus communicatin?

My wiring pics.

https://ibb.co/ghrdnd
https://ibb.co/fACUtJ
https://ibb.co/eJjL0y
https://ibb.co/bE6ptJ
temtronic



Joined: 01 Jul 2010
Posts: 9097
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu May 31, 2018 6:05 am     Reply with quote

warnings are NOT 'errors' !
In this case( same warning) the compiler is telling you that the interrupt is disabled so that a 2nd (or more) interrupt trigger will NOT allow the program to execute the ISR. If it was allowed you'd see a 'sunset loop' where the PIC will keep executing the loop, around and around forever until it crashes.( stack overflow)
Jay
ufkyldrm



Joined: 21 May 2018
Posts: 27

View user's profile Send private message

PostPosted: Thu May 31, 2018 7:37 am     Reply with quote

temtronic wrote:
warnings are NOT 'errors' !
In this case( same warning) the compiler is telling you that the interrupt is disabled so that a 2nd (or more) interrupt trigger will NOT allow the program to execute the ISR. If it was allowed you'd see a 'sunset loop' where the PIC will keep executing the loop, around and around forever until it crashes.( stack overflow)
Jay


So it is not important. Smile
ufkyldrm



Joined: 21 May 2018
Posts: 27

View user's profile Send private message

PostPosted: Thu May 31, 2018 8:31 am     Reply with quote

I just add @define modbus_parity none to ebove to modbus.c and I changed data length on the master device... And my code is working now....... Smile)))))))))))))))))))))))))))))))))))))))))))))))))))))))

Thank u guys... Why it is work?

There is no notification on example codes for parity...

Ttelmah u are my hero.
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Thu May 31, 2018 8:40 am     Reply with quote

It's 'information'. In this case not important.

They tell you, since having the interrupt disabled for a lsignificant time, would be an error. Therefore if the routines being named, were ones where the compiler stayed in them for a really long time (things like delays....), it might be worthwhile re-writing to avoid this. However these are all quick routines.

You really do need to go through your hardware.

Do you have the pull-up on the RX line to the PIC?. Needed.
Have you biased the RS485 bus?. Needed.
Double check your actual pinouts and connections.
Have you done the basic 'flash an LED' test and verified the PIC is running at the speed you expect. For everything 'serial' timing is critical, and if the PIC is not clocking at the right rate, nothing will work.

You also talk about a 'Modbus pool program'. Presumably you mean 'Modbus poll'. Have you got a spec for this. Are you sure it wants Modbus RTU, not Modbus ASCII?. Are you sure it is running at 9600bps (19200 is more common).

I see you have got it working. Smile

Modbus-RTU defaults to always using even parity. Your master must be using no parity. No wonder it didn't work....
ufkyldrm



Joined: 21 May 2018
Posts: 27

View user's profile Send private message

PostPosted: Thu May 31, 2018 10:38 am     Reply with quote

Ttelmah wrote:
It's 'information'. In this case not important.

They tell you, since having the interrupt disabled for a lsignificant time, would be an error. Therefore if the routines being named, were ones where the compiler stayed in them for a really long time (things like delays....), it might be worthwhile re-writing to avoid this. However these are all quick routines.

You really do need to go through your hardware.

Do you have the pull-up on the RX line to the PIC?. Needed.
Have you biased the RS485 bus?. Needed.
Double check your actual pinouts and connections.
Have you done the basic 'flash an LED' test and verified the PIC is running at the speed you expect. For everything 'serial' timing is critical, and if the PIC is not clocking at the right rate, nothing will work.

You also talk about a 'Modbus pool program'. Presumably you mean 'Modbus poll'. Have you got a spec for this. Are you sure it wants Modbus RTU, not Modbus ASCII?. Are you sure it is running at 9600bps (19200 is more common).

I see you have got it working. Smile

Modbus-RTU defaults to always using even parity. Your master must be using no parity. No wonder it didn't work....


You're right. I try to do my best.

Last question Smile Is it work with Kepware OPC Server?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group