Modbus Slave Address

Please add any feature requests for Flowcode version 7 here

Moderator: Benj

lordhex
Posts: 54
Joined: Mon Dec 30, 2013 2:09 am
Has thanked: 15 times
Been thanked: 12 times
Contact:

Modbus Slave Address

Postby lordhex » Mon Jul 18, 2016 8:31 pm

Modbus Slave address and baud rate can be edited by component macro call commands.
For exemple i want to use Switch Array for editing slave address and baud rate but i can't do it now.
Every time i have to edit in program modbus slave component properties.
In this case you can't write a common program.
These users thanked the author lordhex for the post (total 3):
kersing (Mon Jul 18, 2016 9:30 pm) • Steve (Tue Jul 19, 2016 9:27 am) • Benj (Wed Jul 20, 2016 10:27 am)
Rating: 15.79%
 

User avatar
Benj
Matrix Staff
Posts: 14361
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4443 times
Been thanked: 4143 times
Contact:

Re: Modbus Slave Address

Postby Benj » Wed Jul 20, 2016 10:43 am

Hello,

Good suggestion there.

I have now added additional macros to allow the Baud rate and Slave address to be overridden in software so they are no longer fixed in stone by the property settings.

ModbusSlave.fcpx
(20.88 KiB) Downloaded 191 times


For now I left the slave address byte count fixed by the property to avoid using another RAM location but this could easily be changed too.

Let me know how you get on.

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1086
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 440 times
Been thanked: 492 times
Contact:

Re: Modbus Slave Address

Postby Steve001 » Wed Jul 20, 2016 12:36 pm

could I add a suggestion please ?

I haven't had chance to look at V7 yet though :( sorry if it's answered

could the parity be made adjustable in software also odd, even, none ?

Steve
Success always occurs in private and failure in full view.

User avatar
Benj
Matrix Staff
Posts: 14361
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4443 times
Been thanked: 4143 times
Contact:

Re: Modbus Slave Address

Postby Benj » Wed Jul 20, 2016 1:23 pm

Hi Steve,

We don't currently deal at all with parity. You can force it yourself by putting the comms into 9-bit mode and calculating the parity on the 8-bit data your sending.

However this is quite long hand and would be tricky if not impossible to do for multi layer components like Modbus.

Therefore we could automate as an optional feature from the CAL UART and then expose the options in the components that might need it. I'll add it to the tracked requests list.
These users thanked the author Benj for the post:
Steve001 (Wed Jul 20, 2016 6:01 pm)
Rating: 5.26%
 

lordhex
Posts: 54
Joined: Mon Dec 30, 2013 2:09 am
Has thanked: 15 times
Been thanked: 12 times
Contact:

Re: Modbus Slave Address

Postby lordhex » Thu Jul 21, 2016 1:29 pm

Benj wrote:Hello,

Good suggestion there.

I have now added additional macros to allow the Baud rate and Slave address to be overridden in software so they are no longer fixed in stone by the property settings.

The attachment ModbusSlave.fcpx is no longer available


For now I left the slave address byte count fixed by the property to avoid using another RAM location but this could easily be changed too.

Let me know how you get on.

i have a small problem :)
Please see the attach.
Attachments
prb1.jpg
(364.07 KiB) Downloaded 2169 times

User avatar
Benj
Matrix Staff
Posts: 14361
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4443 times
Been thanked: 4143 times
Contact:

Re: Modbus Slave Address

Postby Benj » Thu Jul 21, 2016 2:15 pm

Sorry I forgot to make the new macros public. They should be there now.

ModbusSlave.fcpx
(21.15 KiB) Downloaded 190 times
These users thanked the author Benj for the post:
lordhex (Thu Jul 21, 2016 6:31 pm)
Rating: 5.26%
 

lordhex
Posts: 54
Joined: Mon Dec 30, 2013 2:09 am
Has thanked: 15 times
Been thanked: 12 times
Contact:

