problem with Modbus Master in Flowcode v7
Moderator: Benj
-
- Posts: 36
- Joined: Mon Dec 22, 2014 10:04 pm
- Location: TALLINN
- Has thanked: 5 times
- Been thanked: 2 times
- Contact:
problem with Modbus Master in Flowcode v7
Hello,
I have some expirience with Fc v6 and just purchaced Flowcode v7 because need to make devices with Modbus connectivity.
Question, have Modbus component any restrictions for choosing PIC microcontrollers?
In attachement my small flowchart for testing Modbus master component, my testboard have PIC16F877A with 19,660 crystal.
It have MCP23017 with LEDs , connected via I2C to PIC, and oneLED conected to port RD4. This LED flash once per second to show that program running.
Pushbutton connected to port RE0.
If controller powers up, RD4 LED start flashing and I2C LEDs show preprogrammed value.
If I press the RE0 button, program need to read inputs via Modbus from Slave 1, but program stop working and not running so long, as button pressed. If button released, program will run again.
Is it problem with my logic, or hardware problem (incompatible controller) ?
I have some expirience with Fc v6 and just purchaced Flowcode v7 because need to make devices with Modbus connectivity.
Question, have Modbus component any restrictions for choosing PIC microcontrollers?
In attachement my small flowchart for testing Modbus master component, my testboard have PIC16F877A with 19,660 crystal.
It have MCP23017 with LEDs , connected via I2C to PIC, and oneLED conected to port RD4. This LED flash once per second to show that program running.
Pushbutton connected to port RE0.
If controller powers up, RD4 LED start flashing and I2C LEDs show preprogrammed value.
If I press the RE0 button, program need to read inputs via Modbus from Slave 1, but program stop working and not running so long, as button pressed. If button released, program will run again.
Is it problem with my logic, or hardware problem (incompatible controller) ?
- Attachments
-
- IMG_201606.jpg
- (504.71 KiB) Downloaded 1899 times
-
- modbus_master_1.fcfx
- (17.22 KiB) Downloaded 328 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: problem with Modbus Master in Flowcode v7
Hello,
The Modbus component will work with any microcontroller that has a UART peripheral.
Have you seen the Flowcode 7 update files available here.
http://www.matrixtsl.com/mmforums/viewt ... 63&t=17953
They contain some component fixes for Modbus which may solve the problem you're having.
The Modbus component will work with any microcontroller that has a UART peripheral.
Have you seen the Flowcode 7 update files available here.
http://www.matrixtsl.com/mmforums/viewt ... 63&t=17953
They contain some component fixes for Modbus which may solve the problem you're having.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 36
- Joined: Mon Dec 22, 2014 10:04 pm
- Location: TALLINN
- Has thanked: 5 times
- Been thanked: 2 times
- Contact:
Re: problem with Modbus Master in Flowcode v7
Thanks!
Now example Master-Slave works fine.
But I am confused with reading analog input...
What way is ok?
1. --Use ADC component and read adc value adc0_read.
--Write this value to holding register with SetHoldingRegister with address 1 and value adc0_read.
--Master read the register state (slave address 1, register aadress 1, return value adc0_rd)
2. -- Slave component have function ReadAnalogueInput with address and Return value. Address is 1 and return value is adc0_read. How I can associate address 1 with PIC port An0?.
I need set to work one example, where master ask from slave analog input value and show it in master RD ports.
Many thanks!
Now example Master-Slave works fine.
But I am confused with reading analog input...
What way is ok?
1. --Use ADC component and read adc value adc0_read.
--Write this value to holding register with SetHoldingRegister with address 1 and value adc0_read.
--Master read the register state (slave address 1, register aadress 1, return value adc0_rd)
2. -- Slave component have function ReadAnalogueInput with address and Return value. Address is 1 and return value is adc0_read. How I can associate address 1 with PIC port An0?.
I need set to work one example, where master ask from slave analog input value and show it in master RD ports.
Many thanks!
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: problem with Modbus Master in Flowcode v7
Hello,
You need to use option 1. Although they are called AnalogueInputs they are basically a second set of holding registers.
i.e. use an ADC component to take an analogue reading.
Store the reading either in a holding register (SetHoldingRegister) or in an analogue Input register (SetAnalogueInput).
Read the corresponding register using the Master.
Hope this helps.
You need to use option 1. Although they are called AnalogueInputs they are basically a second set of holding registers.
i.e. use an ADC component to take an analogue reading.
Store the reading either in a holding register (SetHoldingRegister) or in an analogue Input register (SetAnalogueInput).
Read the corresponding register using the Master.
Hope this helps.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 36
- Joined: Mon Dec 22, 2014 10:04 pm
- Location: TALLINN
- Has thanked: 5 times
- Been thanked: 2 times
- Contact:
Re: problem with Modbus Master in Flowcode v7
Sorry, but have problem with adc....
my test program steps:
--read analog value adc0
--write to register SetHoldingRegister addr0,
In ModbusSlave parameters Register aadresses starts with 0
Master side:
--ReadHoldingRegister slave id28, register address0, count0
And answer zero....
Maybe any problem with regesters addressing?
Regards,
Mihhail
my test program steps:
--read analog value adc0
--write to register SetHoldingRegister addr0,
In ModbusSlave parameters Register aadresses starts with 0
Master side:
--ReadHoldingRegister slave id28, register address0, count0
And answer zero....
Maybe any problem with regesters addressing?
Regards,
Mihhail
- Attachments
-
- mod_master_1.fcfx
- (14.49 KiB) Downloaded 326 times
-
- ModBus_Slave_Example1 (1).fcfx
- (11.18 KiB) Downloaded 325 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: problem with Modbus Master in Flowcode v7
Hello Mihhail,
In the Master program for the ReadHoldingRegister component macro you have the RegCount parameter set to 0, I think this needs to be set to 1.
Hopefully that change will allow the code to work as expected.
In the Master program for the ReadHoldingRegister component macro you have the RegCount parameter set to 0, I think this needs to be set to 1.
Hopefully that change will allow the code to work as expected.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 36
- Joined: Mon Dec 22, 2014 10:04 pm
- Location: TALLINN
- Has thanked: 5 times
- Been thanked: 2 times
- Contact:
Re: problem with Modbus Master in Flowcode v7
Hello,
set to 1 not working too... Master just havent read a Holding register values. I just tried to put a fixed value 0x1f to Holding register address 0 in Slave side. No change, output zero
Master side translate address 0 to 40001, 1 to 40002 etc... As the slave side do the same?
In ModbusSlave parameters Modbus Register start value 0 will be translated to 40001 too?
Updated:
On Master side function PresetHoldingRegister works fine, master write to holding register addr0 on slave side fix value and show it on local slave LCD display, but read again the same register from slave by master give zero
set to 1 not working too... Master just havent read a Holding register values. I just tried to put a fixed value 0x1f to Holding register address 0 in Slave side. No change, output zero
Master side translate address 0 to 40001, 1 to 40002 etc... As the slave side do the same?
In ModbusSlave parameters Modbus Register start value 0 will be translated to 40001 too?
Updated:
On Master side function PresetHoldingRegister works fine, master write to holding register addr0 on slave side fix value and show it on local slave LCD display, but read again the same register from slave by master give zero
Last edited by radist73 on Wed Sep 14, 2016 2:55 pm, edited 3 times in total.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: problem with Modbus Master in Flowcode v7
Hello,
I'll see if I can rig up something here and replicate the issue for you.
Yes both the master and slave should translate the addresses for you: 0 to 40001, 1 to 40002 etc.Master side translate address 0 to 40001, 1 to 40002 etc.
I'll see if I can rig up something here and replicate the issue for you.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 36
- Joined: Mon Dec 22, 2014 10:04 pm
- Location: TALLINN
- Has thanked: 5 times
- Been thanked: 2 times
- Contact:
Re: problem with Modbus Master in Flowcode v7
Hello,
I has checked all Read from slave functions (ReadHoldingRegister, ReadInputStatus, ReadCoilStatus) and I hasnt it working.
Locally in slave ReadCoilStatus works fine, but all remote read functions not work....
The same Master program on Flowcode 6 works, but veeery slowly, one TX per 4sec And in FC6 modbus master component properties I cant change Silent time and RX timeout, I think they have by default 60 and 220 values .. If I press button on master side, slave answer after 10sec and reading register again from slave give answer to master after 30sec
I has checked all Read from slave functions (ReadHoldingRegister, ReadInputStatus, ReadCoilStatus) and I hasnt it working.
Locally in slave ReadCoilStatus works fine, but all remote read functions not work....
The same Master program on Flowcode 6 works, but veeery slowly, one TX per 4sec And in FC6 modbus master component properties I cant change Silent time and RX timeout, I think they have by default 60 and 220 values .. If I press button on master side, slave answer after 10sec and reading register again from slave give answer to master after 30sec
-
- Posts: 36
- Joined: Mon Dec 22, 2014 10:04 pm
- Location: TALLINN
- Has thanked: 5 times
- Been thanked: 2 times
- Contact:
Re: problem with Modbus Master in Flowcode v7
Hello,
I found working example
http://www.matrixtsl.com/mmforums/viewt ... bus#p76164 Example3 and understand, but my logic understanding was wrong
Thank you!
I found working example
http://www.matrixtsl.com/mmforums/viewt ... bus#p76164 Example3 and understand, but my logic understanding was wrong
Thank you!
Re: problem with Modbus Master in Flowcode v7
I have try most of examples but still getting CRC Error.
Master works fine with Modbus PLC simulators.
but no luck with slave.
Master works fine with Modbus PLC simulators.
but no luck with slave.
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: problem with Modbus Master in Flowcode v7
Hi hsavas
Have you updated with the latest components from here? ...
http://www.matrixtsl.com/mmforums/viewt ... 63&t=18760
Have you updated with the latest components from here? ...
http://www.matrixtsl.com/mmforums/viewt ... 63&t=18760