Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - kiryat8

Pages: [1]
1
NXPTM LPC2XXX and LPC17XX / Re: Modbus User task callback
« on: September 11, 2014, 08:21:08 AM »
I did not think of the RS485 echo which in my original code I handled.
I just disabled the RS485  receiver while transmitting and it works well.
I found that the write multiple register returns under USER_RECEIVING_ALL_MODBUS_TYPE while the other
Modbus functions that I use return under USER_RECEIVING_MODBUS_UNDEFINED_FUNCTION
which is no problem at all.

Thanks

2
NXPTM LPC2XXX and LPC17XX / Modbus User task callback
« on: September 10, 2014, 07:06:44 AM »
When implementing a Modbus RTU slave...
I have all NULL pointers passed to the fnInitialiseMODBUS_port() function so I get an user callback.
static int fnMODBUSSlaveuserFunction(int iType, MODBUS_RX_FUNCTION *modbus_rx_function)
Using the code below I determine which Modbus command was received and handle accordingly.
  switch(iType){
    case USER_RECEIVING_MODBUS_UNDEFINED_FUNCTION:
       switch (modbus_rx_function->ucFunctionCode){
          case MODBUS_WRITE_SINGLE_REGISTER://         0x06
             ...
             fnMODBUS_transmit(modbus_rx_function,modbus_HostBuf,8);
             return 0;
           case MODBUS_WRITE_MULTIPLE_REGISTERS://      0x10
       } // switch Modbus message type
  } // switch

1) The problem I have is that I get two calls to the function.
  The first time when receiving the incoming message and the second time after my reply was sent.
  In the read request message I checked the MODBUS_RX_FUNCTION fields to detect the reply,
  BUT in the MODBUS_WRITE_SINGLE_REGISTER the reply is exactly the same as the incoming message.
  How can I differentiate between the reply and the incoming callbacks?

2) I receive the MODBUS_WRITE_MULTIPLE_REGISTERS message as 0x90 instead of 0x10.
I can not find out why?

Thanks
David Kaplan




3
MODBUS / Re: MODBUS IP to serial (RTU) gateway
« on: August 27, 2014, 05:41:39 AM »
I found that _HW_TIMER_MODE was not defined. It is used only in ADC_Timers.h fnConfigure_Timer() and in debug.c fnTestTCPServer() in the test project.

A few other questions:
1) When I enable the HTTP server demo together with USE_MODBUS , I can not upload ftp files and the web pages are destroyed. I guess that the fnGetMODBUS_parameters() in modbus_app.c needs to be changed somehow.
I use a SPI_FLASH_SST25VF080B external flash chip which works fine.

2) Our application uses a Modbus RTU slave along with a Modbus TCP slave accessing the exact same data.
My defined Modbus registers are in several address ranges so I guess that I set the second parameter in the fnInitialiseMODBUS_port() function to NULL and I will get notified in the fnMODBUSuserFunction callback?
I must manually send a reply with fnMODBUS_transmit and return zero if all is correct?
Do you have a code snippet example. We use mainly Rd/Wr Holding registers.

Thanks

4
MODBUS / Re: MODBUS IP to serial (RTU) gateway
« on: August 26, 2014, 12:32:41 PM »
In the LPC's tcpip.h file I added the following that I found in the kinetis version.
Now

// ?!? added
#if IP_INTERFACE_COUNT > 1 || IP_NETWORK_COUNT > 1                       // {74}
    #define _TCP_SOCKET_MASK_ASSIGN(uSocket)  (uSocket &= (SOCKET_NUMBER_MASK))
    #define _TCP_SOCKET_MASK(uSocket)  (USOCKET)((uSocket) & (SOCKET_NUMBER_MASK))
    #define _UDP_SOCKET_MASK_ASSIGN(uSocket)  (uSocket &= (SOCKET_NUMBER_MASK))
    #define _UDP_SOCKET_MASK(uSocket)  (USOCKET)((uSocket) & (SOCKET_NUMBER_MASK))
#else
    #define _TCP_SOCKET_MASK_ASSIGN(uSocket)                             // does nothing when single interface and single networks
    #define _TCP_SOCKET_MASK(uSocket) (uSocket)
    #define _UDP_SOCKET_MASK_ASSIGN(uSocket)
    #define _UDP_SOCKET_MASK(uSocket) (uSocket)
#endif

5
MODBUS / Re: MODBUS IP to serial (RTU) gateway
« on: August 26, 2014, 08:18:30 AM »
I downloaded the latest Modbus code to be used with the latest LPC code base.
As I wrote there is no timer_us_value field in the TIMER_INTERRUPT_SETUP structure.
There is also no "_TCP_SOCKET_MASK" macro defined.
Should I use a different Modbus version or where can I get the new defines?

Thanks

6
MODBUS / Re: MODBUS IP to serial (RTU) gateway
« on: August 26, 2014, 07:26:47 AM »
Did you ever get resolved the lack of the lacking timer_us_value field in TIMER_INTERRUPT_SETUP.
I am implementing the Modbus now using the LPC1768 chip and get the same errors.
Thanks

Pages: [1]