Page 1 of 1

Modbus Slave

Posted: Mon Aug 01, 2016 9:16 am
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

Re: Modbus Slave

Posted: Mon Aug 01, 2016 12:27 pm
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 489 times
Here are the example files.
ModBus_Master_Example1.fcfx
(12.88 KiB) Downloaded 451 times
ModBus_Slave_Example1.fcfx
(10.23 KiB) Downloaded 484 times

Re: Modbus Slave

Posted: Tue Aug 02, 2016 10:46 am
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

Re: Modbus Slave

Posted: Wed Aug 03, 2016 11:09 am
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?

Re: Modbus Slave

Posted: Wed Aug 03, 2016 2:12 pm
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

Re: Modbus Slave

Posted: Wed Aug 03, 2016 2:47 pm
by Benj
Investigating this now....

Re: Modbus Slave

Posted: Wed Aug 03, 2016 3:55 pm
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 432 times
ModbusSlave.fcpx
(89.02 KiB) Downloaded 423 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 421 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 427 times
ModBus_Slave_Example2.fcfx
(11.75 KiB) Downloaded 429 times

Re: Modbus Slave

Posted: Sun Aug 07, 2016 5:51 pm
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

Re: Modbus Slave

Posted: Mon Aug 08, 2016 3:36 pm
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 432 times
ModBus_Slave_Example3.fcfx
(12.47 KiB) Downloaded 389 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.

Re: Modbus Slave

Posted: Wed Aug 10, 2016 7:47 pm
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 349 times
Test-ModbusMaster-ForceSingleCoil-V6.c
(38 KiB) Downloaded 349 times
Test-ModbusMaster-ForceSingleCoil-V7.c
(41.3 KiB) Downloaded 358 times
Thank you very mach

Re: Modbus Slave

Posted: Wed Aug 10, 2016 7:53 pm
by Konstantiant
Code Stoping on ATMega32A4.png
(29.33 KiB) Downloaded 2899 times

Re: Modbus Slave

Posted: Thu Aug 11, 2016 3:01 pm
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.

Re: Modbus Slave

Posted: Thu Aug 11, 2016 4:49 pm
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

Re: Modbus Slave

Posted: Tue Aug 16, 2016 11:04 am
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 277 times
Let me know how you get on.

Re: Modbus Slave

Posted: Tue Aug 16, 2016 1:47 pm
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

Re: Modbus Slave

Posted: Tue Aug 16, 2016 5:13 pm
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 316 times

Re: Modbus Slave

Posted: Fri Aug 19, 2016 7:05 pm
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