Solved

Electronics calculations using C

Posted on 1997-12-11
4
192 Views
Last Modified: 2010-04-02
 I am looking for an appropriate data-structure to represent and calculate the values of electronic components that connected (wired) in a circuit.
Questions:
 - How do I resolve data storage for components that have  many values (transistors) and for components that have a  only a few (resistors, capacitors, yet don't end up with a dozen different "typedef struct"?
 - How do I represent nodes -e.g. wires - connecting each  components, since the components are
 - not limited only to 2 nodes (transistors has 3 nodes)
 - not limited to 2 wires (from a node any number of wires can origin)

  If you have no idea, please answer these:
 - Is it the problem that I am thinking too pictorically, and problems of this nature should be derived into equations and solved algebrically?
 - Wouldn't be better to use C++ and create classes of components to pass data between components to simulate voltage/current/resistance values through the circuit?
 - Am I have gone nuts?
0
Comment
Question by:sany
  • 2
4 Comments
 
LVL 3

Expert Comment

by:rmichels
ID: 1256620
I would much rather use C++ as a solution.  You can create electronic objects that have their behavior programmed in. Each component would have relationships to other components (representing the connections).



 I don't remember enuf about electronics though to give you much further advice though..
0
 
LVL 10

Accepted Solution

by:
rbr earned 200 total points
ID: 1256621
Use a dynamic Structure.

struct element {
    unsigned node_anz;
    struct **ppnodes;
... + any other info you need
}
/* Create a new element
 * Returnvalue is pointer to the element */

struct element *create_new_element(int node_anz)
{
     struct element *p;
     p=(struct element*)calloc (sizeof(struct element),1);
     p->node_anz = node_anz;
     p->ppnodes = (struct element **)calloc (sizeof(struct element *),p->node_anz);
       return (p);
}
/* Connect to elements at node1 of first element p1 and at node2
 * of second element p2 */
void connect_elements (struct element *p1, struct element *p2,
                       unsigned node1, unsigned node2)
{
   if ((node1 < p1->node_anz) && (node2 < p2->node_anz)) {
        p1->ppnodes[node1]=p2;
        p2->ppnodes[node2]=p1;
   }
}

0
 
LVL 10

Expert Comment

by:rbr
ID: 1256622
If you need wires this is just a dummy element which as many nodes as you need.
0
 

Author Comment

by:sany
ID: 1256623
A linked list provides only a partial solution, and I'll still end up with all those struct for different components. Traveling a list even more difficult, but this is the only solution I have found so far, and have to consider...
Thanks -san
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now