## Howto : program for charge and discharge an capacitor across an resistor with an voltage source?

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Stephane38
Newbie
Posts: 1
Joined: Wed Mar 16, 2016 8:24 am

### Howto : program for charge and discharge an capacitor across an resistor with an voltage source?

would like to program the x-y coordinate system.
Is there really is not to implement a general formula for the calculation of the window,
and this in a general function ?.
The intention is to have on this x -y axis the curve drawing which is generated with the
function eg the uc (t) and i (t) for charging a capacitor via a resistor or
another application.
I don't find any general formula for calculation the window.
It is not supposed to have to rewrite all my code but some parts where I stuck .
The problem is always that I never see a curve.

My question are:

1) Can here someone once in a general formula a function items for the calculation of the window range?

2) How do I draw the lines with the values ​​of the x and y axis ?.
As x axis is time axis , and this is then divided into lines , and there are then placed on the values ​​for the same y - axis
Refer to the figure of the x-y axis on the zero line

How can I charge and discharge current and capacitor voltage to graphically
visible as and curve. How should I calculate for that is always crashes .
Like a general formula to calculate the points .
Like using ddt statements. The user enters the parameters calculated
in the program and draws and i(t) and uc(t). image_7490.jpg (11.23 KiB) Viewed 2493 times

burger2227
Veteran
Posts: 2300
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

### Re: Howto : program for charge and discharge an capacitor across an resistor with an voltage source?

You cannot draw LINE's in SCREEN 0, the default. Try SCREEN 12 or 13.

12 is values of x from 0 to 640 (columns from left to right) and 0 to 480 values of y (rows from top down)

To plot a graph, take values of x and y and use LINE(x1, y1)-(x2, y2), 12 '12 is color red

You could put the values into an array and use a loop to read it later.