Someone with a Siemens S7 1200 who wants to test ?

I got a connection on Slot 1.
Working in DB10 and DB13, having to stay lower than index 100, because it seems to set anything above 100 back to 100.

I can read Float
I can read Double Word
Word from DB doesn't seem to be right
Bit didn't seem to work, but does change when I write and read the same BitIndex. I think I am just confused about how to use the BitIndex.

Can't seem to write to Float
Haven't got a Double Word I can write to without upsetting a test I am running.
Writing Words is an issue.
Writing Bits seems OK, if I use the same read and write bit so that I know where it is going.

Can't help much in checking code for errors. Mashing together Advanced HMI and Libnodave was my one and only attempt at Visual Basic. Not something I ever want to repeat!!
 
Bryan

Thanks for testing my application, much appreciated !!

Word from DB, what do you get there ? do you read from a Word datatype or an integer ?

Thanks,

Kind regards,
G


I got a connection on Slot 1.
Working in DB10 and DB13, having to stay lower than index 100, because it seems to set anything above 100 back to 100.

Bitindex is a continuecount. For example, bit DB10.DBX2.6 is bit index 23, the 23th bit in te DB.



I can read Float
I can read Double Word
Word from DB doesn't seem to be right
Bit didn't seem to work, but does change when I write and read the same BitIndex. I think I am just confused about how to use the BitIndex.

Can't seem to write to Float
Haven't got a Double Word I can write to without upsetting a test I am running.
Writing Words is an issue.
Writing Bits seems OK, if I use the same read and write bit so that I know where it is going.

Can't help much in checking code for errors. Mashing together Advanced HMI and Libnodave was my one and only attempt at Visual Basic. Not something I ever want to repeat!!
 
Sorry been a bit too busy to get back to the test rig.

Don't know if this will help or hinder, but here is my libnodave read coding.

Code:
 'Reading data with libnodave
'==========================================================================================================================================

                    If PLCConnectedOK = True Then
                        Select Case PolledAddressList(i).DataArea
                            Case "I"
                                result = dc.readBytes(libnodave.daveInputs, 0, ParsedResult.Offset, ParsedResult.BytesPerElements, buf)
                            Case "Q"
                                result = dc.readBytes(libnodave.daveOutputs, 0, ParsedResult.Offset, ParsedResult.BytesPerElements, buf)
                            Case "M"
                                result = dc.readBytes(libnodave.daveFlags, 0, ParsedResult.Offset, ParsedResult.BytesPerElements, buf)
                            Case "V", "D"
                                result = dc.readBytes(libnodave.daveDB, ParsedResult.DBDataBase, ParsedResult.Offset, ParsedResult.BytesPerElements, buf)
                            Case "C"
                                If m_SiemensCommType = "PPI S7200" Then
                                    result = dc.readBytes(libnodave.daveCounter200, 0, ParsedResult.Offset, ParsedResult.BytesPerElements, buf)
                                Else
                                    result = dc.readBytes(libnodave.daveCounter, 0, ParsedResult.Offset, ParsedResult.BytesPerElements, buf)
                                End If
                            Case "T"
                                If m_SiemensCommType = "PPI S7200" Then
                                    result = dc.readBytes(libnodave.daveTimer200, 0, ParsedResult.Offset, ParsedResult.BytesPerElements, buf)
                                Else
                                    result = dc.readBytes(libnodave.daveTimer, 0, ParsedResult.Offset, ParsedResult.BytesPerElements, buf)
                                End If
                            Case Else
                                Debug.Print("PLC Read - Data type not recognised")
                        End Select

                        'Retrieve data from the buffer
                        ReDim ReturnedData(200)
                        Dim tempByte As Byte
                        Dim tempWord As Int16
                        Dim temp8bitsString As String
                        Dim temp8bitsString2 As String
                        If result = 0 Then
                            'TODO complete the data checking
                            Select Case PolledAddressList(i).FullDataType
                                Case "Unsigned Byte"
                                    If ReturnedData(0) >= 0 And ReturnedData(0) < 256 Then
                                        ReturnedData(0) = dc.getU8.ToString
                                    End If
                                Case "Signed Byte"
                                    If ReturnedData(0) >= -126 And ReturnedData(0) <= 127 Then
                                        ReturnedData(0) = dc.getS8.ToString
                                    End If
                                Case "Hex Byte"
                                    tempByte = dc.getU8
                                    ReturnedData(0) = tempByte.ToString("X")
                                Case "Unsigned Word"
                                    ReturnedData(0) = dc.getU16.ToString
                                Case "Signed Word"
                                    ReturnedData(0) = dc.getS16.ToString
                                Case "Hex Word"
                                    tempWord = dc.getU16
                                    ReturnedData(0) = tempWord.ToString("X")
                                Case "Unsigned Double Word"
                                    ReturnedData(0) = dc.getU32.ToString
                                Case "Signed Double Word"
                                    ReturnedData(0) = dc.getS32.ToString
                                Case "Float"
                                    ReturnedData(0) = dc.getFloat.ToString
                                Case "Bit"
                                    ' I converted resulting Byte to a string and then reversed the String
                                    ' I could have just converted and then got 8 - Substring position and avoided the Reverse
                                    temp8bitsString = Convert.ToString(dc.getU8, 2).PadLeft(8, "0"c)
                                    'Debug.Print(temp8bitsString)
                                    Dim arrChar() As Char = temp8bitsString.ToCharArray()
                                    Array.Reverse(arrChar)
                                    temp8bitsString2 = arrChar

                                    ReturnedData(0) = temp8bitsString2.Substring(PolledAddressList(i).BitNumber, 1)
                                    'Debug.Print(PolledAddressList(i).BitNumber, "    ", ReturnedData(0))
                                Case Else
                                    Debug.Print("Retrieve data from buffer - Full Data type not recognised")
                            End Select

                        Else
                            readWriteError = True
                        End If
 
