S7 and MM440 over profibus help please

dijk777

Member
Join Date
Jun 2005
Posts
11
Hi All,

I thought I knew S7 somewhat but have been struggling for the past 2 days to get my MM440 working on an S7. I have downloaded all the Siemens samples from the Siemens website but they don't seem to do what I want. My PLC goes into stop, can't warm start it, etc. Profibus is 'happy', bust still am getting BF led. At one stage I thought it worked. After cycling power the PLC went into stop.


So... I'd like to ask the experts for some help. Does anyone have a S7 program that I could use as my foundation for building my program on. The PlC is an S7-315F 2DP. I'd love to have an Ob1 with a FC/FB that just has start/stop, speed reference and returns current, faults, drive on, etc. in it. Nothing fancy, less is more.

If you know where to find such a solution, please send me the link.


Many thanks in advance, Siebe, Australia
ps: I'd love to send you a nice bottle of Red for a working solution.
 
I dont have a simple example.
My projects are based on Siemens sample projects with all the bells and whistles.

If you PLC goes into stop and you get BF and like that, then I would hunt the causes for this. You do know how to investigate the hardware diagnostics, and the CPU diagnostics buffer, right ?
If there is something wrong with the basic hardware configuration, then a simple program will also not work.

Also, try to tell more about your project, especially detail EVERYTHING that is on Profibus.
 
This block will do what you need.

I'm assuming you already know how add it to your program by pasting the text into a STL source and compiling.


Code:
FUNCTION FC 218 : VOID
TITLE =MM4 control on Profibus
//: Simplified PPO3
AUTHOR : KH
FAMILY : MOTION
NAME : MM4_PPO3
VERSION : 2.0
 
VAR_INPUT
Drive_IO_Address : INT ; //Hardware configured I/O area address
Setpoint_Percent : REAL ; //Speed reference as a percentage (of P2000 Hz)
Run_CW : BOOL ; //Run drive CW
Run_CCW : BOOL ; //Run drive CCW
Reset : BOOL ; //Reset fault
END_VAR
VAR_OUTPUT
Running : BOOL ; //Drive is running
Fault : BOOL ; //Drive fault active
END_VAR
VAR_TEMP
Drive_IO_Pointer : DWORD ; //Drive IO address converted to pointer
Drive_Q_Request : DWORD ; //Intermediate output for TX to drive
Drive_I_Received : DWORD ; //Intermediate input as RX from drive
END_VAR
BEGIN
NETWORK
TITLE =
//- If motor faults then a rising edge of the 'Run' input will be required to
// restart the drive after the fault has been reset. 
//- After run command is removed, the 'Drive_Running' output will stay on until
// the motor has stopped (end of ramp down)
	 NOP 0; 
//Convert IO address to pointer
	 L	 #Drive_IO_Address; 
	 SLD 3; 
	 T	 #Drive_IO_Pointer; 
//Load base command mask to drive control words
	 L	 DW#16#47E0000; 
	 T	 #Drive_Q_Request; 
//Send run CW command to drive
//Set control word 1 (STW), bit 0
	 A	 #Run_CW; 
	 JCN L001; 
	 L	 #Drive_Q_Request; 
	 L	 DW#16#10000; 
	 OD	; 
	 T	 #Drive_Q_Request; 
//Send run CCW command to drive
//Set control word 1 (STW), bit 0
//Set control word 1 (STW), bit 11
L001: A	 #Run_CCW; 
	 JCN L005; 
	 L	 #Drive_Q_Request; 
	 L	 DW#16#8010000; 
	 OD	; 
	 T	 #Drive_Q_Request; 
L005: NOP 0; 
//Send reset command to drive
//Set control word 1 (STW), bit 7
	 A	 #Reset; 
	 JCN L002; 
	 L	 #Drive_Q_Request; 
	 L	 DW#16#800000; 
	 OD	; 
	 T	 #Drive_Q_Request; 
L002: NOP 0; 
//Check 'Setpoint_Percent' parameter input is within range, if not then impose limit 
	 L	 #Setpoint_Percent; 
	 L	 0.000000e+000; 
	 >=R ; 
	 JC	CHK2; 
	 T	 #Setpoint_Percent; 
CHK2: TAK ; 
	 L	 1.000000e+002; 
	 <=R ; 
	 JC	L003; 
	 T	 #Setpoint_Percent; 
