[go: up one dir, main page]

0% found this document useful (0 votes)
47 views3 pages

Example On Bode Magnitude Plot

This document provides steps to create a Bode magnitude plot using Visual Basic.NET. It defines a Bode magnitude function BM and breaks it into smaller components. It then provides code to: 1. Define variables and arrays to store frequency, X and Y values 2. Calculate BM values over a frequency range and store in an array 3. Plot the graph of BM against log frequency on a chart control 4. Determine and display the maximum and minimum BM values

Uploaded by

cadobserver
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)
47 views3 pages

Example On Bode Magnitude Plot

This document provides steps to create a Bode magnitude plot using Visual Basic.NET. It defines a Bode magnitude function BM and breaks it into smaller components. It then provides code to: 1. Define variables and arrays to store frequency, X and Y values 2. Calculate BM values over a frequency range and store in an array 3. Plot the graph of BM against log frequency on a chart control 4. Determine and display the maximum and minimum BM values

Uploaded by

cadobserver
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/ 3

EXAMPLE ON CREATING BODE MAGNITUDE PLOT USING VISUAL BASIC.

NET
Consider a function BM which is the bode magnitude for a system, defined as:

BM  20 Log10  9   20 Log10    20Log  0.01  W  0.998 


0.01  W  0.998 
2
10
2

20 Log10 W   20 Log10  0.36  W  2.9394   20Log  0.36  W  2.9394 


2
10
2

Plot the graph of BM on the Y axis against Log10 W  on the X axis

Fig.1: Programme interface for the function to be plotted


Solution
Steps
1. Launch Visual Basic.
2. From the toolbox, place one button, two textboxes, and two labels by the textboxes
respectively.
3. From the toolbox, place Chart tool on form 1
4. Change the text on button1 to Plot Graph
5. Change the text on label1 to BodeMagMax
6. Change the text on label1 to BodeMagMin
7. Double click on button 1 and type the following codes given in the code section:
8. Run the programme and click on button 1 (that has text: Plot Graph)
9. Break the function BM into smaller components as follows:
10. C  0.01  W  0.998 
2

1
11. D  0.01  W  0.998 
2

12. G  0.36  W  2.9394 


2

13. H  0.36  W  2.9394 


2

14. And combine all as: BM(1) = 20 * (Math.Log10(9) + Math.Log10(C) + Math.Log10(D) -


Math.Log10(W) - Math.Log10(G) - Math.Log10(H)). This is represented on the Y axis
15. XW(I) = Math.Log10(W) This is represented on the X axis
16. To determine the maximum and minimum values for BM(I) use the Math.Max and
Math.Min functions.
17. Use Textbox1.Text to display the values of BMAX and Textbox2.Text to display BMIN
18. Click on button 1 and type the following codes:
DOUBLE CLICK ON BUTTON 1 (PLOT GRAPH) AND TYPE THESE CODES IN TO
ITS CODE WINDOW
Dim W, A(1000), B(1000), C, D, G, H, XW(10000), BM(10000), BMAX, BMIN As Single
Dim I As Integer

W = 0.01
C = ((0.01 + (W - 0.995) ^ 2)) ^ 0.5
D = ((0.01 + (W + 0.995) ^ 2)) ^ 0.5
G = ((0.36 + (W - 2.9394) ^ 2)) ^ 0.5
H = ((0.36 + (W + 2.9394) ^ 2)) ^ 0.5
BM(1) = 20 * (Math.Log10(9) + Math.Log10(C) + Math.Log10(D) - Math.Log10(W) -
Math.Log10(G) - Math.Log10(H))
BMAX = BM(1) * 1
BMIN = BM(1) * 1

With Chart1.ChartAreas(0)
.AxisY.Minimum = -25
.AxisY.Maximum = 40
.AxisX.Maximum = 2
.AxisX.Minimum = -2
End With

For I = 1 To 10000
W = 0.01 * I
XW(I) = Math.Log10(W)
C = ((0.01 + (W - 0.995) ^ 2)) ^ 0.5
D = ((0.01 + (W + 0.995) ^ 2)) ^ 0.5
G = ((0.36 + (W - 2.9394) ^ 2)) ^ 0.5
H = ((0.36 + (W + 2.9394) ^ 2)) ^ 0.5
BM(I) = 20 * (Math.Log10(9) + Math.Log10(C) + Math.Log10(D) - Math.Log10(W) -
Math.Log10(G) - Math.Log10(H))
2
BMAX = Math.Max(BM(I), BMAX)
BMIN = Math.Min(BM(I), BMIN)

With Chart1.Series(0)
.ChartType = DataVisualization.Charting.SeriesChartType.Line
.BorderWidth = 1
.Color = Color.Red
.MarkerStyle = DataVisualization.Charting.MarkerStyle.Square
.MarkerSize = 1
.Points.AddXY(XW(I), BM(I))
End With

Next I

TextBox1.Text = BMAX
TextBox2.Text = BMIN

You might also like