Siemens#Using SINA_SPEED to control G120

In this tutorial I will explain how to control a Siemens drive.In the Last post,we used a software that was provided by Siemens that called “Starter” – directly control the drive from this commissioning tool.

This is very important for this step – you can check if there are any problems on the hardware side and split the commissioning tasks in small pieces.

After you can control the drive from the Commissioning tool directly, we can use User Program to control your drive.

Reference Link

Siemens#Commissioning the Drive with Starter
In this Tutorial I will show you how to use Starter software - A Driv...

SINA_SPEED and Telegram1

What is Telegram? Siemens’s Telegram is a “format” to communicate in the Profidrive Protocol.There are so many Telegrams but not Telegram1:

  • Telegram1
  • Telegram111
  • Telegram30(for profisafe)
  • Free Telegram(User defined)

Telegram111 can be used in the Sinamics Basic Position features, Telegram1 can be used in the simple speed control.It is dependent on your applications.

Thanks to Siemens for providing some libraries for these functions.

  • SINA_SPEED for speed control
  • SINA_POS for positioning
  • SINA_PARA to get/set the parameters inside the drives.

Library Installation

Please download the library with your TIA Version.

https://support.industry.siemens.com/cs/document/109475044/sinamics-communication-blocks-drivelib-for-reading-and-writing-drive-data-within-tia-portal-context?dti=0&lc=en-WW

image.png

After unzip, DriveLib.msi is found.

Double click to install it.

image.png

After the installation,open your TIA and go to Library>Drive_Lib_S7_1200_1500>Master copies>03_SINAMICS>SINA_SPEED, drop it into your project.

image.png

Hardware Configuration

Now we can create the hardware configuration. G120 and Telegram1 are used in this tutorial.

TIA

Insert G120 into your Project.

image.png

Click the “Not assigned” to assign your drive into the profinet network.

image.png

Enter the IP and Device name of G120.

image.png
Drop the Telegram1 into your drive.

image.png


Starter

Open the Starter Software and go to the Field bus object.

image.png

1.Select the Field bus protocol:Profinet is our selection.

2.Send/receive data that you are configuring.(View from the Drive)

3.Choose Compatibility Mode.

4.Telegram Configuration.Telegram 1 is used in this tutorial.

5.Configuration of your Telegram.

image.png

Telegram 1

Here is the basic structure of Telegram1.

image.png

STW1

image.png


ZSW1

image.png

Read more

we can click the “STW1” box to view the telegram configuration.

in the online mode, the current signal is shown in this popup also.

image.png

NSOLL_A is connected to p1070[0]. Click the blue box>Further interconnections to see the detail.

image.pngl

P1070[0] is the speed setpoint.

image.png

Reference to the Manaul:

image.png

Let’s see the data that transfer from Drive to PLC.

1.Choose the transmit direction tab.

2.Click ZSW1

image.png

ZSW1 is connected to r2053[0].

r=read only

w=read or write

It means that the data from r2089 is directly transferred to r2053[0]. 

image.pngIf you want to know more about this r2089, Click the Expert list.

image.png

Enter 2089 in the Parameter field.

image.png

Finally.NIST_A is connected to r63[0]. It is a word format, PZD2.

image.png


r2089 can be viewed in the expert list also.

image.png


The status can be viewed also by Diagnostics>Interconnections.

image.png

All status can be viewed here.

image.png

Program

Here is the program structure of SINA_SPEED.

DPWR_DAT and DPRD_DAT are called inside to implement the profinet communication.

Because It is a function block, Instance DB is necessary.

image.png

SINA_SPEED

This is the Function Block of SINA_SPEED, i will explain all the in/out parameters.

image.png

Input

  • EnableAxis(Bool)
    • Start/Stop the Drive(Assigned to Control Word Bit0)
  • AckError(Bool)
    • Rest the Drive Error(Assigned to Control Word Bit7)
  • SpeedSp(Real)
    • Speed Setpoint(1/min)
  • RefSpeed(Real)
    • The reference speed of the motor(must be matched to p2000)
  • ConfigAxis(Word)
    • Configure the Control word(p2090)
      • Bit1:OFF2
      • Bit2:OFF3
      • Bit3:Enable Operation
      • Bit4:Enable Ramp-Function Generator
      • Bit5:Continue Ramp up Function Generator
      • Bit6:Enable Speed Setpoint
  • HWIDSTW
    • The hardware ID of your Drive
  • HWIDZTW
    • The hardware ID of your Drive


Output

  • AxisEnabled(Bool)
    • Drive is Enabled or not
  • Lockout(Bool)
    • Drive is Lock or not
  • ActVelocity(Real)
    • Actual Velocity
  • Error(Bool)
    • Drive is error or not
  • Status(Word)
    • 16#7002=Normla
    • 16#8401=Drive is error
    • 16#8402=Drive had problem
    • 16#8600=Error in DPRD_DAR
    • 16#8601=Error in DPWR_DAT
  • Diagld(Word)
    • The status of communication error