Re: Modbus Slave Address

Postby lordhex » Thu Jul 21, 2016 6:31 pm

Benj wrote:Sorry I forgot to make the new macros public. They should be there now.

ModbusSlave.fcpx

As i say before...
You are my hero.
I will always love you and matrix team.
These users thanked the author lordhex for the post:
Benj (Sun Jul 24, 2016 12:52 am)
Rating: 5.26%
 

Konstantiant
Posts: 12
Joined: Sun May 09, 2010 7:57 pm
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: Modbus Slave and Modbus Master not communicates

Postby Konstantiant » Mon Jul 25, 2016 11:13 am

Test-Modbus_PresetSingleRegister.fcfx
Modbus Master FCV6 Working
(52.95 KiB) Downloaded 185 times
Hi
The Modbus Master on Flowcode V6 communicate correct.
The Modbus Master and slave on Flowcode V7 no communicates
Use the device ATXMega 32A4
I attach the program used
Please check the componets
Thanks

User avatar
Benj
Matrix Staff
Posts: 14361
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4443 times
Been thanked: 4143 times
Contact:

Re: Modbus Slave Address

Postby Benj » Mon Jul 25, 2016 5:24 pm

Hello Konstantiant,

Are you saying a program created using Flowcode v6 works fine but the exact same program and setup using Flowcode v7 has a problem?

If so then please can you post the C files created by v6 and v7 and I will investigate the differences. The Modbus master component has not been massively changed for v7 so there shouldn't be any massive differences causing problems.

Or are you saying that the new Modbus Slave component in v7 is not working how you are expecting?

EtsDriver
Valued Contributor
Valued Contributor
Posts: 413
Joined: Tue Apr 15, 2014 4:19 pm
Location: Kajaani, Finland
Has thanked: 328 times
Been thanked: 211 times
Contact:

Re: Modbus Slave Address

Postby EtsDriver » Mon Jul 25, 2016 6:51 pm

Benj wrote:Hello Konstantiant,

Are you saying a program created using Flowcode v6 works fine but the exact same program and setup using Flowcode v7 has a problem?

If so then please can you post the C files created by v6 and v7 and I will investigate the differences. The Modbus master component has not been massively changed for v7 so there shouldn't be any massive differences causing problems.

Or are you saying that the new Modbus Slave component in v7 is not working how you are expecting?


By creating FC6 and FC7 from the flowchart and comparing those in notepad++ attached there, the V7 has something new on ASCII characters, but not codebreaking...
EtsDriver wrote:But then i spotted this:
Default differences.JPG
(196.84 KiB) Downloaded 2065 times

The default statement is missing on FC7 created file? Could this be the bug Konstantiant has encountered when loading hex created from this to MCU?

EDIT: DOH, you dont need default always, silly me :lol:

Could it be that the FC7 doesnt like the buffered display he is using? --> cant find same component on FC7 display's menu?

Could you verify that the display you are using is working correctly on V7 alone, without MODBUS component? Thats only thing that seems to differ in generated code, the handling of ascii characters part:
This under V7

Code: Select all

/*========================================================================*\
   Use :Base_GLCD
       :Macro implementations
\*========================================================================*/
/*=----------------------------------------------------------------------=*\
   Use :Gets a byte of the embedded ASCII font data.
       :
       :Parameters for macro ReadASCIILUT:
       :  pos_str : ASCII position -32 so A = 'A' - 32 = 33
       :  count : Font column Ranging 0-4
       :
       :Returns : MX_UINT8
\*=----------------------------------------------------------------------=*/
MX_UINT8 FCD_0ba71_Base_GLCD__ReadASCIILUT(MX_UINT8 FCL_POS_STR, MX_UINT8 FCL_COUNT)
{
   //Local variable definitions
   MX_UINT16 FCL_POSITION;
   MX_UINT8 FCR_RETVAL;


   #if (1) // 1 == 1

      if (FCL_POS_STR > 94)
      {

         FCR_RETVAL = 0xaa;

      } else {

         FCL_POSITION = (FCL_POS_STR * 5) + FCL_COUNT;

         FCR_RETVAL = FCD_00fb1_ASCIIData__INTLIST(FCL_POSITION);

      }

   // #else

   //Code has been optimised out by the pre-processor
   #endif

   return (FCR_RETVAL);

}


