Page 1 of 1

Help regarding compilation error and existing mistakes in my MODBUS programming

Posted: Wed Apr 14, 2021 8:05 am
by mit2003
Hi friends,
Looking for help regarding compilation error and idea / existing mistakes in MODBUS programming.
Thanks in advance.

I am trying to test Master slave communication for past one month. Tried with UART (RS232) but failed and Working with RS485 Multinode method but not reliable.
Realized MODBUS (RS485 - RTU) is the best choice. I google many articles but not get clear idea about MODBUS terminology.

Only "ModbusDemo" can be open, unfortunately can't open "ModBus_Master_Example", "ModBus_Slave_Example", "ModbusMasterDemo" and "ModBusSlaveDemo". If those sample files are accessible, i may get more clarity.

MODBUS Master file created based on "ModbusDemo" and compiled sucessfully.
MODBUS slave file created with the help of online articles (May be did mistakes) and tried to compile but Failed. I can't able to try further and looking for help. I attached Master, SLAVE_1 and SLAVE_2 Files (Just trying to transfer 16 nos of 16 bit data) (PIC18F46K42 with RS485 breakout board) Below one is Error message

C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c: FC_CAL_UART_Init_1()
551: INTCONbits.PEIE = 1;
^ (192) undefined identifier "INTCONbits"
^ (196) struct/union required
552: INTCONbits.GIE = 1;
^ (196) struct/union required
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c: FC_CAL_UART_Uninit_1()
908: PIE1bits.RCIE = 0;
^ (255) not a member of the struct/union ""
^ (182) illegal conversion between types
int -> volatile union S151
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_UART.c: FC_CAL_UART_UpdateBaud_1()
1564: PIE1bits.RCIE = 1;
^ (255) not a member of the struct/union ""
^ (182) illegal conversion between types
int -> volatile union S151
1565: INTCONbits.PEIE = 1;
^ (192) undefined identifier "INTCONbits"
^ (196) struct/union required
1566: INTCONbits.GIE = 1;
^ (196) struct/union required
Modbus_SLAVE_2.c: default_isr()
9584: if ((PIR1bits.RCIF) && (PIE1bits.RCIE))
^ (255) not a member of the struct/union ""
^ (255) not a member of the struct/union ""
(199) logical type required ^
(199) logical type required ^
9591: PIR1bits.RCIF = 0;
^ (255) not a member of the struct/union ""
^ (182) illegal conversion between types
int -> volatile union S178
(908) exit status = 1
(908) exit status = 1

Error returned from [xc8.exe]

C:\Program Files (x86)\Flowcode\Common\Compilers\pic\batch\pic_xc8_comp.bat reported error code 1



FINISHED

Most probably, i may did mistakes. Kindly help me to fix this issue and complete Modbus Testing successfully.

My special thanks to Martin who is my inspiration.

Re: Help regarding compilation error and existing mistakes in my MODBUS programming

Posted: Wed Apr 14, 2021 9:04 am
by medelec35
Hi mit2003,
I have just successfully compiled with all three of your flowcharts.
The two slaves:

Code: Select all

Device:        PIC.18F.18F46K42
Generated by:  Flowcode v8.2.2.15
Date:          Wednesday, April 14, 2021 08:49:10
Users:         1
Registered to: medelec35
License key: 68E2RU
https://www.matrixtsl.com
Launching the compiler...
C:\Program Files (x86)\Flowcode\Common\Compilers\pic\batch\pic_xc8_comp.bat  18F46K42 "C:\Users\medel\DOWNLO~1\" "Modbus_SLAVE_1"

C:\Users\medel\DOWNLO~1>C:\PROGRA~2\Flowcode\Common\COMPIL~1\pic\batch\..\bin\xc8.exe --chip=18F46K42  "Modbus_SLAVE_1.c" --MSGDISABLE=359,1273,1388 --FLOAT=32 --DOUBLE=32 
Microchip MPLAB XC8 C Compiler (Free Mode) V1.45
Build date: Nov 15 2017
Part Support Version: 1.45
Copyright (C) 2017 Microchip Technology Inc.
License type: Node Configuration

using updated 32-bit floating-point libraries; improved accuracy might increase code size
Modbus_SLAVE_1.c: 10062: (2017) config programming has disabled multi-vectors, "irq" in __interrupt attribute/specifier is ignored (warning)
. . . .

Non line specific message: (2019) low-priority interrupt vector in table @ 0x8 is unassigned, will be programmed with a RESET instruction  (warning)

Memory Summary:
    Program space        used   EF4h (  3828) of  F000h bytes   (  6.2%)
    Data space           used   12Bh (   299) of   FFFh bytes   (  7.3%)
    Configuration bits   used     5h (     5) of     5h words   (100.0%)
    EEPROM space         used     0h (     0) of   400h bytes   (  0.0%)
    ID Location space    used     0h (     0) of    10h bytes   (  0.0%)
    Data stack space     used     0h (     0) of   EC1h bytes   (  0.0%)