And write.

Code:
 'Writing data with libnodave
'==========================================================================================================================================
        Dim Writeresult As Integer
        Select Case ParsedResult.DataArea
            Case "Q"
                Select Case FullDataTypeBP
                    Case "Bit"
                        Writeresult = dc.writeBits(libnodave.daveOutputs, ParsedResult.Offset, ParsedResult.BitNumber, 1, BitConverter.GetBytes(libnodave.daveSwapIed_32(CBool(dataToWrite))))
                    Case "Unsigned Byte", "Signed Byte", "Hex Byte"
                        Writeresult = dc.writeBytes(libnodave.daveOutputs, 0, ParsedResult.Offset, 1, BitConverter.GetBytes(CInt(dataToWrite)))
                    Case "Unsigned Word", "Signed Word", "Hex Word"
                        Writeresult = dc.writeBytes(libnodave.daveOutputs, 0, ParsedResult.Offset, 2, BitConverter.GetBytes(libnodave.daveSwapIed_16(CInt(dataToWrite))))
                    Case "Unsigned Double Word", "Signed Double Word"
                        Writeresult = dc.writeBytes(libnodave.daveOutputs, 0, ParsedResult.Offset, 4, BitConverter.GetBytes(libnodave.daveSwapIed_32(CInt(dataToWrite))))
                    Case Else
                        Debug.Print("WriteData Q - Case data length - Full Data type not recognised")
                End Select
            Case "M"
                Select Case FullDataTypeBP
                    Case "Bit"
                        Writeresult = dc.writeBits(libnodave.daveFlags, ParsedResult.Offset, ParsedResult.BitNumber, 1, BitConverter.GetBytes(libnodave.daveSwapIed_32(CBool(dataToWrite))))
                    Case "Unsigned Byte", "Signed Byte", "Hex Byte"
                        Writeresult = dc.writeBytes(libnodave.daveFlags, 0, ParsedResult.Offset, 1, BitConverter.GetBytes(CInt(dataToWrite)))
                    Case "Unsigned Word", "Signed Word", "Hex Word"
                        Writeresult = dc.writeBytes(libnodave.daveFlags, 0, ParsedResult.Offset, 2, BitConverter.GetBytes(libnodave.daveSwapIed_16(CInt(dataToWrite))))
                    Case "Unsigned Double Word", "Signed Double Word"
                        Writeresult = dc.writeBytes(libnodave.daveFlags, 0, ParsedResult.Offset, 4, BitConverter.GetBytes(libnodave.daveSwapIed_32(CInt(dataToWrite))))
                    Case "Float"
                        Writeresult = dc.writeBytes(libnodave.daveFlags, 0, ParsedResult.Offset, 4, BitConverter.GetBytes(libnodave.toPLCfloat(CSng(dataToWrite))))
                    Case Else
                        Debug.Print("WriteData M - Get data length - Full Data type not recognised")
                End Select
            Case "V", "D" ' V is for S7-200, D id for the rest of the PLC range that use BataBase memory
                Select Case FullDataTypeBP
                    Case "Unsigned Byte", "Signed Byte", "Hex Byte"
                        Writeresult = dc.writeBytes(libnodave.daveDB, ParsedResult.DBDataBase, ParsedResult.Offset, 1, BitConverter.GetBytes(CInt(dataToWrite)))
                    Case "Unsigned Word", "Signed Word", "Hex Word"
                        Writeresult = dc.writeBytes(libnodave.daveDB, ParsedResult.DBDataBase, ParsedResult.Offset, 2, BitConverter.GetBytes(libnodave.daveSwapIed_16(CInt(dataToWrite))))
                    Case "Unsigned Double Word", "Signed Double Word"
                        Writeresult = dc.writeBytes(libnodave.daveDB, ParsedResult.DBDataBase, ParsedResult.Offset, 4, BitConverter.GetBytes(libnodave.daveSwapIed_32(CInt(dataToWrite))))
                    Case "Float"
                        Writeresult = dc.writeBytes(libnodave.daveDB, ParsedResult.DBDataBase, ParsedResult.Offset, 4, BitConverter.GetBytes(libnodave.toPLCfloat(CSng(dataToWrite))))
                    Case Else
                        Debug.Print("WriteData V/DB- Case data length - Full Data type not recognised")
                End Select
            Case "C" ' TODO
                If m_SiemensCommType = "PPI S7200" Then
                    Writeresult = dc.writeBytes(libnodave.daveCounter200, 0, ParsedResult.Offset, ParsedResult.BytesPerElements, buf)
                Else
                    Writeresult = dc.writeBytes(libnodave.daveCounter, 0, ParsedResult.Offset, ParsedResult.BytesPerElements, buf)
                End If
            Case "T" 'TODO
                If m_SiemensCommType = "PPI S7200" Then
                    Writeresult = dc.writeBytes(libnodave.daveTimer200, 0, ParsedResult.Offset, ParsedResult.BytesPerElements, buf)
                Else
                    Writeresult = dc.writeBytes(libnodave.daveTimer, 0, ParsedResult.Offset, ParsedResult.BytesPerElements, buf)
                End If
            Case "I"
                Debug.Print("Can't write to Inputs")
            Case Else
                Debug.Print("WriteData - Data Area type not recognised")
        End Select

        Debug.Print("Return from Write = {0:d}", result)
 
