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

Newbie Question re MODBUS over USB

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
f20flyer



Joined: 03 Jan 2009
Posts: 3

View user's profile Send private message

Newbie Question re MODBUS over USB
PostPosted: Sat Jan 03, 2009 7:00 pm     Reply with quote

Hi,

I am contemplating buying the CCS compiler to enable me to complete a project I have. However, I have some questions regarding using MODBUS over USB, and whilst I program in C and have used the 8 bit 16F series PICs, I have little or no experience using the 18F4550, or writing for MODBUS or USB.

In comparing the compilers ( HI-TECH, CCS etc ) I noticed that the CCS version supports both MODBUS and USB.......BUT, are there examples showing how to run MODBUS over USB ?

In my project I have to link an industrial control interface to a PC running an application ( on Win XP ) that acts as a MODBUS slave and requests data from the master via a COM port.

I am assuming that if I use CCS and use the CDC USB code version I can effectively make the USB PIC device appear to be a virtual COM port.

Can I then "overlay" the MODBUS onto the USB to send / receive the data ? Is this supported ? If not, how much re writing am I going to have to do in terms of either the USB or MODBUS code ? Or is it a complete waste of effort ?

Thanks in advance, and Happy New Year Smile

TK
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat Jan 03, 2009 8:22 pm     Reply with quote

MODBUS is a communications protocol and USB is a signaling standard.
MODBUS can be implemented over USB, RS232, RS485, TCP/IP, CAN,
Devicenet etc.

So, the answer is yes, it can be done. The example is set up for use on
RS232/RS485 but it can be rewritten to use USB. Using a USB capable PIC
(i.e 18F4550) would make the change pretty simple.
f20flyer



Joined: 03 Jan 2009
Posts: 3

View user's profile Send private message

PostPosted: Sat Jan 03, 2009 8:46 pm     Reply with quote

Hi, Thanks for the response. Very Happy

When you say "pretty easy" to modify, do you mean for a newbie to CCS / USB / MODBUS, or easy for an experienced programmer ?

My experience is mainly in hardware, with the odd embedded project thrown in for good measure. My last serious work related embedded project was 15 years ago using the 8051.

From what I can see of the code snipets on the forum, the people who have done something similar, are at a much higher experience level than me! Embarassed

My PIC experience is mainly in the hobby arena, so you can understand my caution with regard to this.


Thanks

TK
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat Jan 03, 2009 9:31 pm     Reply with quote

It would take someone fairly experienced with C programming and a good knowledge of PICs. For a "newbie" to PIC C embedded programming it may be more than you would want to tackle expecially if this is a project for school or something similar. It would take some fairly significant changes to the existing driver code. Actually, implementing the USB would likely be the hardest part.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Jan 04, 2009 6:22 am     Reply with quote

Basically, you can regard the CDC driver as existing communbication channel with a well defined interface. The CCS supplied MODBUS example has to be modified in part, e. g. the timeout has to be redefined (or simply omitted). As modbus.c is including the UART RX interrupt, the resepective parts have to be modfied. The example code also has some bugs, so you should have basic knowledge of the MODBUS protocol to be able to correct them.

The other option is not to use the existing MODBUS code and rewrite the MODBUS interface from the scratch. If you have a working MODBUS code from another project, it may be meaningful.
f20flyer



Joined: 03 Jan 2009
Posts: 3

View user's profile Send private message

PostPosted: Sun Jan 04, 2009 6:40 am     Reply with quote

Hi, Thanks for this.

Unfortunately, I have no other option but to use MODBUS and USB. The PC Program interface is fixed with regard to MODBUS, and other parts of the program will be developed to rx/tx data via MODBUS too.

Has anyone on the forum "done" MODBUS over USB ? Code snips, ideas ? Have CCS updated the MODBUS.c program to remove bugs ?

Thanks

TK
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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