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 slave driver explanation

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



Joined: 06 Nov 2007
Posts: 3

View user's profile Send private message

modbus slave driver explanation
PostPosted: Wed Aug 22, 2012 11:06 am     Reply with quote

Hello All,

I compiled the modbus slave example from CCS.
All went OK. I have few questions:

Q1: How do I map the I/O:s as coils and inputs for a particular chip?

Q2: What do these lines in the sample code:
Code:

   int8 coils = 0b00000101;
   int8 inputs = 0b00001001;
   int16 hold_regs[] = {0x8800,0x7700,0x6600,0x5500,0x4400,0x3300,0x2200,0x1100};
   int16 input_regs[] = {0x1100,0x2200,0x3300,0x4400,0x5500,0x6600,0x7700,0x8800};
   int16 event_count = 0;


mean?

Q3: Is there any fully functional modbus slave code and tutorial for ACE kit from CCS?

Thanks!
_________________
There are 10 types of people, those who know binaries and the other nine types are the rest of us.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Aug 22, 2012 11:47 am     Reply with quote

Most of your questions can be answered by Googling for these things:
Quote:

modbus holding registers

modbus coils

modbus How do I map the I/Os as coils and inputs


As a general rule, you should Google first and only if you can't answer it
there, then ask it here.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Aug 23, 2012 12:19 am     Reply with quote

Instead of Google in general, I would rather refer to the Modbus specification and suggest to study the CCS example code in detail.

Q1. I don't understand what you mean with "a particular chip". The example uses a fixed assignment of a Modbus addresses inside the code. It will be typically changed or written in a more flexible way for a real automation problem.

Q2. The shown variables represent the data connected to the Modbus bis and registers. There's no real IO hardware connected.

Q3. I'm not aware of, but agree that it would be a good idea to have an example accessing the on-board digital and analog IOs.

How about starting it as an excercise?
NeoB



Joined: 06 Nov 2007
Posts: 3

View user's profile Send private message

PostPosted: Fri Oct 12, 2012 3:52 pm     Reply with quote

Quote:

As a general rule, you should Google first and only if you can't answer it
there, then ask it here.


Thanks PCM Programmer. I followed the advice.

I would like to add support for blinking LED:s showing

- Chip is communicating
- Error

Q1: What would be the best place to put these? I guess not in "modbus.c".
Q2: I am not sure that the current slave program captures if a master tries to communicate with wrong baud or parity. Am I correct?

Thanks in advance
_________________
There are 10 types of people, those who know binaries and the other nine types are the rest of us.
NeoB



Joined: 06 Nov 2007
Posts: 3

View user's profile Send private message

PostPosted: Fri Oct 12, 2012 3:55 pm     Reply with quote

Quote:
How about starting it as an excercise?


Thanks FvM. Once I got thru explanations found on "modbus.org", everything became clear. Now I am working on flashing LED:s to show Error and/or communication.

Regards
_________________
There are 10 types of people, those who know binaries and the other nine types are the rest of us.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Oct 13, 2012 2:44 am     Reply with quote

In the previous modbus.c version, I set an error LED in the "else" case of the timeout timer modbus_timeout_now() and a "responding" LED in modbus_serial_putc(). The LEDs are cleared by a global timer routine periodically.
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