Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Electronics calculations using C

Posted on 1997-12-11
4
194 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

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…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

808 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