Sunteți pe pagina 1din 13

Application example 08/2016

SIMATIC IOT2000 with DC


Motor Shield
SIMATIC IOT2020, SIMATIC IOT2040

Warranty and liability

Warranty and liability


Note

The Application Examples are not binding and do not claim to be complete
regarding the circuits shown, equipping and any eventuality. The Application
Examples do not represent customer-specific solutions. They are only intended
to provide support for typical applications. You are responsible for ensuring that
the described products are used correctly. These Application Examples do not
relieve you of the responsibility to use safe practices in application, installation,
operation and maintenance. When using these Application Examples, you
recognize that we cannot be made liable for any damage/claims beyond the
liability clause described. We reserve the right to make changes to these
Application Examples at any time without prior notice.
If there are any deviations between the recommendations provided in these
Application Examples and other Siemens publications e.g. Catalogs the
contents of the other documents have priority.

Siemens AG 2016 All rights reserved

We do not accept any liability for the information contained in this document.
Any claims against us based on whatever legal reason resulting from the use of
the examples, information, programs, engineering and performance data etc.,
described in this Application Example shall be excluded. Such an exclusion shall
not apply in the case of mandatory liability, e.g. under the German Product Liability
Act (Produkthaftungsgesetz), in case of intent, gross negligence, or injury of life,
body or health, guarantee for the quality of a product, fraudulent concealment of a
deficiency or breach of a condition which goes to the root of the contract
(wesentliche Vertragspflichten). The damages for a breach of a substantial
contractual obligation are, however, limited to the foreseeable damage, typical for
the type of contract, except in the event of intent or gross negligence or injury to
life, body or health. The above provisions do not imply a change of the burden of
proof to your detriment.
Any form of duplication or distribution of these Application Examples or excerpts
hereof is prohibited without the expressed consent of the Siemens AG.
Security
information

Siemens provides products and solutions with industrial security functions that
support the secure operation of plants, systems, machines and networks.
In order to protect plants, systems, machines and networks against cyber
threats, it is necessary to implement and continuously maintain a holistic,
state-of-the-art industrial security concept. Siemens products and solutions only
form one element of such a concept.
Customer is responsible to prevent unauthorized access to its plants, systems,
machines and networks. Systems, machines and components should only be
connected to the enterprise network or the internet if and to the extent necessary
and with appropriate security measures (e.g. use of firewalls and network
segmentation) in place.
Additionally, Siemens guidance on appropriate security measures should be
taken into account. For more information about industrial security, please visit
http://www.siemens.com/industrialsecurity.
Siemens products and solutions undergo continuous development to make them
more secure. Siemens strongly recommends to apply product updates as soon
as available and to always use the latest product versions. Use of product
versions that are no longer supported, and failure to apply latest updates may
increase customers exposure to cyber threats.
To stay informed about product updates, subscribe to the Siemens Industrial
Security RSS Feed under http://www.siemens.com/industrialsecurity.

SIMATIC IOT2000 with DCMotor Shield


Version 1.0, 09/2016

Table of contents

Table of contents
Warranty and liability ................................................................................................... 2
1

Task ..................................................................................................................... 4
1.1

Required Hardware ............................................................................................ 5


2.1
2.2
2.3
2.4
2.5
2.6

SIMATIC IOT2000 ................................................................................ 5


Arduino Motor Shield Rev3 .................................................................. 5
External power supply .......................................................................... 5
DC Motor .............................................................................................. 6
Potentiometer ....................................................................................... 6
Bread board .......................................................................................... 6

Application Example ......................................................................................... 7


3.1
3.1.1
3.1.2
3.1.3
3.2

Siemens AG 2016 All rights reserved

Overview............................................................................................... 4

Hardware Setting .................................................................................. 7


Connecting the Arduino Shield to the SIMATIC IOT2000 .................... 7
Connecting the Potentiometer to the DC Motor Shield ........................ 8
Connecting the DC Motor Shield to the DC Motor and the
external power supply .......................................................................... 9
Program the Application Example in Eclipse ..................................... 10

Checklist ........................................................................................................... 12

Related literature ............................................................................................. 13

History............................................................................................................... 13

SIMATIC IOT2000 with DCMotor Shield


Version 1.0, 09/2016

1 Task

Task

1.1

Overview

Introduction
This Application Example shows how to use a DC Motor Shield with the SIMATIC
IOT2000. This sample includes controlling the speed of a DC Motor with a
potentiometer.

Goals
After working through this document you know how to

Siemens AG 2016 All rights reserved

NOTICE

Connect a Arduino Shield to the SIMATIC IOT2000

Initialize Digital/Analog/PWM Pins

Control a DC Motor via DC Motor Shield

Precondition!
To use this sample it is required that the Initial Operation in the Document
Setting up the SIMATIC IOT2000 has been executed once.

SIMATIC IOT2000 with DCMotor Shield


Version 1.0, 09/2016

2 Required Hardware

Required Hardware

2.1

SIMATIC IOT2000

2.2

Arduino Motor Shield Rev3


In this Application Example the Arduino Motor Shield Rev3 is used.
For technical description please refer to the official Arduino website:
https://www.arduino.cc/en/Main/ArduinoMotorShieldR3

Siemens AG 2016 All rights reserved

Figure 2-1

2.3

External power supply


In this Application Example a laboratory power supply is used. The Arduino Motor
Shield Rev3 must be powered only by an external power supply, because the
required motor current often exceeds the maximum current rating of the SIMATIC
IOT2000.
An external power supply between 7 and 12V is recommended by the
manufacturer of the Motor Shield. You can also use a battery instead of the
laboratory power supply.

SIMATIC IOT2000 with DCMotor Shield


Version 1.0, 09/2016

