[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Electronics calculations using C

Posted on 1997-12-11
4
Medium Priority
?
200 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
[X]
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
  • 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 600 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
Suggested Courses

649 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