Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: stevon8ter on November 29, 2012, 12:36:51 pm

Title: [AXE] electricity simulator
Post by: stevon8ter on November 29, 2012, 12:36:51 pm
Hi guys

I'm new to AXE programming, so don't be to hard on me for my noobie mistakes i made.
So what i want is a program that can simulate an electrical circuit, like this:

(http://postimage.org/image/zec7c4lzl/1bceb6dc/)

And i want to be able to give values to all the components that i know, and then i want it to be able to calculate all ungiven vars.
And maybe let lines auto connect the components instead of letting the user do it? (optional choice)

Ok, so here's a little gif of what i already made so far.
I know, the map routine could probably be a lot smaller and more optimised, idk

I'll add the source as well...


Title: Re: [AXE] electricity simulator
Post by: Matrefeytontias on November 29, 2012, 01:36:14 pm
I like the concept, it seems a bit like the Proteus software :)

If you're having troubles just ask around, there are many Axe coders which can help you (including me :P ).
Title: Re: [AXE] electricity simulator
Post by: stevon8ter on November 29, 2012, 01:55:09 pm
well i've got some problems... (+ got to recode the while thing) but TheMachine02 is looking into it....
Title: Re: [AXE] electricity simulator
Post by: Keoni29 on November 29, 2012, 01:57:58 pm
Do you even know how to make this kind of simulation software using a different language?

Edit: Do you know analysis techniques to analyze networks?
Title: Re: [AXE] electricity simulator
Post by: stevon8ter on November 29, 2012, 02:17:41 pm
Do you even know how to make this kind of simulation software using a different language?

Edit: Do you know analysis techniques to analyze networks?

No that's something i don't know, the way i'dd do it would take up a lot of space :/ and vars :/
but i just have the tileplacing and i need to know how i could do the Values pointing to a component
Title: Re: [AXE] electricity simulator
Post by: Keoni29 on November 29, 2012, 02:55:22 pm
So... you don't know anything about electronics and simulators and AXE and still you think this is a good idea :P No offense, but I don't see how this is possible at this moment. I study electronics and I know how complex these simulators really are.
Title: Re: [AXE] electricity simulator
Post by: stevon8ter on November 29, 2012, 03:03:51 pm
I know about electronics etc (elektronica, binair, binaire logica, and-or-not-xor-... poorten, elektriciteit (dutch))

Maar dat is juist de bedoeling... om te leren hoe ik zo een eenvoudige simulator maak...
Title: Re: [AXE] electricity simulator
Post by: Keoni29 on November 29, 2012, 03:10:32 pm
A logic simulator is easier to make! With analog electronics you have to deal with impedances, transitions, tresholds, phasors, etc. I bet a TI84+ is not strong enough to handle that.
Title: Re: [AXE] electricity simulator
Post by: stevon8ter on November 29, 2012, 03:12:18 pm
I just need to emulate a: (spoel, weerstand, en condensator op ac, en dat zijn maar enkele formules) it's for school
Title: Re: [AXE] electricity simulator
Post by: Keoni29 on November 29, 2012, 03:15:43 pm
What's the imput signal you want to feed trough those things?
If it's DC you just have to replace the capacitors with open ranks and the inductor coils with short circuits. Analyzing resistor networks is very easy :)
Title: Re: [AXE] electricity simulator
Post by: shmibs on November 29, 2012, 03:32:21 pm
a good place to start with this would be implementing a linked list data structure. once you have that working, you're going to need to decide on what different attributes to have defined for each possible element (i.e., how long is the current stalled when passing through, what resistance level is there, what's the minimal voltage for it to work, etcetera). then, as long as you aren't looking for too much accuracy, and if each element is connected to only one other, it should be pretty easy. as soon as you start adding in branching and merging paths, however, things will get much more difficult. you will have to have multiple paths simulated in tandem. more complex elements, like capacitors, would also be problematic to implement. that's no reason to not give it a shot, though =)
Title: Re: [AXE] electricity simulator
Post by: stevon8ter on November 29, 2012, 03:41:27 pm
a good place to start with this would be implementing a linked list data structure. once you have that working, you're going to need to decide on what different attributes to have defined for each possible element (i.e., how long is the current stalled when passing through, what resistance level is there, what's the minimal voltage for it to work, etcetera). then, as long as you aren't looking for too much accuracy, and if each element is connected to only one other, it should be pretty easy. as soon as you start adding in branching and merging paths, however, things will get much more difficult. you will have to have multiple paths simulated in tandem. more complex elements, like capacitors, would also be problematic to implement. that's no reason to not give it a shot, though =)
Yeah i'll have to make some lists and then i'll have them store all the data, all components are in after eachother, i guess i'll figure it out once ;p

