|
|
0
Offline
Newbie
Karma: 0
Posts: 44
Arduino rocks
|
 |
« Reply #1 on: April 21, 2010, 12:23:37 pm » |
i am locked: timing in TCP management doesn't work as it sould: replies are sent with a delay i don't want. this make timeout occur. probably this happens due to a too big transmission buffer: i can't resize it! nor i can set the TCP_NODELAY option (library doesn't offer this). any suggestion? please help me, i think my project could be very useful!
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 44
Arduino rocks
|
 |
« Reply #2 on: April 22, 2010, 08:13:29 am » |
my libraty is finished and it seems to work perfectly... ;D
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 55
Arduino rocks
|
 |
« Reply #3 on: June 10, 2010, 11:03:35 am » |
nice work can you please explain a bit a about how to use it?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 44
Arduino rocks
|
 |
« Reply #4 on: June 11, 2010, 04:46:53 am » |
ok. i'll write down a few lines, then i'll make a wiki for it: modbusmq is a ModBus ( http://en.wikipedia.org/wiki/Modbus ) TCP slave (server): briefly, it holds a data map, which can be queried by Modbus clients (PC or other) with a standard protocol. requirements: - Arduino Ethernet Shield usage:Arduino side - paste the code in a new project in the Arduino IDE - change the network params, if needed: IP, Gateway. - change the slave Address, if needed - set or unset the DEBUG flag to have debug messages through serial line PC side: - start a modbus client to query Arduino IP, with the correct slave modbus address (there are many freeware, eg: ModScan) TODO: - test two slaves in the same network. - test two masters (clients) for the same slave
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 7
Arduino rocks
|
 |
« Reply #5 on: August 27, 2010, 08:50:37 am » |
Hello,
I just tested the Modbusmq and so far it works fine. But I'm struggling a little with all the pointers.
I already managed to send a modbus command from a PC, which sets different bits to true.
But now I want to switch relais, which are connected to a PCF8574. For this I normally use the command:
PCF8574Write(B11111110);
Now I tried to convert the "mb_mapping->tab_coil_status" to a value which I can send with PCF8574Write. But without success. It is too long ago, that I have done somethink with pointers. I tried the following:
for (n=0;n<8;n++) { PCFStatus1[n] = byte(*(mb_mapping->tab_coil_status + n)); DEBUG_PRINTLN(n); delay(200); }
This seems to me not very efficient and it is also not working.
Can someone help?
BR,
Chris
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 44
Arduino rocks
|
 |
« Reply #6 on: August 27, 2010, 09:06:07 am » |
PCF8574Write(B11111110); what command is it? a function from you? from a library? if you have to copy bytes to/from a vector, use the memcpy() standard C function. reference: http://www.cplusplus.com/reference/clibrary/cstring/memcpy/maybe memcpy(PCFStatus1, mb_mapping->tab_coil_status, n); bye quark
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 7
Arduino rocks
|
 |
« Reply #7 on: August 27, 2010, 10:53:02 am » |
Sounds very promising! But I still have some problems. I tried the following: byte PCFStatus1; memcpy(PCFStatus1, mb_mapping.tab_coil_status,  ; PCF8574Write(PCFStatus1); Here the function: //Write data to PCF8574 void PCF8574Write(byte _data ) { Wire.beginTransmission(PCF8574_ADDR); Wire.send(_data); Wire.endTransmission(); } But I get the following error: error: invalid conversion from 'uint8_t' to 'void*' I do not understand it, why void*? Any idea?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 7
Arduino rocks
|
 |
« Reply #8 on: August 27, 2010, 11:04:33 am » |
Hello,
can you give some explanations for the following (is there already some wiki):
If data are correct received, how to use them in the main loop?
I assume there are the following buffers/memorys: mb_mapping->nb_coil_status mb_mapping->nb_input_status mb_mapping->nb_holding_registers mb_mapping->nb_input_registers
I have also seen some functions like "get_byte_from_bits".
Is there somewhere a more detailed explanation? Maybe in the libmodbus library?
For my problem to write data to the PCF8574 can I use the "get_byte_from_bits" function? But how exactly?
Thank you for your help!
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 7
Arduino rocks
|
 |
« Reply #9 on: August 27, 2010, 12:43:29 pm » |
Got it running with the following code: int PCFStatus1; // Gets the byte value from many input/coil status. PCFStatus1 = get_byte_from_bits(mb_mapping.tab_coil_status, 0,  ; PCF8574Write(byte(PCFStatus1));
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 4
Arduino rocks
|
 |
« Reply #10 on: August 29, 2010, 11:10:06 am » |
I am having trouble getting the modbus sketch to even work on my arduino mega and ethernet shield. Where do I edit the network settings. I tried following the example, but I cannot even ping the arduino. Is there some setup for the wiznet chip? Any help would be appreciated. I am trying to get RC servo control using modbus words.
Thanks
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 2
Arduino rocks
|
 |
« Reply #11 on: August 30, 2010, 11:09:08 am » |
Hello, it works fine (in my initial test), but the DEBUG flag has to be disabled because if it is enables the Arduino hangs :-/, so I can't debug or use the serial port for interchange data.
Any idea to make it work with debug flag?.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 7
Arduino rocks
|
 |
« Reply #12 on: August 31, 2010, 10:21:39 am » |
I got it working with the DEBUG flag, but it starts working only after having the serial monitor started.
I made the following network settings: const byte gateway[] = { 192, 168, 2, 254 }; const byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; const byte ip[] = { 192, 168, 2, 100 }; // Arduino has this IP
You have to use the same subnet (192.168.2.x) as your computer uses.
BR,
Chris
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 22
Arduino rocks
|
 |
« Reply #13 on: September 10, 2010, 11:14:48 am » |
Can anyone give me an example how to read an input on the Arduino, and map the I/O status to be polled by the Master?
I am not sure how the mapping is handled.
|
|
|
|
|
Logged
|
|
|
|
|
Nova Scotia, CA
Offline
Jr. Member
Karma: 0
Posts: 64
A world that runs on bits and bytes!
|
 |
« Reply #14 on: September 12, 2010, 11:19:19 pm » |
wow great to see MODBUS/TCP functional. this library will certainly come in handy.
|
|
|
|
|
Logged
|
Common sense is not so common...
|
|
|
|
|