Thanks, your solution works. I also tried to make it in different way but it has problem with avg. let instpower=supply*vv1#branch let activepower=avg(instpower) let vout_rms = sqrt(mean(out*out)) let output_power= vout_rms*vout_rms/25 let eff=-1*output_power/activepower let eff_last=length(eff)-1 print eff[eff_last]
I think that this solution is the best, but i am wondering about commented line. You write a comment: let activepower=avg(instpower) $ This does not do what you think it does Thanks for it.I thinking about replacing avg by mean . But i want to calculate this only in range 15us to 20us.
You write a comment: let activepower=avg(instpower) $ This does not do what you think it does Thanks for it.I thinking about replacing avg by mean . But i want to calculate this only in range 15us to 20us.
You write a comment: let activepower=avg(instpower) $ This does not do what you think it does Thanks for it.I thinking about replacing avg by mean .
Thanks, your solution works. I also tried to make it in different way: let instpower=supply*vv1#branch let activepower=avg(instpower) let vout_rms = sqrt(mean(out*out)) let output_power= vout_rms*vout_rms/25 let eff=-1*output_power/activepower let eff_last=length(eff)-1 print eff[eff_last]
Hi, I have problem with measure statement and vectors. .control tran 0.1n 20u 0 0.1n let instpower=supply*vv1#branch let activepower=avg(instpower) meas tran inputpower avg instpower from=15u to=20u meas tran outrms RMS out from=15u to=20u meas tran outpower param='(outrms^2)/25' meas tran efficiency param='100*outpower/inputpower' .endc I get following error: inputpower = -5.102376e+01 from= 1.500000e-05 to= 2.000000e-05 outrms = 3.54502e+01 from= 1.50000e-05 to= 2.00000e-05 measure 'outpower' failed...
Hi, I have problem with measure statement and vectors. .control tran 0.1n 20u 0 0.1n let instpower=supplyvv1#branch let activepower=avg(instpower) meas tran inputpower avg instpower from=15u to=20u meas tran outrms RMS out from=15u to=20u meas tran outpower param='(outrms^2)/25' meas tran efficiency param='100outpower/inputpower' .endc I get following error: inputpower = -5.102376e+01 from= 1.500000e-05 to= 2.000000e-05 outrms = 3.54502e+01 from= 1.50000e-05 to= 2.00000e-05 measure 'outpower' failed...
Hi, I have problem with measure statement and vectors. .control tran 0.1n 20u 0 0.1n let instpower=supplyvv1#branch let activepower=avg(instpower) meas tran inputpower avg instpower from=15u to=20u meas tran outrms RMS out from=15u to=20u meas tran outpower param='(outrms^2)/25' meas tran efficiency param='100outpower/inputpower' .endc I get following error: inputpower = -5.102376e+01 from= 1.500000e-05 to= 2.000000e-05 outrms = 3.54502e+01 from= 1.50000e-05 to= 2.00000e-05 measure 'outpower' failed...
Are you sure that partial can be a local variable (there is only a single copy of the code)? In this way variables are used in build in components like capacitor, inductor. Local variable shouldnt cause problems because it is only output from cm_analog_integrate function in my example this variable is not used. cm_analog_integrate is defined on src/xspice/cm/cm.c which calls cm_static_integrate. You can seen at the end of function this line: *partial = 1.0 / geq; Therefore it is independent for each...
Are you sure that partial can be a local variable (there is only a single copy of the code)? In this way this variables are used in build in components like capacitor, inductor. Local variable shouldnt cause problems because it is only output from cm_analog_integrate function in my example this variable is not used. cm_analog_integrate is defined on src/xspice/cm/cm.c which calls cm_static_integrate. You can seen at the end of function this line: *partial = 1.0 / geq; Therefore it is independent...
Are you sure that partial can be a local variable (there is only a single copy of the code)? In this way this variables are used in build in components like capacitor, inductor. Local variable shouldnt cause problems because it is only output from cm_analog_integrate function in my example this variable is not used. cm_analog_integrate is defined on src/xspice/cm/cm.c which calls cm_static_integrate. You can seen at the end of function this line: *partial = 1.0 / geq; Therefore it is independent...
Hi, I discovered problem and i don't know if this is bug or my misunderstading. Presented code is reduced version to show only problem that occurs for simpicity. cfunc.mod void cm_inv_ref_sin(ARGS) { double partial; double *vc; if (INIT) { cm_analog_alloc(VC, sizeof(double)); vc = (double *)cm_analog_get_ptr(0, 0); *vc = 0; } else { vc = (double *)cm_analog_get_ptr(0, 0); } if (ANALYSIS != AC) { cm_analog_integrate(1, vc, &partial); OUTPUT(P) = *vc; PARTIAL(P, P) = 0; //or //cm_analog_auto_partial();...
My post was only information that i am using this macro. I am working with my models. Its not uploaded to any branch at this moment. My intention in previous post was only information, although macro is never used in official branches , it is useful for me.
I used this macro in my own XSPICE models,
Hi, In manual is presented macro for XSPICE, called FIRST_TIMEPOINT but it doesn' exists. It should be corrected in manual. I found that there is another macro named as NEW_TIMEPOINT but not mentioned in manual.
It was only simple example to show memory corruption. In my opinion it should inform that something is wrong. I have more examples which causes memory violation but i must spent some time to reduce netlist. Response from Robert Larice gives exaplanation and solution with another problem. Example: .title KiCad schematic VV1 out GND dc 12 VV1 b GND dc 9 .control let run = 0 set curplot=new set scratch=$curplot setplot $scratch compose points values 100k foreach x $&points alter @vv2[sin] [ 0 10m $x...
It was only simple example to show memory corruption. In my opinion it should inform that something is wrong. I have more examples which causes memory violation but i must spent some time to reduce netlist. Response from Robert Larice gives exaplanation and solution with another problem. Example: .title KiCad schematic VV1 out GND dc 12 VV1 b GND dc 9 .control let run = 0 set curplot=new set scratch=$curplot setplot $scratch compose points values 100k foreach x $&points alter @vv2[sin] [ 0 10m $x...
Thanks for information. This is great. I am working on something similar. I use modified KiCad version to support XSPICE models. I am working on resonant power converters and pfc. At this moment i use XSPICE to create components which emulates software in microcontroller. Your solution with C/C++ compiled code running in externall process, seems useful. I am thinking about coupling ngspice with qemu.
I discovered situation when i have memory violation error. This is simple example: .title KiCad schematic VV1 out GND dc 12 .tran 10n 2m 0m 10n uic .control compose points values 1k 10k 100k let freqvector = vector(length(points)) foreach x $&points alter @vv1[sin] [ 0 10m $x ] let t = 1m+10/$x tran 100n $&t 0 end let xxxx = (tran1.out+1) [[100us,101us]] .endc .end This line causes problem: let xxxx = (tran1.out+1) [[100us,101us]]
Thanks, compose works. compose points values 1 2 3 4 foreach x $&points echo $x end
Thanks, compose works. compose points values 1 2 3 4 foreach x $&points echo $x end
Hi I want to create vector in one line with values assignement. In manual i found this sentence:The procedure is to first allocate a real vector of the appropriate size with either vector(), unitvec(), or [ n1 n2 n3 ... ]. When i try to create vector using last method: let vec = [ 1 2 3] I get error. Is it possible to pass list in foreach loop? Like this: let points = [1k 100k 160k 500k 1Meg 2Meg 3Meg] foreach x points I try to iterate through this vector.
Hi I want to create vector in one line with values. In manual i found this sentence:The procedure is to first allocate a real vector of the appropriate size with either vector(), unitvec(), or [ n1 n2 n3 ... ]. When i try to create vector using last method: let vec = [ 1 2 3] I get error. Is it possible to pass list in foreach loop? Like this: let points = [1k 100k 160k 500k 1Meg 2Meg 3Meg] foreach x points I try to iterate through this vector.
Hi I want to create vector in one line with values. In manual i found this sentence:The procedure is to first allocate a real vector of the appropriate size with either vector(), unitvec(), or [ n1 n2 n3 ... ]. When i try to create vector using last method: let vec = [ 1 2 3] I get error. Is it possible to pass list in foreach loop? Like this: let points = [1k 100k 160k 500k 1Meg 2Meg 3Meg] foreach x points I want to iterate through this vector.
Hi In manual on page 58, i have discovered function: sqr(x). When i try line like this: print sqr(2). I get error: no such function as sqr.
Hi In manual on page 58 function: sqr(x). When i try line like this: print sqr(2). I get error: no such function as sqr.
Thanks. There is only possibility to create vector filled with 1? I cant find alternative version to create zero values vector.
Thanks, it is good example. Script is more complicated, but easy to modify.It works. .title KiCad schematic VV1 in GND sin(3 2.5 1k) RR1 out in 1k CC1 out GND 1nF .control let run = 0 set curplot=new set scratch=$curplot setplot $scratch foreach x 1k 100k 160k 500k 1Meg alter @vv1[sin] [ 3 2.5 $x ] let f = $x let t = 10/f echo $&t tran 100n 1m 0 set run ="$&run" set dt = $curplot setplot $scratch let vout{$run}={$dt}.v(out) if run = 0 let time{$run}={$dt}.time end setplot $dt let run = run + 1 end...
Thanks, it is good example. Script is more complicated by easy to modify.It works. .title KiCad schematic VV1 in GND sin(3 2.5 1k) RR1 out in 1k CC1 out GND 1nF .control let run = 0 set curplot=new set scratch=$curplot setplot $scratch foreach x 1k 100k 160k 500k 1Meg alter @vv1[sin] [ 3 2.5 $x ] let f = $x let t = 10/f echo $&t tran 100n 1m 0 set run ="$&run" set dt = $curplot setplot $scratch let vout{$run}={$dt}.v(out) if run = 0 let time{$run}={$dt}.time end setplot $dt let run = run + 1 end...
I found solution, how to write data without explicit line: .control foreach x 1k 100k 160k 500k 1Meg reset alter @vv1[sin] [ 3 2.5 $x ] let f = $x echo "freq" echo $&f let t = 10/f echo $&t tran 100n $&t 0 set appendwrite write data.raw all end plot tran1.out tran2.out tran3.out tran4.out .endc But it has disadvantages. When i forgot to remove file, it appends data to this file. Is it possible to generate files with different names. For example data1.raw,data2.raw, or include time in file name?
I found solution, how to write data without explicit line: .control foreach x 1k 100k 160k 500k 1Meg reset alter @vv1[sin] [ 3 2.5 $x ] let f = $x echo "freq" echo $&f let t = 10/f echo $&t tran 100n $&t 0 set appendwrite write data.raw all end plot tran1.out tran2.out tran3.out tran4.out .endc
I forgot to remove this line. This line reperents attempts to modify only frequency instead provide vector with amplitude and offset([ 3 2.5 $x ]). There is any other possiblity to write this without explicitly deliver information about plot tran1,tran2, itd.? Because when i add more frequency steps this line will be very long. After every modification of frequency list, write line must be updated. I want to parse this files in python and make Bode plots. This method is used in LTSpice and is supported...
Hi, I have following simple circuit. .title KiCad schematic VV1 in GND sin(3 2.5 1k) RR1 out in 1k CC1 out GND 1nF .control foreach x 1k 100k 160k 500k 1Meg reset alter vv1 $x alter @vv1[sin] [ 3 2.5 $x ] let f = $x echo "freq" echo $&f let t = 10/f tran 100n $&t 0 end plot tran1.out tran2.out tran3.out tran4.out .endc .end I want to write all plots to one file. If it is impossible there is any possibility to write plot to different files?
Hello, I have problem with size of plotted points using pointplot. Plot example in attachments. These dots are very small. In manual i can't find instruction to change it. There is any possibility to do this?
Hello, I have problem with size of plotted points using pointplot. Here is example: These dots are very small. In manual i can't find instruction to change it. There is any possibility to do this?
Thanks, it works: plot v("net-r1-pad1") but plot v('net-r1-pad1') not.
Thanks, it works: plot v("net-r1-pad1")
Hello all, I have problems with plotting node when name is not simply. For example: .title test circuit v1 net-_r1-pad1_ gnd sine(0 1 0.1k 0 0) r1 net-_r1-pad1_ gnd 2k .tran 1u 100m 100u .control .save all run plot v(net-_r1-pad1_) .endc .end It shows: Error: bad v() syntax Manual inform that:If in interactive (16.4.2) or control (16.4.3) mode, node names may either be plain numbers or arbitrary character strings, not starting with a number. It works when i change net name to: netr1pad1. Is it correct...
Hello all, I have problems with plotting node names when name is not simply. For example: .title test circuit v1 net-_r1-pad1_ gnd sine(0 1 0.1k 0 0) r1 net-_r1-pad1_ gnd 2k .tran 1u 100m 100u .control .save all run plot v(net-_r1-pad1_) .endc .end It shows: Error: bad v() syntax Manual inform that:If in interactive (16.4.2) or control (16.4.3) mode, node names may either be plain numbers or arbitrary character strings, not starting with a number. It works when i change net name to: netr1pad1. Is...
On my computer this netlist works without any problems. I copy it and paste here. But when i copy it from this page it not works. After few attempts i discovered that when when i add new line before .tran it work. But without this new line i change ) to +) then it shows: Circuit: .tran 1p 200u 0 1n uic Reducing trtol to 1 for xspice 'A' devices Doing analysis at TEMP = 27.000000 and TNOM = 27.000000 Warning: v1: no DC value, transient time 0 value used Error: no such vector drive Error: no such vector...
On my computer this netlist works without any problems. I copy it and paste here. But when i copy it from this page it not works. After few attempts i discovered that when when i add new line before .tran it work. But without this new line i change ) to +) then it shows: Circuit: .tran 1p 200u 0 1n uic Reducing trtol to 1 for xspice 'A' devices Doing analysis at TEMP = 27.000000 and TNOM = 27.000000 Warning: v1: no DC value, transient time 0 value used Error: no such vector drive Error: no such vector...
On my computer this netlist works without any problems. I copy it and paste here. But when i copy this from this page it not works. After few attempts i discovered that when when i add new line before .tran it work. But without this new line i change ) to +) then it shows: Circuit: .tran 1p 200u 0 1n uic Reducing trtol to 1 for xspice 'A' devices Doing analysis at TEMP = 27.000000 and TNOM = 27.000000 Warning: v1: no DC value, transient time 0 value used Error: no such vector drive Error: no such...
On my computer this netlist works without any problems. I copy it and paste here. But when i copy this from this page it not works. After few attempts i discovered that when when i add new line before .tran it work. But without this new line i change ) to +) then it shows: Circuit: .tran 1p 200u 0 1n uic Reducing trtol to 1 for xspice 'A' devices Doing analysis at TEMP = 27.000000 and TNOM = 27.000000 Warning: v1: no DC value, transient time 0 value used Error: no such vector drive Error: no such...
On my computer this netlist works without any problems. I copy it and paste here. But when i copy this from this page it not works. After few attempts i discovered that when when i add new line before .tran it work. But without this new line i change ) to +) then it shows: Circuit: .tran 1p 200u 0 1n uic Reducing trtol to 1 for xspice 'A' devices Doing analysis at TEMP = 27.000000 and TNOM = 27.000000 Warning: v1: no DC value, transient time 0 value used Error: no such vector drive Error: no such...
On my computer this netlist works without any problems. I copy it and paste here. But when i copy this from this page it not works. After few attempts i discovered that when when i add new line before .tran and change ) to +) then it shows: Circuit: .tran 1p 200u 0 1n uic Reducing trtol to 1 for xspice 'A' devices Doing analysis at TEMP = 27.000000 and TNOM = 27.000000 Warning: v1: no DC value, transient time 0 value used Error: no such vector drive Error: no such vector src Error: no such vector...
On my computer this netlist works without any problems. I copy it and paste here. But when i copy this from this page it not works. After few attempts i discovered that when when i add new line before .tran it works.
Thanks for fast reply. First solution works, but this is only simple example. But what if i want to use my initial conditions. Therefore second reply presents what i want to do but i tested it earlier and it not works. Netlist: .tran 1p 200u 0 1n uic .save all .option rshunt=10e6 .MODEL PowerDiode D( + Vj=.75 + Cjo=175p + Rs=.025 + Eg=1.11 + M=.5516 + N=1 + bv=1800 + Fc=.5 + Ikf=0 + Ibv=20.245m + Is=2.2E-15 + Xti=3 ) c1 src 0 1000u ic=100 v1 drive 0 pulse( 0 5 100u 1n 1n 165.6u 100u) r2 src zas 5mR...
Hello all, Recently i spend some time to build my own switch to smps controller. I rely on aswitch model as base to my modifications. Then i discover line that i'm wondering. File cfunc.mod Line 171: PARTIAL(out,out) = pi_pvout; / Signs are required / Why these line is here? This partial derivative havn't sense. When cm_analog_auto_partial function is used then MIFauto_partial not calculate out derivative with regard to out. Only out with regard to input. I think it proofs that this line can be removed....
I have simple circuit with switch and diode. This elements are powered from capacitor with initial voltage. Netlist: .tran 1p 200u 0 1n uic .save all .option rshunt=10e6 .MODEL PowerDiode D( + Vj=.75 + Cjo=175p + Rs=.025 + Eg=1.11 + M=.5516 + N=1 + bv=1800 + Fc=.5 + Ikf=0 + Ibv=20.245m + Is=2.2E-15 + Xti=3 ) .ic v(src) = 100 c1 src 0 1000u v1 drive 0 pulse( 0 5 100u 1n 1n 165.6u 100u) r2 src zas 5mR rshunt sens gnd 1m am1 %vd drive gnd %gd (zas sens) aswitch_mm1 dd4 sens zas PowerDiode .model aswitch_mm1...
I have simple circuit with switch and diode. This elements are powered from capacitor with initial voltage. Netlist: .tran 1p 200u 0 1n uic .save all .option rshunt=10e6 .MODEL PowerDiode D( + Vj=.75 + Cjo=175p + Rs=.025 + Eg=1.11 + M=.5516 + N=1 + bv=1800 + Fc=.5 + Ikf=0 + Ibv=20.245m + Is=2.2E-15 + Xti=3 ) .ic v(src) = 100 c1 src 0 1000u v1 drive 0 pulse( 0 5 100u 1n 1n 165.6u 100u) r2 src zas 5mR rshunt sens gnd 1m am1 %vd drive gnd %gd (zas sens) aswitch_mm1 dd4 sens zas PowerDiode .model aswitch_mm1...
I have simple circuit with switch and diode. This elements are powered from capacitor with initial voltage. Netlist: .tran 1p 200u 0 1n uic .save all .option rshunt=10e6 .MODEL PowerDiode D( + Vj=.75 + Cjo=175p + Rs=.025 + Eg=1.11 + M=.5516 + N=1 + bv=1800 + Fc=.5 + Ikf=0 + Ibv=20.245m + Is=2.2E-15 + Xti=3 ) .ic v(src) = 100 c1 src 0 1000u v1 drive 0 pulse( 0 5 100u 1n 1n 165.6u 100u) r2 src zas 5mR rshunt sens gnd 1m am1 %vd drive gnd %gd (zas sens) aswitch_mm1 dd4 sens zas PowerDiode .model aswitch_mm1...
I have simple circuit with switch and diode. This elements are powered from capacitor with initial voltage. Natlist: .tran 1p 200u 0 1n uic .save all .option rshunt=10e6 .MODEL PowerDiode D( + Vj=.75 + Cjo=175p + Rs=.025 + Eg=1.11 + M=.5516 + N=1 + bv=1800 + Fc=.5 + Ikf=0 + Ibv=20.245m + Is=2.2E-15 + Xti=3 ) .ic v(src) = 100 c1 src 0 1000u v1 drive 0 pulse( 0 5 100u 1n 1n 165.6u 100u) r2 src zas 5mR rshunt sens gnd 1m am1 %vd drive gnd %gd (zas sens) aswitch_mm1 dd4 sens zas PowerDiode .model aswitch_mm1...
Return type corrections
Sleep modeas added
Added file needed to interrupts
Iomanager created for spi
Iomanager created for spi
Iomanager created for spi
Iomanager created for spi
Serial port works with interrupts
Serial port works with interrupts
Vector table update
Usart works in polling mode
Usart works in polling mode
Usart works in polling mode
Usart works in polling mode
Repaired frequency calculations for ahb, apb1,...
Clock calculations update, not tested
Clock calculations update, not tested
IOManager implemented with serials
IOManager implemented with serials
IOManager implemented with serials
IOManager implemented with serials
Led blinking works!!! and clock configuration p...
Core port compilation problem resloved
Porting progress, gpio done, core in progress
Porting progress, gpio done, core in progress
Porting progress, gpio done, core in progress
Porting progress, gpio done, core in progress
Porting progress, gpio done, core in progress
Included gpio header for stm32f3xx
New CMSIS 4.5.0
Old CMSIS removed
New main for testing
New main for testing
BSp for new board
Port for stm32f373 first steps
Structure of directories and first files
BSP for windows update, example with continuous...
Updated example, setbaudrate added
Microhal configured as externals with new i2c api
Display all data on console(rpm,scaled force,rp...
Display all data on console(rpm,scaled force,rp...
Progress
Progress
Progress and cleaning
Drobne dodatki