Modbus Slave

A forums to allow resolved bugs and problems with Flowcode v7 to be stored and marked as resolved.

Moderator: Benj

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

Modbus Slave

Postby Konstantiant » Mon Aug 01, 2016 9:16 am

Good Morning
The Componet Modbus Slave on the Flowcode 7, reseive data but no trasmite data (No responce).
Please. You could fix it and send?

Thank you very mutch

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

Re: Modbus Slave

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

Hello,

Yes your right there was a problem with the ModBus Slave receive. The interrupt macro called when it receives a byte was not being implemented correctly.

I have now fixed the component and also here is an example that I have up and running on hardware.

ModbusSlave.fcpx
(88.08 KiB) Downloaded 248 times


Here are the example files.

ModBus_Master_Example1.fcfx
(12.88 KiB) Downloaded 205 times

ModBus_Slave_Example1.fcfx
(10.23 KiB) Downloaded 247 times
These users thanked the author Benj for the post:
dazz (Tue Aug 02, 2016 2:50 pm)
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

Postby Konstantiant » Tue Aug 02, 2016 10:46 am

Good Morning

Thank you very much for reply.
The macro ReadCoilState working Perfect. no errors and very fast.
Please. You want to fix macro SetAnalogeInput.

Thank and best regards
These users thanked the author Konstantiant for the post (total 2):
Benj (Tue Aug 02, 2016 11:47 am) • dazz (Tue Aug 02, 2016 2:50 pm)
Rating: 10.53%
 

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

Re: Modbus Slave

Postby lordhex » Wed Aug 03, 2016 11:09 am

Konstantiant wrote:Good Morning

Thank you very much for reply.
The macro ReadCoilState working Perfect. no errors and very fast.
Please. You want to fix macro SetAnalogeInput.

Thank and best regards

Do you mean SetAnalogInput not working?

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

Re: Modbus Slave

Postby Konstantiant » Wed Aug 03, 2016 2:12 pm

Hello
Yes, they have all Macro behavior of macro ReadcoilState. And it shown when positions the cursor to the address showing your coilAddress, while you you select a setAnalogInput.
I believe that the Matrix team will soon complete the componets Modbus slave.
coil.png
coil.png (62.31 KiB) Viewed 8839 times

Thanks

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

Re: Modbus Slave

Postby Benj » Wed Aug 03, 2016 2:47 pm

Investigating this now....

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

Re: Modbus Slave

Postby Benj » Wed Aug 03, 2016 3:55 pm

Found the problem now, all seems to be working well again with the updated components attached. As usual just drop these into your "Flowcode 7/Components" directory before starting/restarting Flowcode.

Modbus.fcpx
(18.04 KiB) Downloaded 188 times

ModbusSlave.fcpx
(89.02 KiB) Downloaded 195 times


I also found a problem where the UART timeout on 8-bit PIC was taking far too long so here is the fix for that. This file lives in the "Flowcode 7/CAL/PIC" directory.

PIC_CAL_UART.c
(24.12 KiB) Downloaded 184 times


Lastly here is another example using the ReadInputRegister command which is now working nicely here on my desk.

ModBus_Master_Example2.fcfx
(12.75 KiB) Downloaded 186 times

ModBus_Slave_Example2.fcfx
(11.75 KiB) Downloaded 198 times
These users thanked the author Benj for the post (total 4):
EtsDriver (Wed Aug 03, 2016 4:33 pm) • petesmart (Wed Aug 03, 2016 8:47 pm) • Konstantiant (Thu Aug 04, 2016 6:23 pm) • lordhex (Fri Aug 05, 2016 11:40 pm)
Rating: 21.05%
 

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

Re: Modbus Slave

Postby Konstantiant » Sun Aug 07, 2016 5:51 pm

Hello
The Modbus Master component working well, but the macro ReadInputRegister,for RegAddress value >3 not responding.
The modbus Slave component working with Device ATMega2560 but no with Device ATXMega32A4.
Please you can check the AVR_CAL_UART.C ?
Thank you very mach
Attachments
Slave_SetAnalogInputATxMega32A4_FCV_7.fcfx
(11.14 KiB) Downloaded 156 times

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

Re: Modbus Slave

Postby Benj » Mon Aug 08, 2016 3:36 pm

Hello,

I've just tested the Modbus Master and Slave with a ReadInputRegister(28, 0, 6) and this is working well on the PIC target.

ModBus_Master_Example3.fcfx
(13.26 KiB) Downloaded 196 times

ModBus_Slave_Example3.fcfx
(12.47 KiB) Downloaded 187 times


It initially wasn't working but I had forgotten to connect the grounds of the two uCs together. School boy error :wink:

