Results 1 to 25 of 25

Thread: network therom

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    12

    Question network therom

    hi

    i have to create a program that does ac thevenins using vb but dont know how to use complex numbers or change from rectangular to polar

  2. #2
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: network therom

    What does "ac thevenins" mean? If you need a tutorial in complex numbers from the ground up, this probably isn't the place because they're a huge topic. Maybe you could ask a teacher or friend in more advanced math... unless you have more specific questions for us.
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    12

    Thumbs up Re: network therom

    i know how to do it jsut not using visual basic and because its ma uni project a kant ask ( a kan ask but they kant help without deducting marks)

    for example if a give you 3 values

    Z1=34+j8
    z2=32+j90

    i have to convert it to polar form so my answer is x to the angle of y

    if anyone can help me it would be great if not oh well
    one phil o donnell

  4. #4
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: network therom

    How much VB do you know? I'm sure quite a few of us could give you the solution but it's much better to lead you to it instead.
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    12

    Re: network therom

    i know a fair bit of vb and have made various other vb programs like a timer and calculater

    once i see the code i will know where i went wrong
    one phil o donnell

  6. #6
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: network therom

    If you know how to do it mathematically (by hand), I'm sure it's not too hard to translate that into VB code?

    For example, to convert a complex number in the form of z = x + jy to polar coordinates, you first need to find the length of the vector:
    r = sqrt( x2 + y2 )

    Then you need to find the angle:
    tanθ = b/a --> θ = arctan(b/a)

    The polar form is now:
    z = r * e = r ( cosθ + j sinθ )

    These are all functions present in VB (probably Math.Arctan for example).


    With numbers:
    Convert z = 4 + 3i to polar form:

    z = sqrt( 42 + 32 ) exp( j * arctan(3/4) )


    Not that hard, right? Is this what you want to do?


    EDIT
    By "AC Thevenins" the topicstarter probably means using Thevenins theorem to model the input/output characteristics of any linear electrical network (with an AC source) to merely one source and one resistor.
    Last edited by NickThissen; May 23rd, 2008 at 12:30 PM.

  7. #7

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    12

    Thumbs up Re: network therom

    yeah thats it thanks
    so say a have 3 ac values
    z1= 120+2j
    z2= 31+2j
    z3= 70+31j
    v1= 31

    would a have to state as a integer or anything

    thanks in advance
    one phil o donnell

  8. #8
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: network therom

    You'll have to tell us more about what you want to do exactly...

    Do you simply want to display a number like z = x + jy in the polar form: z = r e, or do you want to do calculations with them?

    If you simply want to display it in polar form you can probably use something along the lines of:

    Code:
    Dim z(1) As Double
    z(0) = 120   'Real part
    z(1) = 2   'Imaginery part
    
    txtPolar.Text = Math.Sqrt( z(0)^2 + z(1)^2 ).ToString & "exp( j " & Math.Arctan( z(1) / z(0) ) & " )"
    This simply uses a Double z with as an array with two entries. z(0) is the real part and z(1) is the imaginery part.

    So z = x + jy becomes:
    z(0) = x
    z(1) = y

    And z = 91 + 3j becomes:
    z(0) = 91
    z(1) = 3

  9. #9

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    12

    Smile Re: network therom

    yeah

    basically what should happen is the user enters 3 values (z1 z2 z3) and v and my program should work out the thevenins voltage and the thevenins impedance and then showing the answer in rectanguar form aswell as polar form
    one phil o donnell

  10. #10
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: network therom

    Could you just use InputBox and MsgBox for input and output? The rest you should be able to do based on Nick's example (though he wrote it in .NET instead of in VB6).
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  11. #11

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    12

    Thumbs up Re: network therom

    yeah i can am just confused whats the difference with .net and vb ?
    what would i have to change from nicks code
    thanks
    one phil o donnell

  12. #12
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: network therom

    You'd have to use Atn() instead of Math.Arctan, Str() instead of the .ToString method, and Sqr() [no t] instead of Math.Sqrt. Also, you should probably note that the tangent function isn't truly invertible--for example, -1-i and +1+i have different angles, but Atn(-1/-1)=Atn(1/1) = pi/4. You should account for this with appropriate if checks, if it matters in your case.
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  13. #13
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: network therom

    One problem with my method is that arctan(1/1) will not show as pi/4, but as 0.785398...

    You could 'hardcode' a few of these 'neat angles' so your program recognizes them.

  14. #14

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    12

    Unhappy Re: network therom

    nick i will be using simple numbers so a wont have to hardcode anything a just have to show it works

    does anyone have any vb6 samples of the program cos am still not sure

    thanks all for your help
    one phil o donnell

  15. #15
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: network therom

    The VB.NET code I posted above would probably be something like this in VB6:

    Code:
    Dim z(1) As Double
    z(0) = 120   'Real part
    z(1) = 2   'Imaginery part
    
    txtPolar.Text = Str(Sqr( z(0)^2 + z(1)^2 )) & "exp( j " & Str(Atn( z(1) / z(0))) & " )"

  16. #16

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    12

    Re: network therom

    nick what am getting confused at is what do i state z0 = as the number will change from time to time so do i state z0 = x or something along those lines ?
    one phil o donnell

  17. #17
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: network therom

    In my code I am just assigning some random imaginery number to z. How you want to do it in your code depends completely on how the user inputs the number. For example you could use two inputboxes:

    Code:
    z(0) = Dbl( InputBox("Enter the real part:") )
    z(1) = Dbl( InputBox("Enter the imaginery part:") )
    (I believe 'Dbl' is used to convert to double, right?)

    (You could also use just one inputbox and store it to a string, then use string functions to retrieve the real and imaginery parts)

  18. #18

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    12

    Red face Re: network therom

    i have attached what i have done so far how would you code it for the ac?

    thanks
    Attached Files Attached Files
    one phil o donnell

  19. #19
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: network therom

    Assuming you want to do what you mentioned above with coordinate conversions, you have more than enough information to do code that yourself....
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  20. #20

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    12

    Re: network therom

    i have tried the above code but i am still getting error messages
    one phil o donnell

  21. #21

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    12

    Re: network therom

    has any one had any luck with the code am desparate now
    one phil o donnell

  22. #22
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: network therom

    If you could just explain to us exactly what you want to do instead of let us guess you might get better help!

    You are only telling us glimpses of what you need... You need some way to convert a cartesian complex number to a complex number in polar coordinates. I have gave you the exact code for that. How and why does the user need this program? How is the user going to input the number in the first place, how are you going to use the convert number afterwards, etc... etc..?

  23. #23

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    12

    Re: network therom

    sorry if i have not been clear

    i have attached the forms of what i have done so far on the 26th may

    the user will enter 3 values as shown on my ac form and then click calculate the program should then work out the thevenins resistance and thevenisn voltage in both polar and in rectangular form

    i have doen the dc version so if you look at that its simiar to that the answer should be displayed on screen
    one phil o donnell

  24. #24
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: network therom

    I'm sorry I dont have VB6 installed here so I can't check out your forms.

    If you have the DC version you should also be able to work out the AC version... Have you managed to get the AC version in 'rectangular' form? If so, you can easily use the code I gave you to convert it to polar form...

  25. #25
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: network therom

    I did look at the code, but I still don't really know what you want.... However from the code you've got, you really really should have enough information to do this. Sorry, but I'm not coding it for you. If you have a line of code that gives an error, I'm sure people would be happy to explain it and help fix it, but you haven't given us that.
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width