-
Notifications
You must be signed in to change notification settings - Fork 842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ac simulation #4076
base: develop
Are you sure you want to change the base?
Ac simulation #4076
Conversation
This is great work. Thank you! |
Thanks @DanielBarie ! We are trying to merge it into the official code, but it could take a while. Please, feel free to give feedback on the branch. :-) |
Thank you. That's excellent news. |
I just found your paper (Learning Hands-On Electronics from Home: |
Add instructions to be able to submit sketches
…spice (if not the prefix is ignored). There are two u symbols in unicode and only one of them was being replaced.
…nterp option to interpolate results in tran analysis.
…o signals and dispay volt/s and time/s in oscilloscope in BB view
… is no ground symbol, the simulator cannot find the ground. This creates problems when requesting voltages at node 0, as ngspice cannot return the voltage at node 0. This commit fixes this by trying to find an isolated negative power supply if it has not found one before.
… is not connected
…osing horizontal resolution
…is necessary to allow setting negative offsets in the oscilloscope part
…g time. This shows the LED, multimeters and others components at the max simulated time
…lating as the oscilloscope part was modified (screen is now balck and the screen is a bit smaller to allow us to place labels and axes)
…y is not found when generating the spice netlist.
… details of the error and the details can be copied to the clipboard. Before the dialog height was bigger than the screen height for long netlists. The Dialog is based on QBoxMessage instead of FBoxMessage.
…perties and added first example with transformer
…ol, the pattern of the validator becomes invalid
…nnected to it. Return a vector with 0s instead of an empty vector (in case that we ask for the voltage of the ground)
…ion to show transitory behaviours
3f5e5c9
to
2701e68
Compare
@@ -69,7 +69,7 @@ Simulator::Simulator(MainWindow *mainWindow) : QObject(mainWindow) { | |||
|
|||
QSettings settings; | |||
int enabled = settings.value("simulatorEnabled", 0).toInt(); | |||
enable(enabled); | |||
enable(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is now save to remove that setting entirely. If there are no objections, I'll to that for 1.0.3
While on it, will it make sense to have a switch between DC and transient analysis?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am OK with removing the enable simulator setting.
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, as soon as there is an oscilloscope, the transitory analysis is used. Before the trans analysis only made sense with the oscilloscope as there was no animation. Since I added the animation, users could use the LEDs in the breadboard to see the effects on their circuits.
So, yes, maybe it is a good idea to add the trans analysis as an option in the simulate button. However, in that case, how do we specify the simulation time?
Could you implement the button? The last time I played with adding buttons took me ages to make it correctly.
|
||
std::cout << std::endl; | ||
return svg; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this and other methods might be better placed in items/oscilloscope.cpp or similar.
So, we'd create an Oscilloscope class, that can display probe and comVectors ... in the future it could also hold code to act on buttons and knobs.
Is there a specific reason it has to be here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I also thought about that several times. I can create an oscilloscope item and move that code there.
(cherry picked from commit 38e4fb6)
@KjellMorgenstern , regarding the electrolytic capacitors in the example (flipflop_led_flashing_circuit), I took this circuit from internet. Simulation says that they get -0.76V and that is why they show smoke. If I remember correctly I set a threshold of 0.5V to consider it a failure. I have to try this in reality. Probably, we could just increase the threshold to avoid the smoke. I think that less than 1V is OK. |
…ating transitory circuits
…gnal to avoid problems when swapping parts
…d now internal resistance can be changed in power supplies
…ile sim analysis is still on going. Adapt the the speed of the animation to the user´s value if the animation takes too long.
… lab power supplies. Add max current as property to change in lab power supplies. Added behavioral sources as valid spice type. WARNING: lab power supplies need lo load the analog code mode.. Right now, the code mode should be in the CWD as the executable. TODO: Check for several paths to find the code models.
c00d04f
to
a7811ba
Compare
void updatePotentiometer(unsigned long, ItemBase *); | ||
void updateDcMotor(unsigned long, ItemBase *); | ||
void updateIRSensor(unsigned long, ItemBase *); | ||
void updateBattery(unsigned long, ItemBase *); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please set your editor to use single tabs, not fours spaces, for indentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will you replace all the spaces to tabs? |
I have been working a few weeks on this and it is time for feedback. I do not want to keep working without knowing that I am going in the right direction and that the code will be merged in the future.
To use this branch, you also need the pull request from the fritzing-parts repository, which contains the oscilloscope, pulse generators and others.
In general, I think it is working quite well. Even long simulations (20s) are quite fast (I have also been working with simple circuits). To use it, you just need to add an oscilloscope and the simulator will simulate a transitory analysis instead a operation point analysis. The transitory analysis simulates until the maximum time that can be shown in any of the oscilloscopes (calculated based on the horizontal position of the oscilloscope and the horizontal scale: time/division). From the time that needs to be shown (in any of the oscilloscopes) to the end time, the simulator generates a fix amount of data (now it is set to 400 SimSteps). This defines the simulation step size. After the simulator is performed, the oscilloscope signals are retrieved and plotted. The status of all the components is shown as at the end of the simulation (LED lights, smokes, etc.).
TODO: