Saturday, November 22, 2014

Now You Can Have Robust Data Logging for Free - Part 7

Now You Can Have Robust Data Logging for Free - Part 1
Now You Can Have Robust Data Logging for Free - Part 2
Now You Can Have Robust Data Logging for Free - Part 3
Now You Can Have Robust Data Logging for Free - Part 4
Now You Can Have Robust Data Logging for Free - Part 5
Now You Can Have Robust Data Logging for Free - Part 6
Now You Can Have Robust Data Logging for Free - Part 7


Computer Program Visual Basic (VB6) Continue

We have started our VB program and have set up our Adodc connections to the database. Lets continue by setting the labels up with the Adodc connections. Then we will set up the communications to the Do-More PLC and put information into our Access 2007 (*.accdb) database. (AccRL.accdb)

Select all of the labels that will be for the Production_Log table and set the properties. Under DataSource select Adodc1. Do the same thing for all the labels under the Minute_Log table.

Now go through each of the labels and select the DataField that it represents. Do this for both the Production_Log table and the Minute_Log table.
Note: You can also set the format in which the field will display

We now have our basic display set up in visual basic. The last thing that we will do is add a text box and command buttons to control the logging of the information.
A text box is added to enter the IP Address of the PLC. 
A Command1 command button is added to start the logging of the information.
A Command2 command button is added to stop the logging of the information.

We now have everything on the dispay that we will need for the program. 

Lets now take a look at the modbus protocol.
http://www.simplymodbus.ca/TCP.htm

All Modbus Commands:
Function CodeActionTable Name
01 (01 hex)ReadDiscrete Output Coils
05 (05 hex)Write singleDiscrete Output Coil
15 (0F hex)Write multipleDiscrete Output Coils
02 (02 hex)ReadDiscrete Input Contacts
04 (04 hex)ReadAnalog Input Registers
03 (03 hex)ReadAnalog Output Holding Registers
06 (06 hex)Write singleAnalog Output Holding Register
16 (10 hex)Write multipleAnalog Output Holding Registers
Due to Homeland Security the automation direct Do-More PLC will allow only the MHR area of memory to be written and read. Since this controller resides on a network and can be connected to the internet, this makes perfect sense. So the only function codes that we will be using will be 03 Read and 16 Write.
A review of the numbering systems can be found on a previous blog here.
Here is what we have to send to the PLC. (In this example we will read registers.)
00 - Transaction ID
00 - Protocol ID
06 - Length of message words
0 - Unit ID (Default)
3 - Function Code (Read) 10hex - Write
10 - Data bits (In this case the number of registers to read)

We will receive what we sent out plus the data requested.

Note: The rest of the network protocol will be handled by TCP/IP. All of the error checking is also handled by the network.


In part 8 we will continue with writing the VB6 program. We will start to put everything together in the program using code.
If you have any questions or need further information, please contact me.
Regards,
Garry

No comments:

Post a Comment