With the ATXMEGA device. Have you done a 1 second flasher test to confirm the chip is running at the correct speed.
http://www.matrixtsl.com/wikiv7/index.p ... ED_flasher

Another thing you can try is to add a RS232 component, call the initialise macro and then inside a while 1 loop send out the value 0xAA. This should give you a waveform which you can check out with a scope or signal analyser to double check the baud is being calculated correctly. Both the mark and space wave cycles should be around about 104.166uS with a baud of 9600.

I don't currently have an XMEGA device to hand but I can get hold of some if this is proving to have issues.

Personally I wanted to love the XMEGA devices when they came out but then I tried to use one and quickly went off them. They have some nice features but for me are very peculiar and awkward, the EP range of dsPICs I feel is far superior.
These users thanked the author Benj for the post (total 2):
EtsDriver (Mon Aug 08, 2016 4:52 pm) • Konstantiant (Tue Aug 09, 2016 12:17 pm)
Rating: 10.53%
 

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

Re: Modbus Slave

Postby Konstantiant » Wed Aug 10, 2016 7:47 pm

Hello

I've just tested the Modbus Master with forceSingleCoil on the ATXMega32A4 target, with Flowcode 6 and Flowcode 7.
The clock on the MCU is correct. The Led Flashing per sec.
The attach file Test-ModbusMaster-ForceSingleCoil-V6 working well
When opening with Flowcode 7, stopping on the macro ModbusMaster,ForceSingleCoil, and the led is permanent on.
Please, compare the code C from the FC6, with code C from the FC7

Test-ModbusMaster-ForceSingleCoil-V6.c
(39.29 KiB) Downloaded 186 times

Test-ModbusMaster-ForceSingleCoil-V6.c
(39.29 KiB) Downloaded 186 times

Test-ModbusMaster-ForceSingleCoil-V7.c
(42.74 KiB) Downloaded 200 times


Thank you very mach
Attachments
Test-ModbusMaster-ForceSingleCoil-V6.fcfx
(47.69 KiB) Downloaded 146 times
These users thanked the author Konstantiant for the post:
Benj (Wed Aug 10, 2016 8:01 pm)
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

Postby Konstantiant » Wed Aug 10, 2016 7:53 pm

Code Stoping on ATMega32A4.png
(29.34 KiB) Downloaded 2899 times
These users thanked the author Konstantiant for the post:
Benj (Wed Aug 10, 2016 8:01 pm)
Rating: 5.26%
 

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

Re: Modbus Slave

Postby Benj » Thu Aug 11, 2016 3:01 pm

Hmm,

There are differences in both the AVR CAL UART and the Component C code from v6 to v7, however there is nothing show stopping jumping out at me. Mostly minor reliability improvements.

I'll keep looking...

To confirm if it's a CAL problem you should be able to take the v6 UART CAL file from "Flowcode 6/CAL/AVR" and copy into the same folder in v7. Make a backup of the v7 file first so you can go back. Then just re-compile your v7 project.

Let me know how you get on with this.

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

Re: Modbus Slave

Postby Konstantiant » Thu Aug 11, 2016 4:49 pm

Hello

The replace V6 AVR_UART CAL has no change.
Because I observe that at the start MCU, sends only one time data properly, and stops, I personally think that run within in a continuous loop, on macro ModbusMasterForceSingleCoil.

Thank you very mach

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

Re: Modbus Slave

Postby Benj » Tue Aug 16, 2016 11:04 am

Hello,

Hmm right one thing I did notice is that Flowcontrol is enabled in the CAL UART component inside the Modbus Master component.

I have now forced this setting to be in the off state so hopefully this should work better.

Modbus.fcpx
(18.4 KiB) Downloaded 130 times


Let me know how you get on.

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

Re: Modbus Slave

Postby Konstantiant » Tue Aug 16, 2016 1:47 pm

Hello

Thank you very much.
The Component Modbus Master working very well and on the ATMEGA32 Device.
Please, you can fix and the component Modbus Slave (CAL UART inside)

Best regards

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

Re: Modbus Slave

Postby Benj » Tue Aug 16, 2016 5:13 pm

Hello,

Here is the ModBus Slave component with the same fix, though hopefully this should not be an issue with the slave.

ModbusSlave.fcpx
(89.02 KiB) Downloaded 167 times
These users thanked the author Benj for the post:
Konstantiant (Wed Aug 17, 2016 9:17 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

Postby Konstantiant » Fri Aug 19, 2016 7:05 pm

Hello

The component Modbus Slave, now run normaly on the flow chart,
but the macro CheckForIncoming, have return value [0], and the MCU ATMega32A4U not responds.
Please check the Macro CheckForInkoming.

Thank you very mach