Equivalent Resistance Calculations

This is a discussion on Equivalent Resistance Calculations within the C++ Programming forums, part of the General Programming Boards category; Please can anyone help me with the following : http://www.staff.ncl.ac.uk/alex.yako...se/ladder.html It has to work in Cygwin Bash Shell Thanks !...

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    6

    Unhappy Equivalent Resistance Calculations

    Please can anyone help me with the following :

    http://www.staff.ncl.ac.uk/alex.yako...se/ladder.html

    It has to work in Cygwin Bash Shell

    Thanks !
    Last edited by TaBkill3r; 11-09-2007 at 03:45 AM.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,590
    So what bit are you stuck on?
    - parsing the input data
    - doing the calculations
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    6
    I can't finish part 1
    -doing the calculations

  4. #4
    Lead Moderator kermi3's Avatar
    Join Date
    Aug 1998
    Posts
    2,595
    This might be useful.
    Kermi3

    If you're new to the boards, welcome and reading this will help you get started.
    Information on code tags may be found here

    - Sandlot is the highest form of sport.

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,590
    So post your best effort to date, and ask a more specific question about something you're stuck on, or what to do next.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    Registered User
    Join Date
    Nov 2007
    Posts
    6

    Red face

    I have done this so far ( input the readings)...
    ---------------------------------------------------------------
    Code:
    int main()
    {
     
     const int MAXSIZE=10; // absolute max size of the array 	
     double readings[MAXSIZE]; // array declaration
     
     int noOfRes; // actual number of readings 
    
     int carryon = 1; // initialise flag to continue calculations
     while (carryon)
     {
    
      cout << "Enter actual number of the resistors.  (0<n<=" 
           << MAXSIZE << "): ";
      cin >> noOfRes; cout << endl;
     
      // enter actual readings from keyboard
      cout << "Enter the actual value of the resistors (Ohms) , one at a time, following the prompt\n";
      for (int i = 0; i < noOfRes; i++)
      {
      
        cout << "reading(" << i+1 << ") = ";
        cin >>  readings[i];
       
      }                      
      cout << endl;
    ----------------------------------------------------------
    How i will do that ?
    Calculate the overall equivalent resistance of the circuit
    Last edited by TaBkill3r; 11-09-2007 at 07:21 AM.

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Why are you asking for temperarures, when the link you posted is referring to a resistor ladder?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #8
    Registered User
    Join Date
    Nov 2007
    Posts
    6
    Quote Originally Posted by matsp View Post
    Why are you asking for temperarures, when the link you posted is referring to a resistor ladder?

    --
    Mats
    Sorry about that ! ...

    I made the appropriate corrections

  9. #9
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So, what about actually TRYING to write some calculations? After all, the formulas are defined in the project specification.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  10. #10
    Registered User
    Join Date
    Nov 2007
    Posts
    6
    Mate im not good as you in C++, i can't find how i'll make the programm distinguish between odd and even numbers. I think i'll use if the number
    of the resistor is %2=0 then do the calculations which are specified in the problem.
    I want you to write me the code for that if you can ....

  11. #11
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by TaBkill3r View Post
    I want you to write me the code for that if you can ....
    And I don't want to do that, because it would teach you absolutely nothing [and teach me barely anything, because although I haven't implemented this type of calcuation, I don't think it's particularly hard]. So why should I?

    You have the right idea of "how to check if a number is odd or not". x % 2 will be either 0 (x is even) or 1 (x is odd).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  12. #12
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    You really don't need to worry about odd/even. To solve this type of circuit you just have to work backwards.

    The last two resistors are in series. That equivalent resistor is in parallel with the next resistor. That equivalent resistor is in series with the next resistor. That equivalent resistor is in parallel with the next resistor. Repeat until you have no more resistors.

    For this problem you know the last two resistors are in series and that there are 2n resistors.

  13. #13
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,307
    Quote Originally Posted by TaBkill3r View Post
    I want you to write me the code for that if you can ....
    Then you've come to the wrong place. We provide help here, not free code.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  14. #14
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,109
    I think an easier way to deal with something like this is to calculate the currents in each loop. (by applying kcl and kvl laws, and a method called the "maas" currents... I'm sure there is a formal english word for this).
    Aferwards you get for instance 5 equations with 5 unknown variables, put it in a matrix form, calculate the echelon form of this matrix.

    And kabang there you have all the currents in each loop, then its just a matter of calculating the voltage which is easy since you know all currents and know all resistance values...

    I think programming wise, its easier to do it this way, the only difficult part is finding the loops and all nodes and know which resistor is in which loop...afterwards its just applying some simple laws and mathematics.

    I bet if you work it out like this you get even better grades!
    Last edited by GanglyLamb; 11-09-2007 at 12:09 PM.

  15. #15
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    This is an easy task.

    For all series-parallel circuits do the parallel portion first. This effectively turns the parallel portion into a series portion or turns many resistors into one with a corresponding resistance value.

    Once you have this then you can plug the values into Ohm's law and figure out the rest of the circuit.

    Parallel: Total = 1/R1 + 1/R2 + 1/R3 + .... 1/Rn
    Series: Total = R1 + R2 + R3 + ... + Rn

    Ohm's law: E = IR - E = voltage, I = amperage, R = resistance

    I highly recommend RIEP charts (P(ower)=I * E) to figure circuits out. You can implement this in code as well. Using RIEP charts you can figure out any circuit with little trouble.

    Most of that question is a 'trick' question. Regardless of how the resistors in a circuit are arranged they always follow the fundamental parallel or series rules. If you have parallel portions, you must figure those out first.

    Also remember this:

    Series
    Amperage is constant - hence you get voltage drops across the resistors

    Parallel
    Voltage is constant - hence you can figure out how many amps are flowing through each resistor in a parallel circuit
    Last edited by VirtualAce; 11-09-2007 at 05:00 PM.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointer equivalent to array notation
    By bekkilyn in forum C Programming
    Replies: 4
    Last Post: 12-06-2006, 07:22 PM
  2. Air Resistance?
    By Muphin in forum C++ Programming
    Replies: 5
    Last Post: 09-05-2005, 04:35 PM
  3. Replies: 10
    Last Post: 08-17-2005, 11:17 PM
  4. Header File Question(s)
    By AQWst in forum C++ Programming
    Replies: 10
    Last Post: 12-23-2004, 10:31 PM
  5. How do I get these calculations correct?
    By nadeni0119 in forum C++ Programming
    Replies: 10
    Last Post: 04-07-2003, 11:09 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21