Thanks

Thanks,

I will take a look at your code.

Kind regards,
G

And write.

Code:
 'Writing data with libnodave
'==========================================================================================================================================
        Dim Writeresult As Integer
        Select Case ParsedResult.DataArea
            Case "Q"
                Select Case FullDataTypeBP
                    Case "Bit"
                        Writeresult = dc.writeBits(libnodave.daveOutputs, ParsedResult.Offset, ParsedResult.BitNumber, 1, BitConverter.GetBytes(libnodave.daveSwapIed_32(CBool(dataToWrite))))
                    Case "Unsigned Byte", "Signed Byte", "Hex Byte"
                        Writeresult = dc.writeBytes(libnodave.daveOutputs, 0, ParsedResult.Offset, 1, BitConverter.GetBytes(CInt(dataToWrite)))
                    Case "Unsigned Word", "Signed Word", "Hex Word"
                        Writeresult = dc.writeBytes(libnodave.daveOutputs, 0, ParsedResult.Offset, 2, BitConverter.GetBytes(libnodave.daveSwapIed_16(CInt(dataToWrite))))
                    Case "Unsigned Double Word", "Signed Double Word"
                        Writeresult = dc.writeBytes(libnodave.daveOutputs, 0, ParsedResult.Offset, 4, BitConverter.GetBytes(libnodave.daveSwapIed_32(CInt(dataToWrite))))
                    Case Else
                        Debug.Print("WriteData Q - Case data length - Full Data type not recognised")
                End Select
            Case "M"
                Select Case FullDataTypeBP
                    Case "Bit"
                        Writeresult = dc.writeBits(libnodave.daveFlags, ParsedResult.Offset, ParsedResult.BitNumber, 1, BitConverter.GetBytes(libnodave.daveSwapIed_32(CBool(dataToWrite))))
                    Case "Unsigned Byte", "Signed Byte", "Hex Byte"
                        Writeresult = dc.writeBytes(libnodave.daveFlags, 0, ParsedResult.Offset, 1, BitConverter.GetBytes(CInt(dataToWrite)))
                    Case "Unsigned Word", "Signed Word", "Hex Word"
                        Writeresult = dc.writeBytes(libnodave.daveFlags, 0, ParsedResult.Offset, 2, BitConverter.GetBytes(libnodave.daveSwapIed_16(CInt(dataToWrite))))
                    Case "Unsigned Double Word", "Signed Double Word"
                        Writeresult = dc.writeBytes(libnodave.daveFlags, 0, ParsedResult.Offset, 4, BitConverter.GetBytes(libnodave.daveSwapIed_32(CInt(dataToWrite))))
                    Case "Float"
                        Writeresult = dc.writeBytes(libnodave.daveFlags, 0, ParsedResult.Offset, 4, BitConverter.GetBytes(libnodave.toPLCfloat(CSng(dataToWrite))))
                    Case Else
                        Debug.Print("WriteData M - Get data length - Full Data type not recognised")
                End Select
            Case "V", "D" ' V is for S7-200, D id for the rest of the PLC range that use BataBase memory
                Select Case FullDataTypeBP
                    Case "Unsigned Byte", "Signed Byte", "Hex Byte"
                        Writeresult = dc.writeBytes(libnodave.daveDB, ParsedResult.DBDataBase, ParsedResult.Offset, 1, BitConverter.GetBytes(CInt(dataToWrite)))
                    Case "Unsigned Word", "Signed Word", "Hex Word"
                        Writeresult = dc.writeBytes(libnodave.daveDB, ParsedResult.DBDataBase, ParsedResult.Offset, 2, BitConverter.GetBytes(libnodave.daveSwapIed_16(CInt(dataToWrite))))
                    Case "Unsigned Double Word", "Signed Double Word"
                        Writeresult = dc.writeBytes(libnodave.daveDB, ParsedResult.DBDataBase, ParsedResult.Offset, 4, BitConverter.GetBytes(libnodave.daveSwapIed_32(CInt(dataToWrite))))
                    Case "Float"
                        Writeresult = dc.writeBytes(libnodave.daveDB, ParsedResult.DBDataBase, ParsedResult.Offset, 4, BitConverter.GetBytes(libnodave.toPLCfloat(CSng(dataToWrite))))
                    Case Else
                        Debug.Print("WriteData V/DB- Case data length - Full Data type not recognised")
                End Select
            Case "C" ' TODO
                If m_SiemensCommType = "PPI S7200" Then
                    Writeresult = dc.writeBytes(libnodave.daveCounter200, 0, ParsedResult.Offset, ParsedResult.BytesPerElements, buf)
                Else
                    Writeresult = dc.writeBytes(libnodave.daveCounter, 0, ParsedResult.Offset, ParsedResult.BytesPerElements, buf)
                End If
            Case "T" 'TODO
                If m_SiemensCommType = "PPI S7200" Then
                    Writeresult = dc.writeBytes(libnodave.daveTimer200, 0, ParsedResult.Offset, ParsedResult.BytesPerElements, buf)
                Else
                    Writeresult = dc.writeBytes(libnodave.daveTimer, 0, ParsedResult.Offset, ParsedResult.BytesPerElements, buf)
                End If
            Case "I"
                Debug.Print("Can't write to Inputs")
            Case Else
                Debug.Print("WriteData - Data Area type not recognised")
        End Select

        Debug.Print("Return from Write = {0:d}", result)
 
