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 CCS Technical Support

Modbus implementation
Goto page 1, 2, 3, 4, 5, 6  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
anupama619



Joined: 10 Sep 2009
Posts: 47

View user's profile Send private message

Modbus implementation
PostPosted: Sat Sep 12, 2009 6:36 am     Reply with quote

I want to implement modbus for interfacing HMI with pic16f877a. Which compiler is good for this application? Can I get any sample code? Thanks in advance. Embarassed
Guest








MODBUS Imp
PostPosted: Sat Sep 12, 2009 6:04 pm     Reply with quote

CCS has a couple of modbus examples supplied with the the compiler when you buy it.
They should be helpfull.
Cheers.
anupama619



Joined: 10 Sep 2009
Posts: 47

View user's profile Send private message

Thanks for your help in modbus implementation.....
PostPosted: Mon Sep 14, 2009 12:33 am     Reply with quote

First of all thanks for your reply. I successfully implemented modbus send. Now I am able to write my data into the HMI. But now I am facing a problem in response reception. So I couldn't perform the read operation also. I tried communication with interrupt and without interrupt also. Can anybody help me? Thanks in advance. 'Crying or Very sad'
anupama619



Joined: 10 Sep 2009
Posts: 47

View user's profile Send private message

modbus implementation....
PostPosted: Tue Sep 15, 2009 5:37 am     Reply with quote

i tried modbus operations with ccs compiler example code....but i am not getting the output......can anybody help me.....because of this reason my project got stuck....plz help me...plz.....plz.......thanks in advance........'Crying or Very sad'
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue Sep 15, 2009 7:16 am     Reply with quote

I can tell, that the CCS MODBUS master example is basically working. May be, there are some minor bugs, I don't remember exactly.

The first step is to check, if your request is understood and answered by the slave. This is less than receiving the response correctly. If you see a response, e.g. with a serial protocol monitor or MODBUS test software, then you can test, why it's possibly not received at the master. Dumping the received data bytes and checking it against the MODBUS specification is the usual way.
Guest








modbus implementation
PostPosted: Tue Sep 15, 2009 8:01 am     Reply with quote

Thanks for your reply....i will try this now.....
Guest








modbus implementation...
PostPosted: Tue Sep 15, 2009 8:25 am     Reply with quote

Thank you for your reply...But it still not working....I am using pic16f877a and for HMI application....Is EX_MODBUS_MASTER.C applicable for this?
And I used device monitoring studio as a simulator for verifying the serial data...but unfortunately I could not able to receive any data.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue Sep 15, 2009 2:37 pm     Reply with quote

HMI application is very general. I guess, you know that it's using MODBUS protocol, but there are several other parameters to fit. I suggest to use a commercial or freeware MODBUS test software to communicate with the slave and then try to reproduce it's operation with your MODBUS master.
In my opinion, ModBusView from ocean controls is a simple and straightforward tool. It's not free, but evalution mode is sufficient to perform basic tests.http://www.oceancontrols.com.au/modbus/modview.htm

Generally, it's no problem to write a MODBUS application from the scratch, only using the protocol specifications from MODBUS.org, I did it several times with different platforms and programming languages.
anupama619



Joined: 10 Sep 2009
Posts: 47

View user's profile Send private message

modbus implementation
PostPosted: Wed Sep 16, 2009 3:26 am     Reply with quote

Thanks for your replay..Previously i tried with mtester as master simulator and i succeeded in communication with the HMI...So I taken the same data and send it by my PIC...And i succeeded in modbus send but that was with mikroc compiler ..There i faced response reception problem...Because of this reason i changed my compiler . Now i am working with CCs compiler and with its examples.....But unfortunately i am not getting any results...Anyway as your opinion i will try with ModbusView modbus master slave simulator.... 'Smile'
anupama619



Joined: 10 Sep 2009
Posts: 47

View user's profile Send private message

modbus implementation
PostPosted: Wed Sep 16, 2009 5:15 am     Reply with quote

I tried with ModbusView master-slave simulator and it is working fine...But when reproducing the same data with my program I could't able to receive the response..So the read operation also not working ....Can you please help me....The write operation was working fine..I given a 500ms start bit and 1ms between each characters...Is delay is required for response reception?????What is my problem in response reception????? I am using a baud rate of 9600,8 data bits,parity-none,...Can you please help me!!! I am trying with this For the last 2 weeks ....please help me....thanks in advance.......... 'Crying or Very sad'
anupama619



Joined: 10 Sep 2009
Posts: 47

View user's profile Send private message

modbus implementation
PostPosted: Wed Sep 16, 2009 6:33 am     Reply with quote

With modbusView simulator i am getting the following sequence.......I am using ex_modbus_master.c and i compiled with ccs compiler......Downloaded the hex file to PIC16F877A which is my master...........