You have compiled in FREE mode.
Using Omniscient Code Generation that is available in PRO mode,
you could have produced up to 60% smaller and 400% faster code.
See http://www.microchip.com/MPLABXCcompilers for more information.


Compilation successful!

Launching the linker/assembler...
D:\Flowcode v8\tools\DoNothing\DoNothing.exe 

Code: Select all

Device:        PIC.18F.18F46K42
Generated by:  Flowcode v8.2.2.15
Date:          Wednesday, April 14, 2021 08:49:54
Users:         1
Registered to: medelec35
License key: 68E2RU
https://www.matrixtsl.com
Launching the compiler...
C:\Program Files (x86)\Flowcode\Common\Compilers\pic\batch\pic_xc8_comp.bat  18F46K42 "C:\Users\medel\DOWNLO~1\" "Modbus_SLAVE_2"

C:\Users\medel\DOWNLO~1>C:\PROGRA~2\Flowcode\Common\COMPIL~1\pic\batch\..\bin\xc8.exe --chip=18F46K42  "Modbus_SLAVE_2.c" --MSGDISABLE=359,1273,1388 --FLOAT=32 --DOUBLE=32 
Microchip MPLAB XC8 C Compiler (Free Mode) V1.45
Build date: Nov 15 2017
Part Support Version: 1.45
Copyright (C) 2017 Microchip Technology Inc.
License type: Node Configuration

using updated 32-bit floating-point libraries; improved accuracy might increase code size
Modbus_SLAVE_2.c: 10062: (2017) config programming has disabled multi-vectors, "irq" in __interrupt attribute/specifier is ignored (warning)
. .

Non line specific message: (2019) low-priority interrupt vector in table @ 0x8 is unassigned, will be programmed with a RESET instruction  (warning)

Memory Summary:
    Program space        used   EF2h (  3826) of  F000h bytes   (  6.2%)
    Data space           used   103h (   259) of   FFFh bytes   (  6.3%)
    Configuration bits   used     5h (     5) of     5h words   (100.0%)
    EEPROM space         used     0h (     0) of   400h bytes   (  0.0%)
    ID Location space    used     0h (     0) of    10h bytes   (  0.0%)
    Data stack space     used     0h (     0) of   EECh bytes   (  0.0%)


You have compiled in FREE mode.
Using Omniscient Code Generation that is available in PRO mode,
you could have produced up to 60% smaller and 400% faster code.
See http://www.microchip.com/MPLABXCcompilers for more information.


Compilation successful!

Launching the linker/assembler...
D:\Flowcode v8\tools\DoNothing\DoNothing.exe  


FINISHED
Have you made sure your Flowcode version is up to-date?
As you can see from the compiler message, mine is v8.2.2.15
Before compiling I Updated the Full database using Help, Check for Updates...
Changed Files in-use to Full database.

Re: Help regarding compilation error and existing mistakes in my MODBUS programming

Posted: Wed Apr 14, 2021 10:29 am
by mit2003
Thank you so much Martin.

One more favor please, shall my approach in the design is okay for communication between Master and Slaves? If not kindly help me to get the right one.

I will update and get back.

Re: Help regarding compilation error and existing mistakes in my MODBUS programming

Posted: Wed Apr 14, 2021 10:29 am
by mit2003
Thank you so much Martin.

One more favor please, shall my approach in the design is okay for communication between Master and Slaves? If not kindly help me to get the right one.

I will update and get back.

Re: Help regarding compilation error and existing mistakes in my MODBUS programming

Posted: Wed Apr 14, 2021 10:52 am
by mit2003
Actually i got error message, that is why tried these many times.

Re: Help regarding compilation error and existing mistakes in my MODBUS programming

Posted: Wed Apr 14, 2021 3:16 pm
by medelec35
Hi, Your welcome.
yes me too.
I have reported the issue.

Re: Help regarding compilation error and existing mistakes in my MODBUS programming

Posted: Fri Apr 16, 2021 5:25 am
by mit2003
Hi Martin and Benj,

After update to current version, Yes compiled successfully.

Thank you very much Martin and Benj.

Modbus example projects are not accessible. Kindly provide those files in accessible manner which will help me, how to implement my expected task efficiently.

I am not sure that my flow in the master and slave files are even valid one or not. Its great help if you can spend some free time for this request.

Re: Help regarding compilation error and existing mistakes in my MODBUS programming

Posted: Wed Jul 21, 2021 8:05 pm
by Mim
Good evening.
Help solve the problem with Modbus RTU.
The master sends the request, the slave receives it correctly and executes it.
The slave sends a response is not correct. (Only the low byte)

Re: Help regarding compilation error and existing mistakes in my MODBUS programming

Posted: Mon Jul 26, 2021 3:16 pm
by Mim
Dear Benj.
Tell me so it should be in Modbus RTU RS485, or is it a bug?
FC 9 components have been updated.

Re: Help regarding compilation error and existing mistakes in my MODBUS programming

Posted: Mon Jul 26, 2021 3:16 pm
by Mim
Dear Benj.
Tell me so it should be in Modbus RTU RS485, or is it a bug?
FC 9 components have been updated.