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

ModbusTCP Large Dataset

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



Joined: 27 Dec 2013
Posts: 71

View user's profile Send private message

ModbusTCP Large Dataset
PostPosted: Tue Jun 04, 2024 6:11 pm     Reply with quote

Hi all,

I am trying to wrap my brain around the amount of memory that will be used for a modbusTCP application.

I know the modbus code and other code will have an impact, but I can compile that and determine ram and rom usage from the compiler. I am specifically trying to determine exactly how much ram (im pretty sure) I am going to need to make this all work.

In my application I will have 200 coils (int1), 200 inputs(int1) and 220 input registers (int16). Is it correct to assume that I will be using: 25 bytes for coils, 25 bytes for inputs and 440 bytes for input registers? For a total of 490 bytes? Is it that simple?

I modified the example modbus code:
Code:
 unsigned int16 input_regs[220];

but I see no difference in the ram or rom usage when compiling.

The goal is to use a PIC18F97J60.

I'll admit, this is an area where I need to learn a lot more... Can anyone point me to a good resource for learning?
Ttelmah



Joined: 11 Mar 2010
Posts: 19326

View user's profile Send private message

PostPosted: Tue Jun 04, 2024 11:17 pm     Reply with quote

Fundamentally, yes.
However you will use some extra, for things like counters to access this
data, etc. etc..
The reason for the size not increasing, is that the compiler is smart, and
doesn't actually allocate the RAM, till it is used. Add a routine that puts
values into the array, and suddenly this space will be used.
This is where the keyword 'volatile' can be used. If you declare the array
as:
Code:

volatile unsigned int16 input_regs[220];

It won't be optimised away.
temtronic



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

View user's profile Send private message

PostPosted: Wed Jun 05, 2024 5:13 am     Reply with quote

I don't know that PIC but if possible, choose the one in that 'family' that has the most ROM/RAM. The cost to 'upgrade' probably is less than a $1 BUT can save you a LOT of headaches trying to get code into a too small PIC

Often ,1/2 way through the project you'll be asked for 2 more LEDs or need just a few more bytes......
demedeiros



Joined: 27 Dec 2013
Posts: 71

View user's profile Send private message

PostPosted: Wed Jun 05, 2024 7:29 am     Reply with quote

Ttelmah/temtronic,

As always, thank you both for the informative responses. You are both awesome.

The current PIC we're using is a 18F97J60 which is the largest in the family, however it looks like every PIC in that family has the same amount of RAM at 3808bytes. Hopefully I can squeeze this all in!

Thanks again!
temtronic



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

View user's profile Send private message

PostPosted: Wed Jun 05, 2024 3:28 pm     Reply with quote

At one time CCS 'housekeeping' for storing int1 into bytes was a tad flawed...probably corrected that by now but.... if you can logically group say 6 'coils' with 2 'unused' bits, instead of overlapping byte boundaries,it might work better ?

I'm sure others will KNOW if this is true......
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