fritzing / fritzing-parts

Electronic components for use in the Fritzing app (aka the parts library)
http://fritzing.org/parts
Other
505 stars 358 forks source link

Photocell does not support zero luminance #373

Closed KjellMorgenstern closed 1 year ago

KjellMorgenstern commented 1 year ago

image

Log:

"Netlist exporter: Trying to identify the negative connection of a power supply as ground"
"Netlist exporter: ground NOT found. The ground has been connected to the following connectors"
"ground set in:  cid:connector1 cname:V Probe title:Multimeter (Ohmmeter) id:59240 type:0 inst:VM1 vlid:9 vid:2 spec:0 flg:0 hy:0 bus:0 r:0 sw:0 pos:(18 63)"
"ground set in:  cid:connector1 cname:pin 1 title:Photocell (LDR) id:61940 type:0 inst:R3 vlid:9 vid:2 spec:0 flg:0 hy:0 bus:0 r:0 sw:0 pos:(126 45)"
"net cid:connector1 cname:V Probe title:Multimeter (Ohmmeter) id:59240 type:0 inst:VM1 vlid:9 vid:2 spec:0 flg:0 hy:0 bus:0 r:0 sw:0 pos:(18 63)"
"net cid:connector1 cname:pin 1 title:Photocell (LDR) id:61940 type:0 inst:R3 vlid:9 vid:2 spec:0 flg:0 hy:0 bus:0 r:0 sw:0 pos:(126 45)"
"_______________"
"net cid:connector0 cname:COM Probe title:Multimeter (Ohmmeter) id:59240 type:0 inst:VM1 vlid:9 vid:2 spec:0 flg:0 hy:0 bus:0 r:0 sw:0 pos:(9 63)"
"net cid:connector0 cname:pin 0 title:Photocell (LDR) id:61940 type:0 inst:R3 vlid:9 vid:2 spec:0 flg:0 hy:0 bus:0 r:0 sw:0 pos:(80.9994 45)"
"_______________"
"spice VM1 {net connector1}A {net connector0} DC 1.5\nR{instanceTitle} {net connector1}A {net connector1} 100\n"
"spice VM1 0A {net connector0} DC 1.5\nR{instanceTitle} {net connector1}A {net connector1} 100\n"
"spice VM1 0A 1 DC 1.5\nR{instanceTitle} {net connector1}A {net connector1} 100\n"
"spice VM1 0A 1 DC 1.5\nRVM1 {net connector1}A {net connector1} 100\n"
"spice VM1 0A 1 DC 1.5\nRVM1 0A {net connector1} 100\n"
"spice VM1 0A 1 DC 1.5\nRVM1 0A 0 100\n"
"spice R3 {net connector0} {net connector1} {(({luminance}/0.01)**(log({light resistance @100lx}/{dark resistance @0.01lx})/ln(10)/4))*{dark resistance @0.01lx}}\n"
"spice R3 1 {net connector1} {(({luminance}/0.01)**(log({light resistance @100lx}/{dark resistance @0.01lx})/ln(10)/4))*{dark resistance @0.01lx}}\n"
"spice R3 1 0 {(({luminance}/0.01)**(log({light resistance @100lx}/{dark resistance @0.01lx})/ln(10)/4))*{dark resistance @0.01lx}}\n"
"spice R3 1 0 {((0/0.01)**(log({light resistance @100lx}/{dark resistance @0.01lx})/ln(10)/4))*{dark resistance @0.01lx}}\n"
"spice R3 1 0 {((0/0.01)**(log(400/{dark resistance @0.01lx})/ln(10)/4))*{dark resistance @0.01lx}}\n"
"spice R3 1 0 {((0/0.01)**(log(400/300k)/ln(10)/4))*{dark resistance @0.01lx}}\n"
"spice R3 1 0 {((0/0.01)**(log(400/300k)/ln(10)/4))*300k}\n"
Netlist: Simulator Netlist
VM1 0A 1 DC 1.5
RVM1 0A 0 100
R3 1 0 {((0/0.01)**(log(400/300k)/ln(10)/4))*300k}

.options savecurrents
.OP
*.TRAN 1ms 100ms
* .AC DEC 100 100 1MEG
.END
Running command(remcirc):
Running m_simulator->command('reset'):
SendCharFunc (libId:0): stderr Error: there is no circuit loaded.
-----------------------------------
Running LoadNetlist:
SendCharFunc (libId:0): stdout No compatibility mode selected!
SendCharFunc (libId:0): stdout Circuit: simulator netlist
SendCharFunc (libId:0): stdout Error on line 4 :
SendCharFunc (libId:0): stdout r3 1 0                      inf   
SendCharFunc (libId:0): stdout unknown parameter (inf) 
Error loading the netlist. Probably some SPICE field is wrong, check them.
failiz commented 1 year ago

I guess you modify the properties.xml to be able to set the luminance to 0. In any case, it makes sense to be able to set it to cero and the value of the photoresistor should not go to infinity. The solution is to replace the spice filed to: <line>R{instanceTitle} {net connector0} {net connector1} {{luminance}>0.01?(({luminance}/0.01)**(log({light resistance @100lx}/{dark resistance @0.01lx})/ln(10)/4))*{dark resistance @0.01lx}:{dark resistance @0.01lx}}</line>