View previous topic :: View next topic |
Author |
Message |
demedeiros
Joined: 27 Dec 2013 Posts: 71
|
ModbusTCP Large Dataset |
Posted: Tue Jun 04, 2024 6:11 pm |
|
|
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: 19539
|
|
Posted: Tue Jun 04, 2024 11:17 pm |
|
|
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: 9243 Location: Greensville,Ontario
|
|
Posted: Wed Jun 05, 2024 5:13 am |
|
|
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
|
|
Posted: Wed Jun 05, 2024 7:29 am |
|
|
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: 9243 Location: Greensville,Ontario
|
|
Posted: Wed Jun 05, 2024 3:28 pm |
|
|
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...... |
|
|
|