i can read but i cant write.. im interesting of this kind of projects..

z09qd.png


im working on testing program tool too.. ill post tomorrow..
 
screenshot

Hey,

Can you make a screenshot of DB68 please.
Watch out with the index, index 0 = DBD0, index 1 = DBD4, idnex 2 = DBD8, index 3 = DBD12, index 4 = DBD16, index 5 = DBD20, index 6 = DBD24, index 7 =DBD28, so try to write to DB68 index 7 for DB68.DBD28 please.
Keep me updated about this please, thank you,

Thanks,

Regards,
G

i can read but i cant write.. im interesting of this kind of projects..

z09qd.png


im working on testing program tool too.. ill post tomorrow..
 
Last edited:
now works !!!

i cant write "words" or "double words" on my project.. ill post tomorrow all source.. i want monitoring temperature with a chart on real time.. maybe you can help me bro..


a5j8t5.png
 

Similar Topics

If there is anyone that would be willing to open up a Siemens S7 program for me, please shoot me a message with your email and I can email the...
Replies
2
Views
1,461
Can someone please explain to me how to use a counter in siemens S7. After reading and simulating both the up and down counters in S7, they work...
Replies
7
Views
8,050
Does anyone know of a way to detect if someone is online with the controller in ControlLogix (from logic) I'm thinking that maybe there is a CIP...
Replies
7
Views
293
Long story short lost our parameter setup for an indradrive m. I have these files saved as backups but dont know how to open them. Can someone...
Replies
12
Views
858
If a programmable controller controls the operation of a motor, what connects motor control to the PC? A) Line voltage B) I/O device C) Modem D)...
Replies
27
Views
6,960
Back
Top Bottom