Modbus Slave

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

Moderator: Benj

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

Modbus Slave

Post by Konstantiant »

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: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Modbus Slave

Post by Benj »

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 553 times
Here are the example files.
ModBus_Master_Example1.fcfx
(12.88 KiB) Downloaded 523 times
ModBus_Slave_Example1.fcfx
(10.23 KiB) Downloaded 581 times

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

Re: Modbus Slave

Post by Konstantiant »

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

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

Re: Modbus Slave

Post by lordhex »

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

Re: Modbus Slave

Post by Konstantiant »

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
(62.31 KiB) Downloaded 10251 times
Thanks

User avatar
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: Modbus Slave

Post by Benj »

Investigating this now....

User avatar
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: Modbus Slave

Post by Benj »

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 508 times
ModbusSlave.fcpx
(89.02 KiB) Downloaded 484 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
(23.29 KiB) Downloaded 527 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 511 times
ModBus_Slave_Example2.fcfx
(11.75 KiB) Downloaded 487 times

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

Re: Modbus Slave

Post by Konstantiant »

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 469 times

User avatar
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: Modbus Slave

Post by Benj »

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 529 times
ModBus_Slave_Example3.fcfx
(12.47 KiB) Downloaded 462 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.

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

Re: Modbus Slave

Post by Konstantiant »

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
(38 KiB) Downloaded 451 times
Test-ModbusMaster-ForceSingleCoil-V6.c
(38 KiB) Downloaded 451 times
Test-ModbusMaster-ForceSingleCoil-V7.c
(41.3 KiB) Downloaded 441 times
Thank you very mach
Attachments
Test-ModbusMaster-ForceSingleCoil-V6.fcfx
(47.69 KiB) Downloaded 371 times

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

Re: Modbus Slave

Post by Konstantiant »

Code Stoping on ATMega32A4.png
(29.33 KiB) Downloaded 2899 times

User avatar
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: Modbus Slave

Post by Benj »

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

Re: Modbus Slave

Post by Konstantiant »

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: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Modbus Slave

Post by Benj »

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 372 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

Re: Modbus Slave

Post by Konstantiant »

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: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Modbus Slave

Post by Benj »

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 384 times

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

Re: Modbus Slave

Post by Konstantiant »

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

Post Reply