patchGNU Octave - Patches: patch #8263, [octave forge]...

 
 

patch #8263: [octave forge] (instrument-control) add modbus capabilities

Submitter:  Pantxo Diribarne <pantxo>
Submitted:  Wed 18 Dec 2013 06:33:11 PM UTC
   
 
Category:  Forge : new function Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  lostbard Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 11 Jul 2023 04:55:48 PM UTC, comment #3: 

I'm going to close this since instrument control has matlab compatible modbus support now


John Donoghue <lostbard>
Group Member
Sun 12 Jan 2014 10:52:28 AM UTC, comment #2: 

Hi Stephan,

Modbus is intrinsically low-level. You can think of it as four tables :
 - two register (16 bits) tables, one (input_registers) is read only
 - two bits/coils tables, one (input_bits) is read only

There are thus four kinds of read operations and two kinds of write operations.

To access data you have to specify the address of the concerned bit/register. This prevents to mimic directly the interface of set/get or fread/fwrite as you propose.

I can think of something like:


a = modbus('192.168.1.1','tcp');
%Specify the adresses of bits/registers of interest
set (a, 'bits', 1:4)
set (a, 'inputbits', 32:45)
ibits = read (a, 'inputbits');
bits = read (a, 'bits');
count = write (a, 'bits', [1 0 0 1]);


Practically, you often want to retrieve/write floats, which are made of two (not necessarily consecutive) registers. This part is done using bitget/bitpack functions in octave. For this part of the job I can think of a something like:


a = modbus('192.168.1.1','tcp');
%Specify the adresses through vector -> no conversion
set (a, 'registers', 1:4)
regs = read (a, 'registers'); % here I get a vector of 4 uint16
%Specify the adresses through n-by-2 matrix -> conversion to floats
set (a, 'registers', [1 2; 3 4])
regs = read (a, 'registers'); % here I get a vector of 2 floats, composed resp. of registers 1-2 and 3-4.
count = write (a, 'registers', [4.2; 2.8]) %each double is cast into a float and then decomposed into 2 bytes written resp. in 1-2 and 3-4 registers


Pantxo

Pantxo Diribarne <pantxo>
Group Member
Sat 11 Jan 2014 07:35:21 PM UTC, comment #1: 

Just looked to the code. It's a very low level interface to libmodbus. I would prefer a more high level interface, similar to the existing interfaces with own data type.

For example:

a = modbus('192.168.1.1','tcp'); % to create a new type, using tcp in this case
fopen(a);  % allocate resource and connect (modbus_new_tcp, modbus_connect)

fflush(a); % (modbus_flush)

fprintf/fwrite(a,bits); % read/write bits
fread(a,bits);

get(a,'registers');              % reading/writing registers
set(a,'registers',registerset);

fclose(a); % close modbus (modbus_close, modbus_free)

clear(a); % clears variable from memory (and closes it if not done with fclose)


I've never worked with modbus yet, so what's your opinion? Does it make sense?

Stefan Mahr <dac922>
Wed 18 Dec 2013 06:33:11 PM UTC, original submission:  

Attached is an embryonic support for modbus protocol that could be added to the instrument control package. A few details:
 - Depends on libmodbus
 - only a subset of the client functions is implemented
 - included tests are roughly translations (from c to m file) of the tests in libmodbus source. They rely on a an external modbus servers which compiled from a copy of test servers in libmodbus source.

To test one must install libmodbus, cd into the attached directory, "make" and "make check"

Pantxo Diribarne <pantxo>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #30039:  octave-modbus.tar.gz added by pantxo (20KiB - application/x-gzip)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by lostbard (Posted a comment)
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by dac922 (Posted a comment)
  • -email is unavailable- added by dac922
  • -email is unavailable- added by pantxo (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-07-11 lostbard StatusNone Done
        Assigned toNone lostbard
        Open/ClosedOpen Closed
    2018-04-10 mtmiller SummaryInstrument control package: add modbus capabilities [octave forge] (instrument-control) add modbus capabilities
    2018-04-10 mtmiller CategoryNone Forge : new function
    2013-12-19 dac922 Carbon-Copy- Added dac922
    2013-12-18 pantxo Attached File- Added octave-modbus.tar.gz, #30039

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code