L003: NOP 0; 
//Scale setpoint to input range 0 - 16384 
	 L	 #Setpoint_Percent; 
	 L	 1.638400e+002; 
	 *R	; 
	 RND ; 
	 L	 #Drive_Q_Request; 
	 OD	; 
	 T	 #Drive_Q_Request; 
//Send requested commands to drive
	 L	 #Drive_Q_Request; 
	 T	 PQD [#Drive_IO_Pointer]; 
//Load intermediate register with data from drive
	 L	 PID [#Drive_IO_Pointer]; 
	 T	 #Drive_I_Received; 
//Ensure block starts with outputs off 
	 CLR ; 
	 =	 #Running; 
	 =	 #Fault; 
//Get running status from drive 
//Read status word 1 (ZSW), bit 2
	 L	 #Drive_I_Received; 
	 L	 DW#16#40000; 
	 AD	; 
	 L	 0; 
	 >D	; 
	 JCN L004; 
	 SET ; 
	 =	 #Running; 
//Get fault status from drive 
//Read status word 1 (ZSW), bit 3
L004: L	 #Drive_I_Received; 
	 L	 DW#16#80000; 
	 AD	; 
	 L	 0; 
	 >D	; 
	 JCN END; 
	 SET ; 
	 =	 #Fault; 
//Set ENO & exit
END: SET ; 
	 SAVE ; 
 
END_FUNCTION

For the MM440 setup:

- Set up the PROFIBUS node no. on either the DIP switch or P0918
- Set P0700 = 6
- Set P1000 = 6
- Ensure P0719 = 0
- Set P2041.00 = 3 (PPO3 selected)

..
 
Last edited:
Mm440

The MM440 FC:

Code:
 TYPE "MM440_PZD"
VERSION : 0.1

  STRUCT  
   CW_Inch : BOOL ; 
   CCW_Inch : BOOL ; 
   SETP_Valid : BOOL ; 
   SETP_Inv : BOOL ; 
   not_used : BOOL ; 
   MOP_UP : BOOL ; 
   MOP_DOWN : BOOL ; 
   Local_Remote : BOOL ; 
   On_Off_1 : BOOL ; 
   Off_2 : BOOL ; 
   Off_3 : BOOL ; 
   Enable_Oper : BOOL ; 
   Oper_Condition : BOOL ; 
   Enable_RFG : BOOL ; 
   Enable_Setp : BOOL ; 
   Ack : BOOL ; 
   No_SETP : BOOL ; 
   Master_CTRL : BOOL ; 
   f_Reached : BOOL ; 
   Current_Limit : BOOL ; 
   Holding_Brake : BOOL ; 
   Overload_ACM : BOOL ; 
   CW_CCW : BOOL ; 
   Overload_MM4 : BOOL ; 
   Ready_On : BOOL ; 
   Ready_Run : BOOL ; 
   Oper_Enabled : BOOL ; 
   Fault : BOOL ; 
   Off2 : BOOL ; 
   Off3 : BOOL ; 
   Starting_Lockout : BOOL ; 
   Alarm : BOOL ; 
  END_STRUCT ; 
END_TYPE

FUNCTION "MM440" : VOID
TITLE =MM440
VERSION : 0.1


VAR_INPUT
  SETP_Hz : REAL ; 
  FW_RUN : BOOL ; 
  RV_RUN : BOOL ; 
  RST : BOOL ; 
  STAT_WORD : WORD ; 
  ACTUAL_VAL : INT ; 
END_VAR
VAR_OUTPUT
  FLT : BOOL ; 
  CTRL_W : WORD ; 
  SETP_Int : INT ; 
END_VAR
VAR_TEMP
  PZD : "MM440_PZD"; 
  CTRLWORD : WORD ; 
END_VAR
BEGIN
NETWORK
TITLE =STAT_WORD 

	  LAR1  P##PZD; 
	  L	 #STAT_WORD; 
	  T	 LW [AR1,P#2.0]; 
NETWORK
TITLE =PREBITS

	  L	 0; 
	  T	 LW [AR1,P#0.0]; 

	  SET   ; 
	  =	 #PZD.Off_2; 
	  =	 #PZD.Off_3; 
	  =	 #PZD.Enable_Oper; 
	  =	 #PZD.Oper_Condition; 
	  =	 #PZD.Enable_RFG; 
	  =	 #PZD.Enable_Setp; 
	  =	 #PZD.SETP_Valid; 


NETWORK
TITLE =FW_RUN

	  A	 #FW_RUN; 
	  X	 #RV_RUN; 
	  =	 #PZD.On_Off_1; 
NETWORK
TITLE =RV_RUN

	  A	 #RV_RUN; 
	  =	 #PZD.SETP_Inv; 
NETWORK
TITLE =RST

	  A	 #PZD.Fault; 
	  =	 #FLT; 
	  A	 #RST; 
	  =	 #PZD.Ack; 
NETWORK
TITLE =CTRL_WORD

	  LAR1  P##PZD; 
	  L	 LW [AR1,P#0.0]; 
	  T	 #CTRL_W; 
NETWORK
TITLE =SETP

	  L	 #SETP_Hz; 
	  L	 5.529600e+002; 
	  *R	; 
	  RND   ; 
	  T	 #SETP_Int; 
END_FUNCTION

OB1:

Code:
ORGANIZATION_BLOCK "CYCL_EXC"
TITLE = "Main Program Sweep (Cycle)"
VERSION : 0.1


VAR_TEMP
  OB1_EV_CLASS : BYTE ; //Bits 0-3 = 1 (Coming event), Bits 4-7 = 1 (Event class 1)
  OB1_SCAN_1 : BYTE ; //1 (Cold restart scan 1 of OB 1), 3 (Scan 2-n of OB 1)
  OB1_PRIORITY : BYTE ; //Priority of OB Execution
  OB1_OB_NUMBR : BYTE ; //1 (Organization block 1, OB1)
  OB1_RESERVED_1 : BYTE ; //Reserved for system
  OB1_RESERVED_2 : BYTE ; //Reserved for system
  OB1_PREV_CYCLE : INT ; //Cycle time of previous OB1 scan (milliseconds)
  OB1_MIN_CYCLE : INT ; //Minimum cycle time of OB1 (milliseconds)
  OB1_MAX_CYCLE : INT ; //Maximum cycle time of OB1 (milliseconds)
  OB1_DATE_TIME : DATE_AND_TIME ; //Date and time OB1 started
END_VAR
BEGIN
NETWORK
TITLE =MM440


	  CALL "MM440" (
		   SETP_Hz				  := MD	50,
		   FW_RUN				   := I	  0.0,
		   RV_RUN				   := I	  0.1,
		   RST					  := I	  0.2,
		   STAT_WORD				:= PIW  256,
		   ACTUAL_VAL			   := PIW  258,
		   FLT					  := M	100.0,
		   CTRL_W				   := PQW  256,
		   SETP_Int				 := PQW  258);

END_ORGANIZATION_BLOCK

[/code]
 
BTW: to test a drive:

Make a VAT.

To start: send W#16#47F
To stop: send W#16#47E

Never send 0 (zero), the drive will go in F0070 (profibus fault).

When started, send W#16#4000 to the setpoint and the drive will run at reference speed (default that's 50Hz).
 
When passing in integer values for the address of a drive on profibus, I use the following method to extract the integer address from the peripheral address. The advantage is the peripheral address will appear in the cross-reference and you can track down where the address is being used. If you simply pass an integer in, then the cross ref will not help.

pp03.JPG



Code for FC1 as follows:

Code:
FUNCTION FC 1 : INT
TITLE =
VERSION : 0.1

VAR_INPUT
  pPI : POINTER ; 
END_VAR
BEGIN
NETWORK
TITLE =return integer address of Peripheral variable
	  L	 P##pPI; 
	  LAR1  ; 
	  L	 D [AR1,P#2.0]; 
	  SRD   3; 
	  T	 #RET_VAL; 
	  SET   ; 
	  SAVE  ; 
END_FUNCTION
 
[QUOTE='L D[AR2,P#0.0]The advantage is the peripheral address will appear in the cross-reference and you can track down where the address is being used. If you simply pass an integer in, then the cross ref will not help.[/QUOTE]

Good point Simon... I'm gonna steal your method :)


[QUOTE='Combo]
BTW: to test a drive:

Make a VAT.

To start: send W#16#47F
To stop: send W#16#47E
[/QUOTE]

The first time I used a PROFIBUS MM was on a Siemens course some (ahem) years ago and this was how the control was demonstrated. The block I posted originated from these course notes and kind of 'grew organically' over the years.

Masking isn't the most transparent technique to use when reading/writing bits and I've always intended to go back and rewrite this using structures for bit access, more along the lines of Combo's offering.

I'm absolutely, definitely going to do it - tomorrow.
 
Thanks for the quick reply. I will try tommorow. This is going to be my approach:
- reset PLC (hold switch down, release, push down again), this ensures a 'clean start', does the PLC go in stop after this?
- go in HW config, add PLC, add dp network, add 4 MM420 drives (not used for now, but connected on the network & have 24vdc) and 1 MM440 drive (the one I need to get working asap). addres: 4,5,6,7 & 8 set on PB card. Set drives for PP03?
- compile & save, upload to PLC. swith plc in run mode. check if all green PB LEDs are blinking. Should plc stay in run here? I have seen F0070 on the not used 420 drives? Should I build the network without the 420s?
- create OB1 and one of the FCs that are suggested here. upload to PLC and done? What about SFC14 & 15?
- check drive for correct settings (I have Starter on 1 PC to check the drive & S7 on MPI on the 2nd laptop).

If not successfull I will report back with the S7 files zipped.

many thanks, Siebe
 
I really really recommend using Siemens framework for controlling MM4 drives.
You get for free some advantage that you would be hardpressed to achieve by yourself. If you get the lastest version, you now have the parameters and error messages in english language (before was only german).
Using this framework shall not in itself cause CPU STOP or BF, so you are "dummying down" the program and HMI for the wrong reasons.

And I find it distressing to watch someone not even trying to find the real root of the error.
 
Yes - PPO3 if you use the block I posted.

You don't need SFC14 & 15 for this as you get data consistency with L & T over the 4 bytes required.

*edit*
...but listen to Jesper - he does make valid points especially if you also happen to be using a Siemens HMI.


..
 
Last edited:
From a PM:
dihk777 said:
Hi Jesper,
what is Siemens Framework?
thx, Siebe
I mean the sample project with both S7 and HMI programs.
I thought that you were using this already. I used the term "Framework" in the general meaning of the word.
I shall see if I can locate the last version of the sample project.
 
Helo dijk777;

What about SFC14 & 15
If you are using PP03, you do not need to use SFC14/15; these are used for consistent data transfer of more than 4 bytes, and required only in the case you need to read/write to the drive parameters.
Look at the following illustration, showing all 5 PPOx telegramm structures:
PPOx_Typ.jpg


PPO3 and PPO4 only use the Process Data section of the Profibus telegram, each value is accessible word by word from the PLC register that is attributed to it. I mean you can write directly to the Control word, or the Speed reference word, using the PQWxxx address prvided by the Profibus configurator; reading the corresponding value simply means accessing the corresponding PIWxxx address. The programming examples above show this.

When you want to read or modify a parameter value, though, you need to use PPO1, PPO2 or PPO5, and send all 4 words of the Parameter Identification side of the telegram as one unit (consistent data). So you need SFC14/15 to do this, as Profibus can only handle up to 4 bytes at a time (DINT or REAL value) in non-consistent data.

If you need more detailed information on Profibus-DP communications with a MM4 drive, have a look at the following manuals:
http://support.automation.siemens.com/WW/view/en/6586565

Hope this helps,
Daniel Chartier
 
If you are ONLY USING MM440 (not 420's) use PPO4. It will let you read and write 4 words each way above the usual Control Word & Speed. Makes for easy code and no read and writes.


Nick
 

Similar Topics

Hi, I'm using PPO1 to communicate with MM440. I only need to read and modify MM440 parameters, so i sucssesfully use PKW mechanism. I don't have...
Replies
1
Views
1,304
The software i am using is STEP7 and the hardware is C7-635 Touch screen and a MM440 drive.Can anyone help me on how to send data to the drive to...
Replies
1
Views
1,802
Hi, I have 2 inputs in the PLC for decrease and increase the motorspeed. The drive MM440 is connected on profibus to a s7-315-2DP master...
Replies
4
Views
3,554
How would u start, invert direction and reset fault, do u use the Drive ES Blocks for simple projects, or do u just write something yourself ...
Replies
10
Views
4,330
Hi I have some communication issues regarding a PLC and a couple of Drives. They are communicating on a Profibus network. The PLC is a...
Replies
14
Views
12,107
Back
Top Bottom