[F0][00][F0][F0][F0][F0][00][00][00][00][00][F0][F0][F0][F0][F0][F0][F0][F0][00][00][F0][F0][F0][00][F0][00][F0][F0][F0][00][F0][00][F0][F0][00][00][00][00][00][00][00][F0][F0][00][00][F0][F0][00][F0][F0][F0][00][00][F0][00][00][F0][00][F0][00][00][F0][F0][00][F0][F0][00][F0][F0][F0][00][F0][F0][00][F0][00][00][F0][00][00][00][00][F0][00][00][F0][F0][00][F0][F0][00][F0][F0][00][F0][00][F0][00][00][F0][00][00][00][F0][F0][00][F0][F0][00][F0][00][F0][F0][00][00][00][F0][00][F0][F0][F0][00][00][00][F0][F0][F0][F0][F0][F0][F0][F0][00][00][F0][00][00][F0][00][F0][F0][00][F0][F0][00][F0][00][F0][00][F0][00][F0][F0][00][00][F0][00][00][00][F0][F0][00][00][F0][00][F0][F0][00][F0][F0][F0][00][00][00][00][00][F0][F0][F0][F0][00][F0][F0][00][F0][00][00][F0][00][00][F0][00][F0][00][F0][F0][F0][00][F0][F0][00][F0][F0][F0][F0][F0][00][F0][F0][00][F0][F0][F0][00][F0][00][F0][00][F0][F0][00][F0][00][F0]
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Sep 16, 2009 7:55 am     Reply with quote

I don't clearly see which signal is displayed here. If it's the PIC Tx signal, I wonder if the baudrate is correct.
anupama619



Joined: 10 Sep 2009
Posts: 47

View user's profile Send private message

modbus implementation
PostPosted: Wed Sep 16, 2009 8:13 am     Reply with quote

Thanks for your corperation....


This stream i got from the modbbus communication window..the transmit part was empty...and the receive part have the following stream...


[00][F0][00][00][F0][F0][F0][F0][F0][00][F0][F0][00][F0][F0][00][F0][F0][F0][00][F0][00][00][00][00][00][F0][F0][F0][F0][00][00][00][00][00][F0][00][F0][F0][00][F0][00][00][F0][F0][F0][F0][F0][00][F0][F0][00][F0][F0][F0][F0][F0][F0][F0][00][00][F0][00][00][00][00][F0][00][00][00][F0][00][F0][F0][F0][F0][00][F0][00][F0][F0][00][00][00][00][00][00][00][00][00][F0][F0][F0][00][F0][F0][00][F0][F0][00][F0][F0][F0][00][F0][00][F0][F0][F0][F0][00][F0][00][00][F0][F0][00][F0][00][00][00][F0][F0][F0][F0][F0][00][00][00][00][00][F0][F0][00][00][F0][00][00][F0][00][00][F0][00][00][00][F0][00][00][00][00][00][00][F0][00][00][00][00][00][00][00][00][00][00][00][00][F0][F0][00][00][F0][00][F0][00][00][00][F0][00][00][00][F0][00][F0][F0][F0][F0][00][F0][00][F0][F0][00][00][F0][00][00][F0][F0][F0][F0][00][F0][F0][F0][F0][F0][F0][00][F0][F0][F0][F0][F0][F0][F0][F0][00][F0][F0][00][00][F0][00][F0][F0][F0][F0][F0][F0][F0][F0][F0][F0][F0][F0][F0][00][F0][00][F0][F0][00][00][F0][F0][F0]



hoping a replay...
thanks in advance
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Sep 16, 2009 10:26 am     Reply with quote

What's the hardware connection? RS232/RS485
Can you show the UART setup at the PIC side? #fuses, #device r232(), pin connections to the RS232/RS485 driver
anupama619



Joined: 10 Sep 2009
Posts: 47

View user's profile Send private message

modbus implementation
PostPosted: Wed Sep 16, 2009 11:57 pm     Reply with quote

I am using RS232 for communication and I used the ex_modbus_master.c, given in the ccs compiler example program.
This is the preproccessor part of that program.
Code:

#include <16f877a.h>
#device *=16
#fuses HS, NOWDT, NOLVP, NOBROWNOUT, NOPROTECT, PUT
#use delay(clock=20M)

#define MODBUS_TYPE MODBUS_TYPE_MASTER
#define MODBUS_SERIAL_RX_BUFFER_SIZE 64
#define MODBUS_SERIAL_BAUD 9600

#ifndef USE_WITH_PC
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, stream=PC, errors)
#define MODBUS_SERIAL_INT_SOURCE MODBUS_INT_EXT
#define MODBUS_SERIAL_TX_PIN PIN_B1   // Data transmit pin
#define MODBUS_SERIAL_RX_PIN PIN_B0   // Data receive pin
//The following should be defined for RS485 communication
//#define MODBUS_SERIAL_ENABLE_PIN   0   // Controls DE pin for RS485
//#define MODBUS_SERIAL_RX_ENABLE    0   // Controls RE pin for RS485
#define DEBUG_MSG(msg) fprintf(PC, msg)
#define DEBUG_DATA(msg,data) fprintf(PC, msg, data)
#else
#define MODBUS_SERIAL_INT_SOURCE MODBUS_INT_RDA
#define DEBUG_MSG(msg) if(0)
#define DEBUG_DATA(msg,data) if(0)
#endif

#include "modbus.c"

#define MODBUS_SLAVE_ADDRESS 0xF7

Hoping a reply....
Thanks in advance.
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 1, 2, 3, 4, 5, 6  Next
Page 1 of 6

 
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