Tuesday, October 2, 2012

GE Micro SNP, Master and Two Slaves Communication

Getting a GE Micro SNP to be a master to two slaves can be a little tricky. The process will be described below starting with how to make the cables. Then, the ladder logic and ComReqs for the master and the two slaves will be described in detail. The entire setup is shown below.





The figure below shows the cable diagram for connecting a master to two slaves. The only difference is the master needs to be changed to the correct PIN numbers. SD(A) is actually 12, not 9 and so on. The PIN numbers should match what the slave cables use. Be sure to label which cable end is the master and which is the slave.

 

Below is an actual photograph of the finished cables. 

Now that the cables are finished, go ahead and connect the master to the slaves and power them up. 


Open and start running Machine Edition. The next section will cover each slave and the master ladder logic that should be entered into Machine Edition.
First, download the following program onto the first Slave:

This program will allow you to see if the main program is working. When it is, it will be moving a 1 into the input table beginning at 209. 209 was chosen because 208 is divisible by 8 and 200 was used for SNPID2 (or slave 1). This will make it easier when finding the value 1 when the program is working. You can get to the table by going to Reference View Tables, Default Tables, and then open %I – Input.

The next program is the same but for SNPID3 (or slave 2). It follows the same logic as SNPID2. 305 was chosen for the same reasons that 209 was. They are stored in different locations so that you can be sure both of the slaves are communicating with the master without having to switch connections.

Note: Make sure when you are downloading the program to each slave to make it the active target in Machine Edition. This is shown below:


The ladder logic for the master is more complicated than the slaves. Each rung will be described.

This is the first scan. It begins by moving 0 into the ComReqStatusWord variable which is located at %R01018. This is in place so that the program knows a ComReq has not been completed yet. Next, 0 is moved into the ComReqState located at %R2000. This means either the program has completed all the ComReqs and is ready to start over, or that none have been completed yet. Finally, %T0001 is Set.

A timer will begin if T1 is turned on. The timer will provide a 2 second delay when the ladder is started. This allows more than enough time for the Micro to initialize upon system power up. When the startup delay is complete, one-shot %T0002 fires to load the Attach command for SNPID3 (this was just the one we set up first, it can be in any order).

T1 is set to normally closed so it will not run the first scan, but every scan after it. Next, it checks to make sure the ComReqState is set to 0 and the ComReqStatusWord is 1. This ensures the all the ComReqs have been complete and it is ready to start again at the beginning. One-shot T10 fires to load the Attach SNPID3 command. Note: Without this line, once the all the ComReqs have ran, it will be stopped because T2 is a one-shot command only on the first scan.

When T2 (first scan) or T10 are on, it will check that the ComReqState is 0. If it is true, it will then prepare the following data to be moved into the ComReq:



This rung checks to make certain the ComReqStatus is 1 (Successful) and the State is 1. If these are both true, T4 switches on to start the read command for SNPID3.


Once T4 is turned on, the Block Moves prepare the data to move into the ComReq. The ComReqState is then changed to 2 so that it will go on to Read data for SNPID2 and the ComReqStatusWord is changed back to 0. One-shot T5 fires to load the SNPID3 Read Command. The Block Move data is described below:
ATTACH COMMAND FOR SNPID 3 – This can be found on Page 118 of gfk0582d.pdf
0 - SNP Data Block Length                                                            7 - Characters 1 & 2 of Slave SNPID (0033Hex = 3 ASCII)
1 - NOWAIT Mode                                                                               8 - Characters 3 & 4
2 - Status Word Memory Type (8=%R)                                 9 - Characters 5 & 6
3 - Status Word Offset (1017 = %R1018)                            10 - Char 7 & 8
4 - Not Used                                                                                                                   11 - Master Memory Type to store Piggyback Status (8=%R)
5 - Not Used                                                                                                                   12 = Master Memory Address to store Piggyback Status (1030 = %R1031)
6 - SNP Command Number (7200 = ATTACH)                  13 = Not Used             

Once this is successful, 1 will be moved into the ComReqState so that it will be ready for the next ComReq. 0 will once again be moved into the ComReqStatusWord. T1 will be reset since the first scan is complete.

This rung will run for after each of the data has been prepared. It will move the data beginning at %R01001. T3 will only be set if there was an error in the ComReq.

This rung checks to make certain the ComReqStatus is 1 (Successful) and the State is 1. If these are both true, T4 switches on to start the read command for SNPID3.

Once T4 is turned on, the Block Moves prepare the data to move into the ComReq. The  ComReqState is then changed to 2 so that it will go on to Read data for SNPID2 and the ComReqStatusWord is changed back to 0. One-shot T5 fires to load the SNPID3 Read Command. The Block Move data is described below:
READ SYSTEM MEMORY COMMAND FOR SNP-ID 3; Can be found on Page 124 from gfk0582d.pdf
0- SNP Data Block Length                                                                               7-Slave Memory Type form which to read data (70=%I)
1-NOWAIT                                                                                                       8-Slave Memory Address form which to read data (304=%I305)
2-Status Word Memory Type (%R)                                                                  9-Number of Master Memory Type elements to read (16=%I301-%I316)
3-Status Word Address minus 1(Register 1017=R1018)                                 10-Master Memory Type to store data (70=%I)
4-Not Used                                                                                                       11-Master Address to store data (304=%I305)
5-Not Used                                                                                                       12- Not used
6-SNP Command Number (7202=Read System Memory)                              13-Not used


This rung checks to make sure the State is 2 and the Status is 1. If both are true, one-shot T7 is fired to load the Attach command for SNPID2.

This rung does the same as the Attach command for SNPID3. The only difference is the 16#0032 is 2 in Hex instead of 3 and it moves the State to 3 after it runs and the Status word back to 0.

This rung checks to make sure the State is 3 and the Status word is 1 (the ComReq Attach Command was successful). One-shot T8 then fires to load ComReqSNPID2Successful. 

This rung does the same as for SNPID3. Once it is successful, it will move 0 back into the State and 0 into the Status Word. T6 will fire to load RunReadSNPID2. This is the last ComReq so moving the State back to 0 will allow the first ComReq, Attach SNPID3, to begin again. 

The rungs above work together. Their purpose is to time how long it takes for data to be sent. The timer is set to always on, but it begins counting when the Read command is sent to SNPID2. The top rung makes more sense to come after the last one, but it has to be before or it will always show 0 because it will record the time after the timer has been reset. The time is stored in %R0004.

No comments:

Post a Comment