Modbus Slave Address

Please add any feature requests for Flowcode version 7 here

Moderator: Benj

Post Reply
lordhex
Posts: 54
Joined: Mon Dec 30, 2013 2:09 am
Contact:

Modbus Slave Address

Post by lordhex »

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.

User avatar
Benj
Matrix Staff
Posts: 15009
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: Modbus Slave Address

Post by Benj »

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 236 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: 1156
Joined: Wed Dec 31, 2008 3:37 pm
Contact:

Re: Modbus Slave Address

Post by Steve001 »

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: 15009
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: Modbus Slave Address

Post by Benj »

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.

lordhex
Posts: 54
Joined: Mon Dec 30, 2013 2:09 am
Contact:

Re: Modbus Slave Address

Post by lordhex »

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: 15009
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: Modbus Slave Address

Post by Benj »

Sorry I forgot to make the new macros public. They should be there now.
ModbusSlave.fcpx
(21.15 KiB) Downloaded 240 times

lordhex
Posts: 54
Joined: Mon Dec 30, 2013 2:09 am
Contact:

Re: Modbus Slave Address

Post by lordhex »

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.

Konstantiant
Posts: 12
Joined: Sun May 09, 2010 7:57 pm
Contact:

Re: Modbus Slave and Modbus Master not communicates

Post by Konstantiant »

Test-Modbus_PresetSingleRegister.fcfx
Modbus Master FCV6 Working
(52.95 KiB) Downloaded 233 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: 15009
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: Modbus Slave Address

Post by Benj »

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: 438
Joined: Tue Apr 15, 2014 4:19 pm
Location: Kajaani, Finland
Contact:

Re: Modbus Slave Address

Post by EtsDriver »

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? [/size]
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
(69.95 KiB) Downloaded 141 times
Test-Modbus_PresetSingleRegister.c
V6 file
(76.45 KiB) Downloaded 151 times
Ill just keep the good work up!

User avatar
Benj
Matrix Staff
Posts: 15009
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: Modbus Slave Address

Post by Benj »

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.

Konstantiant
Posts: 12
Joined: Sun May 09, 2010 7:57 pm
Contact:

Re: Modbus Slave Address

Post by Konstantiant »

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 154 times
Thanks

Konstantiant
Posts: 12
Joined: Sun May 09, 2010 7:57 pm
Contact:

Re: Modbus Slave Address

Post by Konstantiant »

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: 15009
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: Modbus Slave Address

Post by Benj »


lordhex
Posts: 54
Joined: Mon Dec 30, 2013 2:09 am
Contact:

Re: Modbus Slave Address

Post by lordhex »

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: 15009
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: Modbus Slave Address

Post by Benj »

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.

claudemir
Posts: 55
Joined: Sat Nov 03, 2012 7:43 am
Contact:

Re: Modbus Slave Address

Post by claudemir »

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?

Post Reply