This under V6

Code: Select all

/*========================================================================*\
   Use :Base_GLCD
       :Macro implementations
\*========================================================================*/
/*=----------------------------------------------------------------------=*\
   Use :Gets a byte of the embedded ASCII font data.
       :
       :Parameters for macro ReadASCIILUT:
       :  pos_str : ASCII position -32 so A = 'A' - 32 = 33
       :  count : Font column Ranging 0-4
       :
       :Returns : MX_UINT8
\*=----------------------------------------------------------------------=*/
MX_UINT8 FCD_0ba71_Base_GLCD__ReadASCIILUT(MX_UINT8 FCL_POS_STR, MX_UINT8 FCL_COUNT)
{
   //Local variable definitions
   MX_UINT8 FCL_POSITION;
   MX_UINT8 FCR_RETVAL;


   #if (1) // 1 == 1

      FCL_POSITION = FCL_POS_STR / 12;

      switch (FCL_POSITION)
      {
         case 0:
         {
            FCL_POSITION = (FCL_POS_STR * 5) + FCL_COUNT;

            FCR_RETVAL = FCD_00fb1_ASCII0__INTLIST(FCL_POSITION);

            break;
         }
         case 1:
         {
            FCL_POSITION = ((FCL_POS_STR - 12) * 5) + FCL_COUNT;

            FCR_RETVAL = FCD_00fb2_ASCII1__INTLIST(FCL_POSITION);

            break;
         }
         case 2:
         {
            FCL_POSITION = ((FCL_POS_STR - 24) * 5) + FCL_COUNT;

            FCR_RETVAL = FCD_00fb3_ASCII2__INTLIST(FCL_POSITION);

            break;
         }
         case 3:
         {
            FCL_POSITION = ((FCL_POS_STR - 36) * 5) + FCL_COUNT;

            FCR_RETVAL = FCD_00fb4_ASCII3__INTLIST(FCL_POSITION);

            break;
         }
         case 4:
         {
            FCL_POSITION = ((FCL_POS_STR - 48) * 5) + FCL_COUNT;

            FCR_RETVAL = FCD_00fb5_ASCII4__INTLIST(FCL_POSITION);

            break;
         }
         case 5:
         {
            FCL_POSITION = ((FCL_POS_STR - 60) * 5) + FCL_COUNT;

            FCR_RETVAL = FCD_00fb6_ASCII5__INTLIST(FCL_POSITION);

            break;
         }
         case 6:
         {
            FCL_POSITION = ((FCL_POS_STR - 72) * 5) + FCL_COUNT;

            FCR_RETVAL = FCD_00fb8_ASCII6__INTLIST(FCL_POSITION);

            break;
         }
         case 7:
         {
            FCL_POSITION = ((FCL_POS_STR - 84) * 5) + FCL_COUNT;

            FCR_RETVAL = FCD_00fb7_ASCII7__INTLIST(FCL_POSITION);

            break;
         }
         default:
         {
            FCR_RETVAL = 0;

            FCR_RETVAL = 0xaa;

         }
      }

   // #else

   //Code has been optimised out by the pre-processor
   #endif

   return (FCR_RETVAL);

}
Attachments
Test-Modbus_PresetSingleRegister_v7.c
V7
(72.57 KiB) Downloaded 115 times
Test-Modbus_PresetSingleRegister.c
V6 file
(79.29 KiB) Downloaded 129 times
Ill just keep the good work up!

User avatar
Benj
Matrix Staff
Posts: 14361
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4443 times
Been thanked: 4143 times
Contact:

