Master to Master Communication

remeolbremeolb Junior MemberPosts: 79
How does master to master communication work? I have a job coming up where I will be using 2x NI-3100 and 1x NI-2100. I will be controlling devices via RS-232 connected to all three controllers. I only intend to have one source file which will reside on the NI-3100 if it's possible to do it that way.

-How do I define my masters?

-How do I define my devices?

-Will I be able to see all three masters and connected equipment in my system online tree?

Here is what I have done so far. Do I need to specify the different masters' IP addresses somewhere or is just the system number enough?
DEFINE_DEVICE

dvMASTER1		= 0:1:11	// MASTER
dvMASTER2		= 0:1:12	// MASTER 2
dvMASTER3		= 0:1:13	// MASTER 3

Comments

  • ericmedleyericmedley Senior Member - 3709 Posts Posts: 4,157
    this will be pretty down-n-dirty, so hang on.


    Firstly, set up your masters with unique system numbers. From your example set up main master as system 11, 2nd and 3rd masters as system 12 and 13 respecively. An easy way to do this is to connect a serial cable to the program port on the NI and your computer. Run Netlinx Diagnostics and set them up there. While there you might want to setup the IP addresses too. I like to keep the system numbers and IP addresses similar. Only the main master has to be a static IP for this to work, but it's a good idea to set the others to static too.

    Example might be
    Master 1 - (system 11 , IP address 192.168.1.11) This one will have the program.
    Master 2 - (system 12 , IP address 192.168.1.12)
    Master 3 - (system 13 , IP address 192.168.1.13)

    Now for making the M2M connection.

    While in Netlinx Diagnostics, you go to the URL List tab. (You don't need to do this on the main master (System 11) only the subordinate masters.

    In the URL List tab, add an URL to the list with the IP address of the main master. (In our example the IP is 192.168.1.11) If all are connected to the network it will show 'connected' in the URL window after a few seconds. After both your sub-masters are setup the connection is made.

    Important!!! do NOt make an URL reference on the main master back to the sub-masters. The connections are 2-way communication. The main master needs no connection back to the sub-masters.

    Now, to using these connected masters in code.

    Just put in a device declaration for the devices on the sub masters. You must make sure to keep the system number correct.

    So, for example, let's make a device for all the serial ports. (I assume NI-3100s for all masters)
    DEFINE_DEVICE
    
    dv_RS232_01_Sys_11  =  5001:01:11 // this is serial port 1 on the main master
    dv_RS232_01_Sys_12  =  5001:01:12 // this is serial port 1 on sub-master 1
    dv_RS232_01_Sys_13  =  5001:01:13 // this is serial port 1 on sub-master 2
    


    Now they're declared and ready for programming. If you want to monitor strings from the serial port 1 on the 2nd master here's what that looks like.

    
    DEFINE_EVENT
    
    data_event[dv_RS232_01_Sys_13]
    {
    string:
      {
      astringfrommaster3_port1_buffer=data.text
      // do something.
      }
    online:
      {
      send_command dv_RS232_01_Sys_13,' set baud 9600,etc...."
      } 
    }
    
    

    As a rule of thumb, it's a good idea to put a small program on the submasters to set stuff like this up on reboot as well.

    Hope that helps.
    e
  • remeolbremeolb Junior Member Posts: 79
    Eric,

    That was incredibly helpful. Thanks a million!!!
  • John GonzalesJohn Gonzales Junior Member Posts: 609
    That was incredibly helpful. Thanks a million!!!

    meh, it was just o.k. .


    Just kidding. Nice writeup.

    --John
  • ericmedleyericmedley Senior Member - 3709 Posts Posts: 4,157
    meh, it was just o.k. .


    Just kidding. Nice writeup.

    --John

    'meh' is my new favorite word nowadays.
  • annuelloannuello Junior Member Posts: 294
    I vote to have this thread shifted to the Tips & Tricks section. A beautifully succinct explanation of M2M.

    Roger McLean
    Swinburne University
Sign In or Register to comment.