Implementation

Now we will create some sample programs.

Let’s Create a function Block that is named G120.
image.png

Call it in OB1.

image.png


Interface

image.png

NTW1:Drive Reset
image.png
NTW2:Drive Enable

A reset operation is needed to re-enable your drive while an error is occurring.

image.png
NTW3:Ref Speed
image.png
NTW4:Write the Speed setpoint 

If the enable signal is off or the run command is off, 0 is always output.

image.png
NTW5:Transfer the HWID
image.png
NTW6:Call the SINA_SPEED
image.png
NTW7:Drive is Enabled or not
image.png
NTW8:Drive had problem or not
image.png
NTW9:Current speed
image.png
NTW10:Flag for Drive Error
image.png

NTW11:Output the Error Status
image.png
NTW12:Get the Error status while communication fault
image.png
NTW13:The Error Flag reset operation
image.png

How to check the HWIO?

Open the Deview view and click the G120 Drives.

The HWIO is shown in System constants>XXXX_Standard_Telegram_1XX.

image.png

Bouns1- Inside SINA_SPEED

SINA_SPEED is implemented in SCL Language or  splitted to 4 parts.(In my view)

  • Part1:Line20-26
    • the code to Assign the ConfigAxis,EnableAxis,AckError input parameters to STW.
  • Part2:Line38-55
    • the code to Assign the speed setting
  • Part3
    • The code to send the data by profinet.
  • Par4
    • Error operation,get data from Drive
image.png

Part1

EnaleAxis,Ackerror is Assigned to Stw1.%X0 and STW1.%X7.

STW1.%X10 is the bit for the PLC Control Request.

We implemented the control by PLC, sure this device should be true.

image.png

Here is the map from %X0 to %X15.

image.png

If 16#07 is written into the 16bit word..

16#07=1+2+4, %X0,%X1 and %X1 is True.

image.png
image.png

And Also, If we Write the %X0,%X1 and %X2 to Ture, the 16bit word ‘value is 16#07.

image.png
image.png

The value of Config input parameter is 16#3F.

It means that from %X0 to %X5 are true.

image.png

Part2:Speed setting

  • Line39 
    • used to check if the RefSpeed is 0 or not because we can not divide 0 in any program language.
  • Line40
    • 16384 =4000Hex , we can check p1070 in the starter and Manual, Max=4000hex=16384
      A Scaling is implemented in here.If RefSpeed is 2500, and your speed setpoint is 1300,
      The Value that output to the Drive is:
      SpeedSp*(16384.0/RefSpeed)=1300x(16384/2500)=8519.
  • Line42-48
    • Check if the speed setpoint is inside the range or not.
  • Line49
    • Change the data type to word and move to buffer.
  • Line51-52
    • If Refspeed parameter is <=0, write 0 to the speed setpoint
  • Line54-55
    • Move the STW1 and Speed setpoint to the transfer buffer.
image.png
image.png
image.png

Part3 – Profinet Data Transfer

The code to Exchange the Profinet Data, reference from HWID.

image.png

Part4-Data get from Profinet

I will split 4 parts to explain it.

image.png

Part1

Check the result of profinet data exchange function is 0 or not,

0=Normal.

image.png

Part2

If there is no error from piRetSFC, the program will execute the DPRD_DAT function to get the data from drive by profinet, and change the data type from Word to int, transfer to Diagld.

image.png

Part3

All receive buffer force to 0 if DPRD_DAT had error.

image.png

The data that receive from DPRD_DAT Function are transferred to sxRecvBuff.

ZSW1 is the index 0 of the word,

Velocity is the index 1 of the word.

image.png

Line155-161 is the code to check if the RefSpeed is 0 or not.

And Scale back the data to current speed.

image.png

Actual Speed is forced to 0 iF Refspeed is 0.

image.png

Line 162-168 is the error operation.

Bouns2-Brake

Go to DriveUnit>Control_Unit>Functions>Brake control.

image.png

Select the Motor holding brake to 1.(holding brake acc. To sequence control)

p1215 will be 

image.png

Here is the time chart.

image.png

Change the Brake setting in here also.

image.png

Reference Link

https://support.industry.siemens.com/cs/document/109485727/sinamics-g-controlling-a-speed-axis-with-the-%E2%80%9Csina_speed%E2%80%9D-block?lc=en-WW&dti=0

https://support.industry.siemens.com/cs/document/109475044/sinamics-communication-blocks-drivelib-for-reading-and-writing-drive-data-within-tia-portal-context?lc=en-WW&dti=0

Footer_Basic

Please Support some devices for my blog

Amazon Gift List

Find ME

Twitter:@3threes2
Email:soup01threes*gmail.com (* to @)
YoutubeChannel:https://www.youtube.com/channel/UCQ3CHGAIXZAbeOC_9mjQiWQ

シェアする

  • このエントリーをはてなブックマークに追加

フォローする

コメント

  1. yücel uzun says:

    Hello sir
    I like your discussions, could you send me sina_speed scl codes please.