Like Tree2Likes
  • 2 Post By CommonTater

Basic C help. charging battery DC RC circuit in series

This is a discussion on Basic C help. charging battery DC RC circuit in series within the C Programming forums, part of the General Programming Boards category; given circuit containing a capacitor, switch, resistor and power supply. have to create a c program that allows the person ...

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    12

    Basic C help. charging battery DC RC circuit in series

    given circuit containing a capacitor, switch, resistor and power supply. have to create a c program that allows the person using it to calculate time it takes for capacitor to charge up to 50% 70% and 90% of supply voltage Vs.
    User must input values for the resistor R, capacitor C and power supply dc voltage with the final time answer given in seconds.

    Vc = Vs(1-e^-1/RC)) formula for calculating voltage across capacitor ( as a function of time) t=0 when switch is closed

    any ideas? new to c!

  2. #2
    Registered User
    Join Date
    Nov 2011
    Posts
    84
    Nope.

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    12
    okay thanks anyways!

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    The electrical charge on a capacitor is a function of time and available current... the current is limited by series resistence in the circuit...
    Given R and C one can calculate the rate of change using the simple forumla tc = 1 / (2pi R C)... A time constant (tc) is defined as the time it takes the capacitor to charge to 63% of the remaining voltage... a capacitor is considered fully charged after 5 time constants.

    Once you know C and R, simply apply the forumla to get the value of 1 time constant... the rest should be simple.

    What you need to do is sit down and figure out what is needed...
    Obviously you need the forumla...
    You also need some means of acquiring the values of R and C...
    and so on.

    With that in hand, you can write a step by step plan for solving the problem.

    With plan in hand, you can begin working on your source code.

    When the source is completed you need to test to make sure it's behaving correctly.
    Adak and yellowmania like this.

  5. #5
    Registered User
    Join Date
    Nov 2011
    Posts
    12
    Many Thanks Tater. This has helped my understanding of the problem loads! cheers.

  6. #6
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    That's a fine post Tater.

  7. #7
    Registered User
    Join Date
    Nov 2011
    Posts
    12

    C newbie!

    after some great help from Tater ive spent some time looking at it i now understand how it works on paper but i am still struggling to put that into a c program. As a C newbie wondering if anyone can help. The user must input the values of resistance R, capacitor C and Supply Voltage Vs. here is as far as ive got before hitting the wall. ( sorry if these basic c questions seem silly, only just started out! The aim of the program is to find how long it takes for capacitor to charge up 50%, 70% and 90%


    Code:
    #include <stdio.h>
     
    main()
    {
        float r;
        float c;
        float vs;
        float vc;
        printf("please input the value of the resistance\n");
        scanf("%f",&r);
        printf("please input the value of the current\n");
        scanf("%f",&c);
        printf("please input the value of the source voltage\n");
        scanf("%f",&vs);
    
    
    
    
    
    
    }

  8. #8
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Great start! ...

    Every solution begins with understanding the problem.

    The next step would be to apply your formula to the user's data and determine your time constant.

    I noticed you had a somewhat different formula in your original message... I don't recognize it (i.e. Its not one I've used in general electronics) but you should probably try both... When R is in Megohms and C is in Microfarads mine gives an answer in seconds... not sure about the other one.

    Then, once you've got the forumla to compile, you need to display the answers... so you'll have to add some printf() with the results.

    Then guess what... That's it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Battery charging algorithm
    By bloody in forum C++ Programming
    Replies: 7
    Last Post: 10-07-2011, 12:44 AM
  2. Series and Parallel Circuit Calculator
    By LOBH in forum C Programming
    Replies: 1
    Last Post: 11-22-2009, 12:06 PM
  3. C Programming for LED circuit
    By vivharv in forum C Programming
    Replies: 4
    Last Post: 09-18-2007, 04:34 AM
  4. eulers circuit
    By zarganah in forum C++ Programming
    Replies: 4
    Last Post: 11-15-2004, 05:25 PM
  5. circuit
    By theOracle in forum C++ Programming
    Replies: 13
    Last Post: 05-18-2003, 07:14 PM

Tags for this Thread


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