How do i create a 384 hex elements that are all the same without having to hardcode the thing?

So not: [0000000000000....

And also not: [00-> gdb0
For(A,0,384
00-> {gdb0 + A}
End
Cause that could corrupt the other ram...
Is there a possible way?
Title: Re: [AXE] electricity simulator
Post by: Keoni29 on November 29, 2012, 04:41:08 pm
Buff(384)->GDB0
Title: Re: [AXE] electricity simulator
Post by: stevon8ter on November 29, 2012, 05:01:41 pm
Ok thx ;3
Title: Re: [AXE] electricity simulator
Post by: tr1p1ea on November 29, 2012, 06:35:49 pm
Actually this is a really neat idea for a project. I can see this being extremely valuable for students and enthusiasts alike.

Title: Re: [AXE] electricity simulator
Post by: TheMachine02 on November 30, 2012, 11:32:52 am
here what I am thinking. If you don't understand something, just ask.

Title: Re: [AXE] electricity simulator
Post by: Lionel Debroux on November 30, 2012, 11:56:41 am
Quote
With analog electronics you have to deal with impedances, transitions, tresholds, phasors, etc. I bet a TI84+ is not strong enough to handle that.
On the contrary, considering that my father simulated some analog electronics - and IIRC, not just RLC circuits - on a HP-41C, about two decades ago, I'd bet that a TI-Z80 can handle quite a number of things ;)
The HP-41C's processor is clocked at least an order of magnitude slower than the 6(-15) MHz Z80 of the 83+ family, and the 83+ family has at least two orders of magnitude more RAM.
Of course, the TI-68k series, the Prizm and the Nspire series could do better than the 83+ family.
Title: Re: [AXE] electricity simulator
Post by: Keoni29 on November 30, 2012, 12:10:26 pm
Stevon8er, have you ever used LTspice? When you simulate you can pick a node or a component and measure respectively voltage or current. No need to simulate the whole circuit every cycle. (unless you do a frequency sweep)
Title: Re: [AXE] electricity simulator
Post by: stevon8ter on November 30, 2012, 12:14:55 pm
No i didn't, but it's actually a wrong tittle, it's not really a simulation but it's drawing a circuit, and then giving the values (like U, I, R, Xl , Xc , f , ...) and after that it calculates it for you

so instead of using input fields for getting the vars, it asks you to draw it and give the values... it's just a funnier way of learning/ solving formulas
Title: Re: [AXE] electricity simulator
Post by: Keoni29 on November 30, 2012, 12:17:07 pm
When you let it "calculate" for you it simulates the behaviour of the circuit right?
Title: Re: [AXE] electricity simulator
Post by: stevon8ter on November 30, 2012, 12:19:45 pm
Not really, euhm let me explain it a bit... so you give a source... to that source you add a value... after it has enough values... it starts calculating and on the missing places it puts the calculated answer... that's it... after that it's done... (or you could edit the values and recalculate)
Title: Re: [AXE] electricity simulator
Post by: Keoni29 on November 30, 2012, 01:40:57 pm
Like this?
Title: Re: [AXE] electricity simulator
Post by: stevon8ter on November 30, 2012, 01:41:47 pm
yes, but then with more complex drawings and more vars (like frequency etc...)

EDIT: maybe i could do it so, that user can go to another screen, where the sin-function of the circuit is drawn... idk, maybe i could add that lol :p
Title: Re: [AXE] electricity simulator
Post by: Keoni29 on November 30, 2012, 01:55:24 pm
Good luck with that.
Title: Re: [AXE] electricity simulator
Post by: stevon8ter on November 30, 2012, 01:57:22 pm
Yeah probably won't work but whatever xD
Title: Re: [AXE] electricity simulator
Post by: leafy on November 30, 2012, 03:05:53 pm
It might be easier to do this in BASIC, because it actually has support for floating point (assuming non-integral values, which is sometimes the case)
Title: Re: [AXE] electricity simulator
Post by: stevon8ter on November 30, 2012, 04:18:00 pm
Hmmmm that's actually true, but then if i'dd try to visualize it, it's a lot harder...
Isn't there a way to add basic progs + their outputs to an axe program?
Or maybe something like grammer can do... Start up the program... But values declared by the axe program?
Title: Re: [AXE] electricity simulator
Post by: shmibs on November 30, 2012, 04:43:51 pm
you can always use the old 12:prgmBLAH approach that all the hybrid programs of old used, performing functions in an axe program that reads values from BASIC variables.
Title: Re: [AXE] electricity simulator
Post by: stevon8ter on November 30, 2012, 04:48:34 pm
How do you mean? Could you explain it a bit?
Title: Re: [AXE] electricity simulator
Post by: Keoni29 on November 30, 2012, 05:39:12 pm
Or use basic with libs to enhange gfx :)
Title: Re: [AXE] electricity simulator
Post by: stevon8ter on November 30, 2012, 05:42:46 pm
Could do that, only problem is that one would need xlib for example

But whatever we'll see what happens :p
Title: Re: [AXE] electricity simulator
Post by: Xeda112358 on November 30, 2012, 06:53:29 pm
You can make an asm library that is a program :P You've probably seen a bazillion of mine. Basically what I think they mean is that you can make an Axe program that handles all the graphics based on input from a BASIC program.
Title: Re: [AXE] electricity simulator
Post by: shmibs on November 30, 2012, 07:55:35 pm
yeah ^^
Axe can access all of the basic variables, including Ans, pretty easily, so passing values to a program shouldn't take too much work. using something like Batlib would probably be a better idea, though.
Title: Re: [AXE] electricity simulator
Post by: stevon8ter on December 01, 2012, 07:56:05 am
So it's too hard to use floats in axe...?
Title: Re: [AXE] electricity simulator
Post by: Xeda112358 on December 01, 2012, 07:57:33 am
Yes, without using bcalls which would require using opcodes.
Title: Re: [AXE] electricity simulator
Post by: Keoni29 on December 01, 2012, 07:58:57 am
Too bad axe doesn't support true inline AMS yet. Only opcodes.
Title: Re: [AXE] electricity simulator
Post by: aeTIos on December 01, 2012, 07:59:00 am
errm... <_< I think someone made an axiom for floating point.
And it's not tooo hard to create a bunch of FP routines in axe.
Title: Re: [AXE] electricity simulator
Post by: willrandship on December 01, 2012, 08:14:24 am
There are internal fixed-point decimals, iirc. How much precision do you really need? Surely not 9 bytes.
Title: Re: [AXE] electricity simulator
Post by: aeTIos on December 01, 2012, 08:15:46 am
if possible you can even just multiply by 10 to get one decimal.
Title: Re: [AXE] electricity simulator
Post by: Keoni29 on December 01, 2012, 08:16:30 am
Maybe millivolts and tenths of milliamperes are sufficiently small increments?
Title: Re: [AXE] electricity simulator
Post by: stevon8ter on December 01, 2012, 08:24:36 am
There are internal fixed-point decimals, iirc. How much precision do you really need? Surely not 9 bytes.

I think it could be a number like: 999,99   I don't think i'll need more
Title: Re: [AXE] electricity simulator
Post by: Keoni29 on December 01, 2012, 08:27:26 am
Well from a programmers perspective you can have numbers up to 0-65535 or 0-655,35 with the standard 16 bit resolution (unsigned) or -32767 to 32767 or -327,67 to 327,67 (signed)
Title: Re: [AXE] electricity simulator
Post by: stevon8ter on December 01, 2012, 08:39:58 am
How would i do the standard 16bit then? How would i make a float out of them?
Title: Re: [AXE] electricity simulator
Post by: willrandship on December 01, 2012, 08:51:57 am
You wouldn't be using floats. You would be using an integer, and knowing that the integer is actually the number*1000 (thus, 1.010 amps would be stored as the integer 1010)
Title: Re: [AXE] electricity simulator
Post by: stevon8ter on December 01, 2012, 08:53:29 am
Yes but how could i in example display the "float"?
Title: Re: [AXE] electricity simulator
Post by: willrandship on December 01, 2012, 08:55:46 am
The easiest way that occurs to me is this:
Store the number divided by 1000 in another var, here I'll call it A.
Display A
Display a .
Display number-(A*1000)
Title: Re: [AXE] electricity simulator
Post by: aeTIos on December 01, 2012, 08:58:24 am
say you have the number 125,3 stored as 1253 then you would first divide by 10, store it to a var (let's say, A) then subtract A*10 from 1253 to get the decimal part.

edit: ninja'd D:
Title: Re: [AXE] electricity simulator
Post by: Xeda112358 on December 01, 2012, 08:59:51 am
Something like this:
Code: [Select]
Text(0,0,A/100>Dec
Text(".")
Text(A^100>Dec

EDIT: Accidentally hit post before XD
Title: Re: [AXE] electricity simulator
Post by: stevon8ter on December 01, 2012, 09:01:57 am
Erhm you're last sentence i read as: substract 1253 from 1253

EDIT: read it as 1253 -1250 :p thx guys

But now there: __125.___3

Where _ = space