0% found this document useful (0 votes)
11 views20 pages

Simulink Programming - IO and Operators

The document outlines a project on Simulink programming, covering essential concepts such as data types, source and sink blocks, arithmetic operators, logical operators, relational operators, and delay. Each section includes examples and instructions for implementing these concepts in Simulink. The focus is on understanding how to manipulate and analyze data using various programming blocks within the Simulink environment.

Uploaded by

sgk52578
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views20 pages

Simulink Programming - IO and Operators

The document outlines a project on Simulink programming, covering essential concepts such as data types, source and sink blocks, arithmetic operators, logical operators, relational operators, and delay. Each section includes examples and instructions for implementing these concepts in Simulink. The focus is on understanding how to manipulate and analyze data using various programming blocks within the Simulink environment.

Uploaded by

sgk52578
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Creative Problem Solving Project

Simulink Programming – Part 1


Contents
1 Data Type

2 Source & Sink Block

3 Arithmetic Operators

4 Logical Operators

5 Relational Operators

6 Delay
1. Data Type

Data Type

❖ Integer(정수형)
❖ Int : 정수를 표현하기 위해 사용하는 데이터 타입으로 4 byte의 메모리 양을 가지고 있다.

❖ Float(실수형)
❖ Double : 실수를 표현하기 위해 사용하는 데이터 타입으로 8 byte의 메모리 양을 가지고 있다.

❖ Boolean(참, 거짓)
❖ Normally
• True : 1
• False : 0

❖ Textual(문자형)
1. Data Type

Example #1
예제 : Data type에 따른 출력값을 Display 에서 확인한다.

1. Enter the desired constant


2. Create the ‘Data_type_conversion’
3. Connect to ‘Display’
4. Run Program.
5. Check the Value (Display~Display1)
2. Source & Sink Block

Source(Input) Block

▪ 1. 상수 값 입력 ▪ 2. 일차함수 입력
Library Browser -> Sources -> Constant Library Browser -> Sources -> Ramp

▪ 3. 계단함수 입력 ▪ 4. 삼각함수 입력
Library Browser -> Sources -> Step Library Browser -> Sources -> Sine Wave

※ Input을 생성해야 Output이 발생한다.


2. Source & Sink Block

Sink(Output) Block

▪ 1. Output을 수치로 확인
Library Browser -> Sinks -> Display

▪ 2. Output을 그래프로 확인

Library Browser -> Sinks -> Scope


3. Arithmetic Operators

Four fundamental rules of arithmetic

▪ 1. A + B ▪ 2. A - B

▪ 3. A X B ▪ 4. A / B
A
Result

Library Browser -> Math Operations ->


3. Arithmetic Operators

Example #2
예제 : Add(+), Subtract(-), Product(x), Divide(÷)를 통한 연산결과 확인

1. Enter the desired constant


2. Design the math BLOCK as follows
3. Run Program.
4. Check the Value (Display~Display3)
5. Try step 2 ~ 4 again as changing the Value.
3. Arithmetic Operators

Example #2
First Step) Add

1. Enter the desired constant


2. Design the math BLOCK as follows
3. Run Program.
4. Check the Value (Display_Add)
3. Arithmetic Operators

Example #2
Second Step) Subtract

1. Enter the desired constant


2. Design the math BLOCK as follows
3. Run Program.
4. Check the Value (Display_Subtract)
3. Arithmetic Operators

Example #2
Third Step) Product

1. Enter the desired constant


2. Design the math BLOCK as follows
3. Run Program.
4. Check the Value (Display_Product)
3. Arithmetic Operators

Example #2
Final Step) Divided

1. Enter the desired constant


2. Design the math BLOCK as follows
3. Run Program.
4. Check the Value (Display_divide)
4. Logical Operators

Logical Operator Block


Library Browser → Simulink → Logic and Bit Operations→
Logical Operator

A
Result

B
4. Logical Operators

Logical Operators

x y Result x y Result
True True True True True True
False True False False True True
True False False True False True
False False False False False False

x y Result x y Result
True True False True True False
False True True False True True
True False True True False True
False False True False False False
4. Logical Operators

Example #3
예제: Boolean값과 논리연산자를통해Display에서결과값확인
*연산결과가 0이면 거짓 1이면 참
5. Relational Operators

Comparison
❖Comparison
In computer programming, Comparison of
two data items is effected by the compariso
n operators typically written as :
▪ > (greater than)
▪ < (less than)
▪ >= (greater than or equal to)
▪ <= (less than or equal to)
▪ = or == (exactly equal to)
▪ !=, <> or /= (not equal to)
5. Relational Operators

Relational Operators Block

A
Result
A≤B?
B
5. Relational Operators

Example #4
예제 : 입력값과 기준값의 비교연산 결과를 통해
Display에서 참, 거짓 판단
6. Delay

Delay
Unit Delay : Delay input signal by fixed or variable
sample periods

Simulink Library Browser -> Simulink -> Math Operations - > Delay
6. Delay

Example #5
예제 : Delay 를 통해 sum연산자의 정보를 저장하고 저장한 데이터를
다시 연산자의 input으로 사용할 수 있다.

You might also like