### Author Topic: Electric Circuit Calculation  (Read 891 times)

0 Members and 1 Guest are viewing this topic.

#### APoloG13

• LV2 Member (Next: 40)
• Posts: 32
• Rating: +0/-0
##### Electric Circuit Calculation
« on: October 14, 2018, 07:23:58 pm »
Hello omnimaga users,

I'm opening this topic to discuss/brainstorm/beg for help because I have in mind to create a program to solve circuits.

For those who don't know what i mean with solve circuits i will explain myself. When you elaborate a circuit you end knowing what intensity, voltage, resistance and power you have on each branch, node and object using the Kirchhoff Laws of current and voltage combined with the Ohm law. Basically an equation system. ( For more info   https://www.electronics-tutorials.ws/dccircuits/dcp_4.html )

The idea is to elaborate a program in wich we can "draw" our circuits and it will be able to find the nodes and branch and after that calculate all the enigmas of the circuit.

What's the problem? Don't know how to do the part for insert the data / draw the circuit, because the most common scenario will be always you have a circuit and some data known and some missing data. I assume the calculation part will be the easy part (I assume... probably wrong).

Hope someone could give me a hand with this project.

#### Xeda112358

• Xombie. I am it.
• Moderator
• LV12 Extreme Poster (Next: 5000)
• Posts: 4450
• Rating: +702/-6
• meow :3
##### Re: Electric Circuit Calculation
« Reply #1 on: October 16, 2018, 02:06:35 am »
I wish I could help, but I can't think up a way to make input easy.

#### APoloG13

• LV2 Member (Next: 40)
• Posts: 32
• Rating: +0/-0
##### Re: Electric Circuit Calculation
« Reply #2 on: October 19, 2018, 07:22:09 pm »
Maybe like an structural analysis, you know xy coordinates for the nodes, specify where the wires go and then specify in wich lines we have something?
Something like :

N°nodes?
4

Coordinates of the nodes:
Node 1(0,0)
Node 2(1,0)
Node 3(1,1)
Node 4(0,1)

Nodes conections?
a 1-2
b 2-3
c 3-4
d 4-5

Any wire have something?
a - Battery
c - 10kOhm resistor

Maybe that could be a way don’t know, of course would be incredible if it draws it as you could see if you have made any mistake inserting the data but one step then other.

What do you think?

#### APoloG13

• LV2 Member (Next: 40)
• Posts: 32
• Rating: +0/-0
##### Re: Electric Circuit Calculation
« Reply #3 on: October 31, 2018, 08:26:48 pm »
Well, i FINALLY managed to make a program that actually works and makes quite exact calculations based on the modify nodal analysis algorithm.

For now only supports for a 2 node circuit. The code is quite a bit a lot shitty, hope someone can help me to make it prettier (because it's actually my first "hard" program) but works.

To make it work just fill the request windows and it will solve all your problems (2 nodes problmes)

#### Stefan Bauwens

• Creator of Myst 89 - סטיבן
• LV10 31337 u53r (Next: 2000)
• Posts: 1799
• Rating: +162/-24
• 68k programmer
##### Re: Electric Circuit Calculation
« Reply #4 on: November 08, 2018, 03:01:19 pm »
Hi there. As I myself am working on some kind of circuit simulation thing for VR I was intrigued.
I've been looking a bit into SPICE recently, as I probably will be using that in the near future for more accurate circuit simulation.

Anyways this page shows an example of how Spice(sharp) defines a simple DC circuit in C#.
Code: [Select]
// Build the circuitvar ckt = new Circuit(    new VoltageSource("V1", "in", "0", 1.0),    new Resistor("R1", "in", "out", 1.0e4),    new Resistor("R2", "out", "0", 2.0e4)    );
Even though this is CODE, the connections are based on the custom given nodes (if I'm not mistaken): "in", "0", "out", which seems pretty easy to understand to me. So perhaps you could just use user inputed strings for each terminal of a component and compare the strings in code to see how the things are connected in your code?

fixed url -- z
« Last Edit: November 08, 2018, 09:48:56 pm by Xeda112358 »

Very proud Ticalc.org POTY winner (2011 68k) with Myst 89!
Very proud TI-Planet.org DBZ winner(2013)

Interview with me

#### Xeda112358

• Xombie. I am it.
• Moderator
• LV12 Extreme Poster (Next: 5000)
• Posts: 4450
• Rating: +702/-6
• meow :3
##### Re: Electric Circuit Calculation
« Reply #5 on: November 08, 2018, 09:53:07 pm »
Thanks for weighing in, Stefan, you are probably one of the most knowledgeable 68k/nSpire BASIC programmers here, so you'd really know what was feasible ^_^ And the link looks pretty useful.

#### Stefan Bauwens

• Creator of Myst 89 - סטיבן
• LV10 31337 u53r (Next: 2000)
• Posts: 1799
• Rating: +162/-24
• 68k programmer
##### Re: Electric Circuit Calculation
« Reply #6 on: November 09, 2018, 09:37:19 am »
Thanks for weighing in, Stefan, you are probably one of the most knowledgeable 68k/nSpire BASIC programmers here, so you'd really know what was feasible ^_^ And the link looks pretty useful.
Perhaps when it comes to 68k basic though I have basically no experience with the nspire, unlike my brother Jim
It's been a while since I really programmed for any calculator to be honest.

Very proud Ticalc.org POTY winner (2011 68k) with Myst 89!
Very proud TI-Planet.org DBZ winner(2013)

Interview with me

#### Xeda112358

• Xombie. I am it.
• Moderator
• LV12 Extreme Poster (Next: 5000)
• Posts: 4450
• Rating: +702/-6
• meow :3
##### Re: Electric Circuit Calculation
« Reply #7 on: November 09, 2018, 09:39:43 am »
Pretty much the only difference in the BASIC language is no real graphics functions on the nspire. The rest is pretty much the same.

#### APoloG13

• LV2 Member (Next: 40)
• Posts: 32
• Rating: +0/-0
##### Re: Electric Circuit Calculation
« Reply #8 on: November 12, 2018, 08:08:04 pm »
Upgrade for the program, i manage to make a modified nodal analysis for 3 node circuits wich i plan to upgrade for more nodes, not hard to use.

If anyone have any questions or want to help to improve the program will be more than welcome