You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old October 22nd, 2018, 01:57 AM   #1
hmwright
Member
Australia

hmwright is offline
 
Join Date: Oct 2018
Location: Australia
Posts: 3
M340 Modbus Comms, None sequential write

I am learning Modbus and having a issue writing some code to write a value to a specified register where I also need to write the 1's complement in the same write. This isto a Deep Sea Electronics Governor module. I have to set the module to AUTO by writing 1 to register 35701 and in teh same write also write 1 to the 1's complement at 29834. The writevar command works only with sequential addresses so that leaves me stuck.

Hoping somebody can let me know how its done in Unity Pro.
  Reply With Quote
Old October 22nd, 2018, 02:38 AM   #2
lfe
Member
France

lfe is offline
 
Join Date: Jun 2007
Location: Barcelona
Posts: 279
Modbus can't write or read multiple non consecutive addresses in a single request.

Also if the address 35701 refers to an Analog Input then you can't write it due Analog Inputs are read only.
__________________
Suppanel HMI
  Reply With Quote
Old October 22nd, 2018, 02:48 AM   #3
hmwright
Member
Australia

hmwright is offline
 
Join Date: Oct 2018
Location: Australia
Posts: 3
Extract from DSE Manual

From DSE Litriture.

Control is performed by sending System Control Keys to the module, and also sending the bitwise opposite
(or one’s compliment) of the control key to another register ‘in the same write operation’ for security.


Hence I assume it must be posible or why do it ?
  Reply With Quote
Old October 22nd, 2018, 10:44 AM   #4
lfe
Member
France

lfe is offline
 
Join Date: Jun 2007
Location: Barcelona
Posts: 279
Perhaps that phrase also refers to other protocols that are supported by the device, in other protocols such as Ethernet/P it is possible to write non-contiguous positions in a single request, but Modbus does not allow it.
__________________
Suppanel HMI
  Reply With Quote
Old October 22nd, 2018, 10:55 AM   #5
Lare
Member
Finland

Lare is offline
 
Join Date: Jan 2006
Location: Finland
Posts: 1,046
is that Modbus TCP or serial?

If serial, you can't write to different addresses same time which isn't consecutive

if TCP, then you can send two different requests on same time.
  Reply With Quote
Old October 22nd, 2018, 04:04 PM   #6
5618
Member
United States

5618 is online now
 
Join Date: Oct 2017
Location: York, PA
Posts: 52
The 35701 and 29834 values are 1’s complement of each other. I think you’ll find that values like that are the data to be written to consecutive registers, not the actual register addresses. You’ll probably do a modbus function 16 - ‘write multiple registers’ to a series of registers starting at a five or maybe six digit address that begins with 4. I am not familiar with the M340. Depending on your system, your instruction might omit that leading 4 and the starting register might be one less than documented in the governor literature.

Last edited by 5618; October 22nd, 2018 at 04:07 PM.
  Reply With Quote
Old October 23rd, 2018, 01:09 AM   #7
hmwright
Member
Australia

hmwright is offline
 
Join Date: Oct 2018
Location: Australia
Posts: 3
Solved - Sort Of Limits of write_var

I read again the book and yes they are consecutive registers which lets me use the write_var or so I thought. Registers are 4104 and 4105

Now a new issue is that the DSE controller is expecting a key to be written in one register and its ones complement in the other. For some reason the keys start at 35700.

The issue is write_var has an INT array which is signed hence I can only write values up to 32,768.

Is their another way to wright unsigned integers with write_var
  Reply With Quote
Old October 23rd, 2018, 02:37 PM   #8
Lare
Member
Finland

Lare is offline
 
Join Date: Jan 2006
Location: Finland
Posts: 1,046
Quote:
Originally Posted by hmwright View Post
I read again the book and yes they are consecutive registers which lets me use the write_var or so I thought. Registers are 4104 and 4105

Now a new issue is that the DSE controller is expecting a key to be written in one register and its ones complement in the other. For some reason the keys start at 35700.

The issue is write_var has an INT array which is signed hence I can only write values up to 32,768.

Is their another way to wright unsigned integers with write_var

unsigned integer and signed integers differs only how 16 bits are converted to numerical view, 16th bit is number or +/- sign.

you have 0..65535 or -32767..+32768 numbers dependig of integer type



Use uint to int conversion block before write block, on bit level both numbers have same bit patterns.

uint 35700 = int -29836 = bin 1000101101110100)


http://www.free-test-online.com/bina...converter.html
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
M340 modbus mapping daichi LIVE PLC Questions And Answers 18 September 21st, 2017 09:41 AM
Ethernet TCP/IP and Allen-Bradley CompactLogix (RSlogix 5000) CAAJ LIVE PLC Questions And Answers 14 December 18th, 2015 12:46 PM
Programming M340 with Modbus TCP/IP Forrest LIVE PLC Questions And Answers 6 August 25th, 2011 02:57 PM
Comms issues with ModBus On Redlion cross1284 LIVE PLC Questions And Answers 5 July 1st, 2011 10:29 AM
CP341 Modbus slave WRITE tonus LIVE PLC Questions And Answers 3 May 11th, 2010 10:50 AM


All times are GMT -5. The time now is 12:45 PM.


.