View previous topic :: View next topic |
Author |
Message |
NeoB
Joined: 06 Nov 2007 Posts: 3
|
modbus slave driver explanation |
Posted: Wed Aug 22, 2012 11:06 am |
|
|
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
|
|
Posted: Wed Aug 22, 2012 11:47 am |
|
|
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
|
|
Posted: Thu Aug 23, 2012 12:19 am |
|
|
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
|
|
Posted: Fri Oct 12, 2012 3:52 pm |
|
|
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
|
|
Posted: Fri Oct 12, 2012 3:55 pm |
|
|
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
|
|
Posted: Sat Oct 13, 2012 2:44 am |
|
|
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. |
|
|
|