2 Required Hardware

2.4

DC Motor
In this Application Example a DC Motor 3 7.2V is used.

2.5

Potentiometer
In this Application Example a Potentiometer with 10k is used in order to control
the speed of the DC Motor.

2.6

Bread board

Siemens AG 2016 All rights reserved

In this Application Example a Bread Board is used to connect the Potentiometer


with the SIMATIC IOT2000

SIMATIC IOT2000 with DCMotor Shield


Version 1.0, 09/2016

3 Application Example

Application Example
This chapter describes how an application can be created with the Intel System
Studio IoT Edition.
For learning purposes, the speed of a DC Motor will be regulated with a
Potentiometer.

3.1

Hardware Setting
This chapter describes step by step how the hardware has to be connected

3.1.1

Connecting the Arduino Shield to the SIMATIC IOT2000


To connect the Arduino Shield to the SIMATIC IOT2000 insert the motor shield
pins into the sockets of the SIMATIC IOT2000

Siemens AG 2016 All rights reserved

Figure 3-1

SIMATIC IOT2000 with DCMotor Shield


Version 1.0, 09/2016

3 Application Example

3.1.2

Connecting the Potentiometer to the DC Motor Shield


Connect the L+ pin of the Potentiometer with the 5V pin of the Arduino Motor
Shield.
Connect the GND pin of the Potentiometer with the GND pin of the Arduino Motor
Shield.
Connect the middle pin of the Potentiometer with the A2 pin of the Arduino Motor
Shield.

Siemens AG 2016 All rights reserved

Figure 3-2

SIMATIC IOT2000 with DCMotor Shield


Version 1.0, 09/2016

3 Application Example

3.1.3

Connecting the DC Motor Shield to the DC Motor and the external


power supply
Connect the + terminal of Channel A of the DC Motor Shield to the positive pin of
the DC Motor
Connect the - terminal of Channel A of the DC Motor Shield to the ground pin of the
DC Motor

Siemens AG 2016 All rights reserved

Figure 3-3

Connect the Vin terminal of the DC Motor Shield to the positive wire of your
external power supply
Connect the GND terminal of the DC Motor Shield to the ground wire of your
external power supply
Figure 3-4

SIMATIC IOT2000 with DCMotor Shield


Version 1.0, 09/2016

3 Application Example

3.2

Program the Application Example in Eclipse

Create a new project and insert the code


Create a new project in Eclipse as described in SIMATIC IOT2000 Getting
Started
Table 3-1
No.
1.
2.

Action
Create a new project, here it is called DCMotor
Insert the code in the *.cpp file

#include <iostream>
#include "mraa.hpp"
using namespace std;

Siemens AG 2016 All rights reserved

int main()
{
//initialize GPIO Pin 12 for Motor Channel
mraa::Gpio* Motor_Channel_A;
Motor_Channel_A = new mraa::Gpio(12, true, false);
Motor_Channel_A->dir(mraa::DIR_OUT);
//initialize GPIO Pin 13 for Break Channel
mraa::Gpio* Break_Channel_A;
Break_Channel_A = new mraa::Gpio(13, true, false);
Break_Channel_A ->dir(mraa::DIR_OUT);
//initialize PWM Pin 3 for Speed Control
mraa::Pwm* Speed_A;
Speed_A = new mraa::Pwm(3);
Speed_A->enable(1); //enable the Pin for PWM
//initialize AIO Pin 2 for Potentiometer Input
mraa::Aio* PotentiometerIn;
PotentiometerIn = new mraa::Aio(2);
while(true)
{
float value;
value =PotentiometerIn->read(); //read analog
value from Potentiometer
value = value / 1023; //map into value for PWM
output (between 0 and 1 (0-100%))
Motor_Channel_A->write(1);//Establishes
forward direction of Channel A
Break_Channel_A->write(0);//Disengage the
Brake for Channel A
Speed_A->write(value);//write the mapped
analog value to the Speed control Pin
cout<<value<<endl;//display value written to
the Speed control Pin
}
return 0;
}
3.

Build the project (Ctrl+B)

SIMATIC IOT2000 with DCMotor Shield


Version 1.0, 09/2016

10

3 Application Example

No.
4.
5.

Change the storage location as described in the Getting Started


Transfer and run the project to the SIMATIC IOT2000 by press the green RUN
Button
Now you can control the speed of the DC Motor by modifying the value of
resistance of the potentiometer

Siemens AG 2016 All rights reserved

6.

Action

SIMATIC IOT2000 with DCMotor Shield


Version 1.0, 09/2016

11

4 Checklist

Checklist
This chapter contains a Checklist which summarizes all important steps in this
Application Example
Table 4-1
No.

Action

Connecting the Arduino Shield to the SIMATIC IOT2000

2.

Connecting the Potentiometer to the DC Motor Shield

3.

Connecting the DC Motor Shield to the DC Motor and the external power
supply

4.

Program the Application Example in Eclipse

Siemens AG 2016 All rights reserved

1.

SIMATIC IOT2000 with DCMotor Shield


Version 1.0, 09/2016

12

5 Related literature

Related literature
Table 5-1
Topic

\1\

SIMATIC IOT2000 forum


www.siemens.com/iot2000-forum

\2\

SIMATIC IOT2000 Setting Up


https://support.industry.siemens.com/tf/ww/en/posts/155642/

\3\

SIMATIC IOT2000 Getting Started


https://support.industry.siemens.com/tf/ww/en/posts/155643/

History

Siemens AG 2016 All rights reserved

Table 6-1
Version

Date

V1.0

09/2016

SIMATIC IOT2000 with DCMotor Shield


Version 1.0, 09/2016

Modifications
First version

13

S-ar putea să vă placă și