Re: Modbus Slave Address

Postby Benj » Tue Jul 26, 2016 10:26 am

Hello,

Nothing is jumping out as obvious to me. I had changed the way the gLCD fonts work slightly as arrays greater than 256 characters are now allowed on 8-bit PIC and everything else so I simply use one font array instead of 8. I also added a new font type but again this shouldn't cause any issues. If the gLCD is working well in other programs and correctly printing out values then I can't see the changes having any ill effect.
These users thanked the author Benj for the post:
EtsDriver (Tue Jul 26, 2016 10:35 am)
Rating: 5.26%
 

Konstantiant
Posts: 12
Joined: Sun May 09, 2010 7:57 pm
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: Modbus Slave Address

Postby Konstantiant » Tue Jul 26, 2016 5:25 pm

Hello

I noticed that the program that I sent you (Test-Modbus_PresetSingleRegister), when you disable the Display the Modbus Master of function properly as in version 6. But,the Modbus Slave I have not been able to communicate. The settings I use is:Baud Rate=9600, Data Bits=8, Parity=None, Stop Bits=1, Time Out=1000ms on the Modbus Tester
Could you send me a example your own that works properly in Modbus Slave AVR

USBSuit.png
Logic Analyser
(185.87 KiB) Downloaded 2036 times

Modbus-Slave-RS232 No Display.fcfx
(8.62 KiB) Downloaded 135 times

Thanks

Konstantiant
Posts: 12
Joined: Sun May 09, 2010 7:57 pm
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: Modbus Slave Address

Postby Konstantiant » Sat Jul 30, 2016 11:34 pm

Hello

Does anyone have communicated with Modbus Slave components ?
If there is any malfunction, could you tell me about when you are ready?

Thanks

User avatar
Benj
Matrix Staff
Posts: 14361
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4443 times
Been thanked: 4143 times
Contact:

Re: Modbus Slave Address

Postby Benj » Mon Aug 01, 2016 12:28 pm


lordhex
Posts: 54
Joined: Mon Dec 30, 2013 2:09 am
Has thanked: 15 times
Been thanked: 12 times
Contact:

Re: Modbus Slave Address

Postby lordhex » Mon Aug 08, 2016 9:31 pm

Ben i want to stop asking but you know i am like a litle child :)
In the future will we have an option TCP/IP for modbus slave?

User avatar
Benj
Matrix Staff
Posts: 14361
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4443 times
Been thanked: 4143 times
Contact:

Re: Modbus Slave Address

Postby Benj » Tue Aug 09, 2016 9:45 am

Hello,

TCP/IP would certainly be very nice. The main thing blocking this at the moment is which TCP/IP module to choose from. They all work in different ways meaning implementing one size fits all is not really possible. We could do an on-board TCP/IP stack but then we need to implement this and it is a fair amount of work. For me the ESP8266 and ENC28J60 are both viable options for a wired or wireless connection but as I say we would likely have to force commonality between the modules to help make this possible.

We want to do more networking bits and pieces in the future, specifically things like IOT and LoraWAN so hopefully we will bite off a piece of technology that will also allow TCP/IP with Modbus.
These users thanked the author Benj for the post (total 3):
lordhex (Tue Aug 09, 2016 11:04 am) • EtsDriver (Tue Aug 09, 2016 2:28 pm) • petesmart (Tue Aug 09, 2016 3:35 pm)
Rating: 15.79%
 

claudemir
Posts: 45
Joined: Sat Nov 03, 2012 7:43 am
Has thanked: 11 times
Been thanked: 4 times
Contact:

Re: Modbus Slave Address

Postby claudemir » Thu Jul 27, 2017 5:12 pm

Hello Benj
With the constant evolution of the flowcode and together with the technology of industrial electronic equipment, has it been possible to verify the creation of a modbus TCP IP component to communicate with the Ethernet module w5100?