Have a nice day. I have a pca9685 controller. When I try to read and write I get the error errno 6.
root#orangepipc:~/wiringOP# i2cdetect -y 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: 70 -- -- -- -- -- -- --
root#orangepipc:~/wiringOP# i2cdump -y 0 40
No size specified (using byte-data access)
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
10: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
20: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
30: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
40: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
50: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
60: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
70: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
80: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
90: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
a0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
b0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
c0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
d0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
e0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
f0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
my code
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <cstdlib>
#include <unistd.h>
#include <pthread.h>
#include <wiringPi.h>
#include <wiringPiI2C.h>
#include <errno.h>
using namespace std;
int main()
{
string addr = "/dev/i2c-0";
int fd = wiringPiI2CSetupInterface(addr.c_str(), 40);
if (fd < 0)
printf("wiringPiI2CSetupInterface errno %d\n", errno);
int wr8 = wiringPiI2CWriteReg8(fd, 0x00, 0x00);
if (wr8 < 0)
printf("wiringPiI2CWriteReg8 errno %d\n", errno);
int wr16 = wiringPiI2CWriteReg16(fd, 0x00, 0x00);
if (wr16 < 0)
printf("wiringPiI2CWriteReg16 errno %d\n", errno);
int r8 = wiringPiI2CReadReg8(fd, 0x00);
if (r8 < 0)
printf("wiringPiI2CReadReg8 errno %d\n", errno);
int r16 = wiringPiI2CReadReg16(fd, 0x00);
if (r16 < 0)
printf("wiringPiI2CReadReg16 errno %d\n", errno);
close(fd);
}
console output
wiringPiI2CWriteReg8 errno 6
wiringPiI2CWriteReg16 errno 6
wiringPiI2CReadReg8 errno 6
wiringPiI2CReadReg16 errno 6
I also have a gy521 which behaves exactly the same.
Can this behavior signal a microcomputer i2c bus failure?
Can determining the address of the connected controller ensure that the microcomputer's i2c bus is working properly?
Maybe I'm doing something wrong?
I could not find information about errno 6, please help.
I thought that I did not install the wiringpi correctly, reinstalled several times, different versions.
Related
I have successfully compiled the following repository pisces with ubuntu 20.04.
https://github.com/ComputerWhisperer/pisces
I used gcc-5 and gfortran-5 at compile time.
Then, I ran mosfet.p2 with pisces from the pdf of the following university (Sorry, in japanese).
http://www.nuee.nagoya-u.ac.jp/labs/nakazatolab/nakazato/2005Lids/Lids3.pdf
(mosfet.p2)
Title Short Channel (L = 1.5 um) MOSFET
mesh infile = ldd.mesh geom
symb gummel carr = 1 electrons
method iccg damped
mater num = 4 g.surf = 0.75
contact num = 1 n.poly
models conmob temp = 300 fldmob print
solve initial
solve v1 = 0.6 vstep = 0.6 nsteps = 2 electrode = 1
log outf = log
solve v1 = 1.8
symb newton carriers = 1 electrons
method itlimit = 50 autonr
solve v2 = 0.1 vstep = 0.1 nsteps = 17 electrode = 2
plot.1d x.axis = v2 y.axis = i2
end
But,
solve initial
At that point, the device simulation is interrupted.
Screen output.
********* PISCES-II Device Modeling Program *********
(Version 9009-S.0523 SunOS 4.1)
Date and time = 20-May-21 14:55:39
1 ... Title Short Channel (L = 1.5 um) MOSFET
2 ... mesh infile = ldd.mesh geom
3 ... symb gummel carr = 1 electrons
4 ... method iccg damped
5 ... mater num = 4 g.surf = 0.75
6 ... contact num = 1 n.poly
7 ... models conmob temp = 300 fldmob print
8 ... solve initial
9 ... solve v1 = 0.6 vstep = 0.6 nsteps = 2 electrode = 1
10 ... log outf = log
11 ... solve v1 = 1.8
12 ... symb newton carriers = 1 electrons
13 ... method itlimit = 50 autonr
14 ... solve v2 = 0.1 vstep = 0.1 nsteps = 17 electrode = 2
15 ... plot.1d x.axis = v2 y.axis = i2
16 ... end
*******************************
Short Channel (L = 1.5 um) MOSFET
*******************************
Read geometry from file ldd.mesh
Mesh statistics:
Total grid points = 2273
Total no. of triangles = 4310
Obtuse triangles = 539 (12.5%)
** Warning in line # 5
Invalid parameter specified for an insulator! 36
Gummel method carriers = 1 Electrons
Constants:
Boltzmanns k = 8.61700E-05
charge = 1.60200E-19
permittivity = 8.85400E-14
Temperature = 300.
Thermal voltage = 0.025851
Material data:
Num Type Rel Permit
1 1 11.80
2 -1 3.90
3 -1 3.90
4 -1 3.90
5 -1 3.90
Semiconductor data:
type = 1.0000
rel permit = 11.800
log10 (ni) = 10.160
n-mobility = 1000.0
p-mobility = 500.00
vsat = 1.03494E + 07
taup0 = 1.00000E-07
taun0 = 1.00000E-07
egap (300) = 1.0800
egalpha = 4.73000E-04
egbeta = 636.00
affinity = 4.1700
egap = 1.0800
cnau = 2.80000E-31
cpau = 9.90000E-32
An ** = 110.00
Ap ** = 30.000
Nc = 2.80000E + 19
Nv = 1.04000E + 19
gcb = 2.0000
gvb = 4.0000
edb = 4.40000E-02
eab = 4.50000E-02
Contacts:
Num Work fn. Vsurfn Vsurfp Resistance Capacitance
1 4.170 0.000000E + 00 0.000000E + 00 0.000000E + 00 0.000000E + 00
2 0.000 0.000000E + 00 0.000000E + 00 0.000000E + 00 0.000000E + 00
3 0.000 0.000000E + 00 0.000000E + 00 0.000000E + 00 0.000000E + 00
4 0.000 0.000000E + 00 0.000000E + 00 0.000000E + 00 0.000000E + 00
5 0.000 0.000000E + 00 0.000000E + 00 0.000000E + 00 0.000000E + 00
Model flags:
SRH recombination = F
Conc. dep. lifetime = F
Auger recombination = F
Band-gap narrowing = F
Conc. Dep. Mobility = T
Field dep. Mobility = T
CCS dep. mobility = F
Analytic mobility = F
Arora mobility = F
Trans. E. mobility = F
Impact Ionization = F
Cylindrical coords = F
Photogeneration = F
Mobility model parameters:
Gsurf = 7.500000E-01
B.elect = 2.000000E + 00
B.hole = 1.000000E + 00
Internal error in vmin / vmax calculation, elect = 4
nb = 107 nelect = 5
** Internal error occurs when executing solve initial.
In addition, suprem is
https://github.com/cogenda/Suprem4
I made it with the master branch of.
Above
http://www.nuee.nagoya-u.ac.jp/labs/nakazatolab/nakazato/2005Lids/Lids3.pdf
From
I edited and ran ldd.s4 to create ldd.mesh.
(ldd.s4)
line x loc = 0.0 tag = lft spacing = 0.25
line x loc = 0.45 spacing = 0.03
line x loc = 0.75 spacing = 0.03
line x loc = 1.4 spacing = 0.25
line x loc = 1.5 tag = rht spacing = 0.25
line y loc = 0.0 tag = top spacing = 0.01
line y loc = 0.1 spacing = 0.01
line y loc = 0.25 spacing = 0.05
line y loc = 3.0 tag = bot
region silicon xlo = lft xhi = rht ylo = top yhi = bot
bound exposed xlo = lft xhi = rht ylo = top yhi = top
bound backside xlo = lft xhi = rht ylo = bot yhi = bot
init boron conc = 1.0e16
deposit oxide thick = 0.025
implant boron dose = 1.0e12 energy = 15.0
deposit poly thick = 0.50 div = 10 phos conc = 1.0e19
diff time = 10 temp = 1000
etch poly right p1.x = 0.55 p1.y = -0.020 p2.x = 0.45 p2.y = -0.55
diffuse time = 30.0 temp = 950
implant phos dose = 1.0e13 energy = 50.0
deposit oxide thick = 0.400 spac = 0.05
etch dry oxide thick = 0.420
method vert fermi grid.ox = 0.0
diffuse time = 30 temp = 950 dry
implant ars dose = 5.0e15 energy = 80.0
deposit oxide thick = 0.15 space = 0.03
diffuse time = 20 temp = 950
#put down the aluminum
deposit alum thick = 0.1
#reflect the structure
struct mirror left
#etch off aluminum
etch alum start x = -1.4 y = 0.1
etch continue x = 1.4 y = 0.1
etch continue x = 1.4 y = -0.7
etch done x = -1.4 y = -0.7
plot.2d boundary
#save it in Pisces format
struct pisces = ldd.mesh
In order for pisces not to output an Internal error
What should I do with solve initial in mosfet.p2?
Changed ldd.s4 as follows.
(ldd.s4)
line x loc = 0.0 tag = lft spacing = 0.25
line x loc = 0.45 spacing = 0.03
line x loc = 0.75 spacing = 0.03
line x loc = 1.4 spacing = 0.25
line x loc = 1.5 tag = rht spacing = 0.25
line y loc = 0.0 tag = top spacing = 0.01
line y loc = 0.1 spacing = 0.01
line y loc = 0.25 spacing = 0.05
line y loc = 3.0 tag = bot
region silicon xlo = lft xhi = rht ylo = top yhi = bot
bound exposed xlo = lft xhi = rht ylo = top yhi = top
bound backside xlo = lft xhi = rht ylo = bot yhi = bot
init boron conc = 1.0e16
deposit oxide thick = 0.025
implant boron dose = 1.0e12 energy = 15.0
deposit poly thick = 0.50 div = 10 phos conc = 1.0e19
diff time = 10 temp = 1000
etch poly right p1.x = 0.55 p1.y = -0.020 p2.x = 0.45 p2.y = -0.55
diffuse time = 30.0 temp = 950
implant phos dose = 1.0e13 energy = 50.0
deposit oxide thick = 0.400 spac = 0.05
etch dry oxide thick = 0.420
method vert fermi grid.ox = 0.0
diffuse time = 30 temp = 950 dry
implant ars dose = 5.0e15 energy = 80.0
deposit oxide thick = 0.15 space = 0.03
diffuse time = 20 temp = 950
plot.2d bound
struct pisc = ldd.mesh
Then I ran pisces mosfet.p2 and it looks like this:
(pisces ./mosfet.p2)
********* PISCES-II Device Modeling Program *********
(Version 9009-S.0523 SunOS 4.1)
Date and time = 26-May-21 19:38:47
1 ... Title Short Channel (L = 1.5 um) MOSFET
2 ... mesh infile = ldd.mesh geom
3 ... symb gummel carr = 1 electrons
4 ... method iccg damped
5 ... mater num = 4 g.surf = 0.75
6 ... contact num = 1 n.poly
7 ... models conmob temp = 300 fldmob print
8 ... solve initial
9 ... solve v1 = 0.6 vstep = 0.6 nsteps = 2 electrode = 1
10 ... log outf = log
11 ... solve v1 = 1.8
12 ... symb newton carriers = 1 electrons
13 ... method itlimit = 50 autonr
14 ... solve v2 = 0.1 vstep = 0.1 nsteps = 17 electrode = 2
15 ... plot.1d x.axis = v2 y.axis = i2
16 ... end
*******************************
Short Channel (L = 1.5 um) MOSFET
*******************************
Read geometry from file ldd.mesh
Mesh statistics:
Total grid points = 1150
Total no. of triangles = 2154
Obtuse triangles = 269 (12.5%)
** Warning in line # 5
Invalid parameter specified for an insulator! 36
Gummel method carriers = 1 Electrons
Constants:
Boltzmanns k = 8.61700E-05
charge = 1.60200E-19
permittivity = 8.85400E-14
Temperature = 300.
Thermal voltage = 0.025851
Material data:
Num Type Rel Permit
1 1 11.80
2 -1 3.90
3 -1 3.90
4 -1 3.90
5 -1 3.90
Semiconductor data:
type = 1.0000
rel permit = 11.800
log10 (ni) = 10.160
n-mobility = 1000.0
p-mobility = 500.00
vsat = 1.03494E + 07
taup0 = 1.00000E-07
taun0 = 1.00000E-07
egap (300) = 1.0800
egalpha = 4.73000E-04
egbeta = 636.00
affinity = 4.1700
egap = 1.0800
cnau = 2.80000E-31
cpau = 9.90000E-32
An ** = 110.00
Ap ** = 30.000
Nc = 2.80000E + 19
Nv = 1.04000E + 19
gcb = 2.0000
gvb = 4.0000
edb = 4.40000E-02
eab = 4.50000E-02
Contacts:
Num Work fn. Vsurfn Vsurfp Resistance Capacitance
1 4.170 0.000000E + 00 0.000000E + 00 0.000000E + 00 0.000000E + 00
2 0.000 0.000000E + 00 0.000000E + 00 0.000000E + 00 0.000000E + 00
Model flags:
SRH recombination = F
Conc. dep. lifetime = F
Auger recombination = F
Band-gap narrowing = F
Conc. Dep. Mobility = T
Field dep. Mobility = T
CCS dep. mobility = F
Analytic mobility = F
Arora mobility = F
Trans. E. mobility = F
Impact Ionization = F
Cylindrical coords = F
Photogeneration = F
Mobility model parameters:
Gsurf = 7.500000E-01
B.elect = 2.000000E + 00
B.hole = 1.000000E + 00
Solution for bias:
V1 = 0.0000000E + 00 V2 = 0.0000000E + 00
Initial solution
Warning --ICCG not converging
Switching to direct LU for this iteration
p-iter c-iter psi-error n-error p-error
1 2.3432E + 01
Warning --ICCG not converging
Switching to direct LU for this iteration
2 1.0951E + 01
Warning --ICCG not converging
Switching to direct LU for this iteration
3 4.1479E + 00
4 1.1738E + 00
Warning --ICCG not converging
Switching to direct LU for this iteration
5 1.1284 E-01
Warning --ICCG not converging
Switching to direct LU for this iteration
6 1.5466E-03
Warning --ICCG not converging
Switching to direct LU for this iteration
7 1 5.5300E-07 1.1362E-14 0.0000E + 00
8 2 8.7875E-15 2.9333E-15 0.0000E + 00
Electrode Voltage Electron Current Hole Current Conduction Current
(Volts) (amps / micron) (amps / micron) (amps / micron)
1 0.0000 -0.00000E + 00 -0.00000E + 00 -0.00000E + 00
2 0.0000 2.28455E-32 -0.00000E + 00 2.28455E-32
Electrode Flux Displacement Current Total Current
(coul / micron) (amps / micron) (amps / micron)
1 3.46222E-16 0.00000E + 00 0.00000E + 00
2 -1.82419E-26 0.00000E + 00 2.28455E-32
Absolute convergence criterion met for Poisson
Absolute convergence criterion met for continuity
Total cpu time for bias point = 0.06
Total cpu time = 0.08
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
Solution for bias:
V1 = 6.0000002E-01 V2 = 0.0000000E + 00
Previous solution used as initial guess
Warning --ICCG not converging
Switching to direct LU for this iteration
p-iter c-iter psi-error n-error p-error
1 2.3210E + 01
2 2.3356E + 00
3 9.9053E-01
Warning --ICCG not converging
Switching to direct LU for this iteration
4 9.5441 E-01
5 8.1053E-01
Warning --ICCG not converging
Switching to direct LU for this iteration
6 4.6211E-01
7 1.0489E-01
Warning --ICCG not converging
Switching to direct LU for this iteration
8 4.1305E-03
Warning --ICCG not converging
Switching to direct LU for this iteration
9 1 5.9992E-06 1.1531E-14 0.0000E + 00
10 2 6.8864E-15 6.9463E-15 0.0000E + 00
Electrode Voltage Electron Current Hole Current Conduction Current
(Volts) (amps / micron) (amps / micron) (amps / micron)
1 0.6000 -0.00000E + 00 0.00000E + 00 0.00000E + 00
2 0.0000 3.75532E-32 0.00000E + 00 3.75532E-32
Electrode Flux Displacement Current Total Current
(coul / micron) (amps / micron) (amps / micron)
1 6.26181E-16 0.00000E + 00 0.00000E + 00
2 -1.82967E-26 0.00000E + 00 3.75532E-32
Absolute convergence criterion met for Poisson
Absolute convergence criterion met for continuity
Total cpu time for bias point = 0.05
Total cpu time = 0.13
Solution for bias:
V1 = 1.2000000E + 00 V2 = 0.0000000E + 00
Projection used to find initial guess
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
p-iter c-iter psi-error n-error p-error
1 2.3057E + 00
2 9.9999E-01
3 1.8374E + 02
Warning --ICCG not converging
Switching to direct LU for this iteration
4 3.8682 E + 01
5 9.9957E-01
6 9.9857E-01
7 9.9521E-01
8 2.9386E + 00
Warning --ICCG not converging
Switching to direct LU for this iteration
9 2.9 147E + 00
10 8.4660E-01
11 6.1511 E-01
12 2.6687E-01
Warning --ICCG not converging
Switching to direct LU for this iteration
13 3.7334E-02
14 6.3672 E-04
Warning --ICCG not converging
Switching to direct LU for this iteration
15 1 3.4358E-06 1.1966E-14 0.0000E + 00
16 2 5.5567E-15 7.1786E-15 0.0000E + 00
Electrode Voltage Electron Current Hole Current Conduction Current
(Volts) (amps / micron) (amps / micron) (amps / micron)
1 1.2000 -0.00000E + 00 -0.00000E + 00 -0.00000E + 00
2 0.0000 4.54473E-32 -0.00000E + 00 4.54473E-32
Electrode Flux Displacement Current Total Current
(coul / micron) (amps / micron) (amps / micron)
1 1.06838E-15 0.00000E + 00 0.00000E + 00
2 -1.83123E-26 0.00000E + 00 4.54473E-32
Absolute convergence criterion met for Poisson
Absolute convergence criterion met for continuity
Total cpu time for bias point = 0.06
Total cpu time = 0.18
Solution for bias:
V1 = 1.8000001E + 00 V2 = 0.0000000E + 00
Projection used to find initial guess
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
p-iter c-iter psi-error n-error p-error
1 9.7099E-01
2 9.2042E-01
Warning --ICCG not converging
Switching to direct LU for this iteration
3 7.9295E-01
4 5.3167 E-01
5 1.9655E-01
6 2.1050E-02
Warning --ICCG not converging
Switching to direct LU for this iteration
7 2.2976E-03
8 1 2.1611E-08 8.1258E-15 0.0000E + 00
9 2 1.8033E-14 2.9538E-15 0.0000E + 00
Electrode Voltage Electron Current Hole Current Conduction Current
(Volts) (amps / micron) (amps / micron) (amps / micron)
1 1.8000 -0.00000E + 00 0.00000E + 00 0.00000E + 00
2 0.0000 2.47781E-32 0.00000E + 00 2.47781E-32
Electrode Flux Displacement Current Total Current
(coul / micron) (amps / micron) (amps / micron)
1 1.55386E-15 0.00000E + 00 0.00000E + 00
2 -1.83165E-26 0.00000E + 00 2.47781E-32
Absolute convergence criterion met for Poisson
Absolute convergence criterion met for continuity
Total cpu time for bias point = 0.04
Total cpu time = 0.22
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
Solution for bias:
V1 = 1.8000000E + 00 V2 = 0.0000000E + 00
Projection used to find initial guess
p-iter c-iter psi-error n-error p-error
1 1 5.0496E-08 6.5467E-15 0.0000E + 00
Warning --ICCG not converging
Switching to direct LU for this iteration
2 2 5.1730E-09 3.4275E-15 0.0000E + 00
Electrode Voltage Electron Current Hole Current Conduction Current
(Volts) (amps / micron) (amps / micron) (amps / micron)
1 1.8000 -0.00000E + 00 -0.00000E + 00 -0.00000E + 00
2 0.0000 5.78572E-32 -0.00000E + 00 5.78572E-32
Electrode Flux Displacement Current Total Current
(coul / micron) (amps / micron) (amps / micron)
1 1.55386E-15 0.00000E + 00 0.00000E + 00
2 -1.83165E-26 0.00000E + 00 5.78572E-32
Absolute convergence criterion met for Poisson
Absolute convergence criterion met for continuity
Total cpu time for bias point = 0.02
Total cpu time = 0.25
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
** Warning in line # 0
Small pivot had to be fixed during incomplete factorization --ICCG is in difficulty.738
Solution for bias:
V1 = 1.8000000E + 00 V2 = 1.0000000E-01
Previous solution used as initial guess
iter psi-error n-error p-error
1 9.7924E-01 1.1696E + 00 0.0000E + 00
2 9.4461E-01 2.4172E + 00 0.0000E + 00
3 3.5434E + 01 9.7816E-01 0.0000E + 00
4 6.7550E + 00 4.7057E + 00 0.0000E + 00
5 4.3743E + 00 4.7430E + 00 0.0000E + 00
6 2.4091E + 00 6.4758E + 00 0.0000E + 00
7 8.5386E-01 1.7228E + 02 0.0000E + 00
8 9.9325E-02 4.5727E + 01 0.0000E + 00
9 * 9.9125E-02 6.0700E-01 0.0000E + 00
10 5.3139E-02 9.9966E-01 0.0000E + 00
11 * 5.3144E-02 2.3083E-02 0.0000E + 00
12 7.4757E-02 2.0760E-01 0.0000E + 00
13 5.1106E-02 2.2708E-02 0.0000E + 00
14 5.4977E-02 2.4046E-02 0.0000E + 00
15 1.6516E-01 7.1058E-02 0.0000E + 00
16 6.9029E-02 2.8302E-02 0.0000E + 00
17 7.0727E-02 3.0941E-02 0.0000E + 00
18 5.9970E-02 2.7111E-02 0.0000E + 00
19 1.4453E-01 6.3741E-02 0.0000E + 00
20 1.1600E-01 5.0619E-02 0.0000E + 00
21 3.7983E-02 1.6272E-02 0.0000E + 00
22 3.8026E-02 1.7518E-02 0.0000E + 00
23 1.2794E-01 5.8200E-02 0.0000E + 00
24 2.5246E-02 1.3028E-02 0.0000E + 00
25 * 2.5245E-02 1.1592E-02 0.0000E + 00
26 4.6918E-02 2.1424E-02 0.0000E + 00
27 3.3700E-01 1.5601E-01 0.0000E + 00
28 1.2478E-01 6.3979E-02 0.0000E + 00
29 1.1582E-01 5.2105E-02 0.0000E + 00
30 2.5380E-02 1.1970E-02 0.0000E + 00
31 * 2.5378E-02 1.0935E-02 0.0000E + 00
32 8.9952E-02 3.8959E-02 0.0000E + 00
33 6.9398E-02 3.0246E-02 0.0000E + 00
34 7.8585E-02 3.3048E-02 0.0000E + 00
35 3.6101E-02 1.5893E-02 0.0000E + 00
36 4.0608E-02 1.7227E-02 0.0000E + 00
37 1.1913E + 00 5.1002E-01 0.0000E + 00
38 1.6712E + 00 7.6782E-01 0.0000E + 00
39 1.7433E-01 1.0673E + 00 0.0000E + 00
40 * 4.2024E-02 3.2193E-02 0.0000E + 00
41 4.3470E-02 2.8632E-02 0.0000E + 00
42 2.9936E-02 1.8434E-02 0.0000E + 00
43 5.0113E-02 3.0157E-02 0.0000E + 00
44 2.4720E-02 1.5407E-02 0.0000E + 00
45 5.4076E-02 3.2707E-02 0.0000E + 00
46 1.2671E-01 7.7875E-02 0.0000E + 00
47 1.2971E-01 7.5825E-02 0.0000E + 00
48 4.1093E-02 2.2797E-02 0.0000E + 00
49 * 4.1096E-02 2.5519E-02 0.0000E + 00
50 4.1441E-02 2.4940E-02 0.0000E + 00
Electrode Voltage Electron Current Hole Current Conduction Current
(Volts) (amps / micron) (amps / micron) (amps / micron)
1 1.8000 -0.00000E + 00 -0.00000E + 00 -0.00000E + 00
2 0.1000 -5.85968E-18 -0.00000E + 00 -5.85968E-18
Electrode Flux Displacement Current Total Current
(coul / micron) (amps / micron) (amps / micron)
1 8.54356E-16 0.00000E + 00 0.00000E + 00
2 -2.04272E-25 0.00000E + 00 -5.85968E-18
Total cpu time for bias point = 0.54
Total cpu time = 0.81
*** Warning ***
This solution has not converged to the selected tolerances!
Solution for bias:
V1 = 1.8000000E + 00 V2 = 2.0000000E-01
Projection used to find initial guess
iter psi-error n-error p-error
1 5.8878E + 17 5.8989E + 16 0.0000E + 00
2 8.6348E + 18 6.1800E + 00 0.0000E + 00
3 3.4686E + 18 4.8415E + 15 0.0000E + 00
4 1.0680E + 18 1.0000E + 00 0.0000E + 00
** Error in line # 14
Numerical value of pivot # 99 is approximately zero in vmnp routine --no solution possible.
Try a different bias point.
********* PISCES Aborted **********
This time I got an error on line14 of mosfet.p2.
"Try a different bias point."
I don't really understand the meaning.
I will come back again.
Please let me know if you have a reference book (About ldd, etc).
The question is how to convert dates between different representations using integer arithmetic, specifically between a "Days since year zero ( Jan 1, 0000 )" representation, and either Year/Day or Year/Month/Day forms, in the Julian calendar. The different representations are useful for date input, date display and date arithmetic.
Specifically, a date such as June 5th, 2020 is represented in Year/Month/Day representation as
2020 * 512 + 6 * 32 + 5
or in Year/Day representation as
2020 * 512 + 157 ( June 5th is day 157 in a leap year ).
Yesterday, I wanted to write code to do this, and surprisingly didn't find much help online, so I thought I would document my solution here ( I will be answering my own question ).
First here is code for converting from Year/Day to Days ( the language is very similar to Microsoft SQL Server T-SQL, except variable names do not begin with '#', and there is a 'bool" data type ) :
CREATE FUNCTION [date].[YearDayToDays]( yd int ) RETURNS int AS
BEGIN
-- Given a date in Year/Day representation stored as y * 512 + d where 1 <= d <= 366 ( so d is day in year )
-- returns the number of days since "day zero" (1 Jan 0000)
-- using the Gregorian calendar where days divisible by 4 are leap years, except if divisible by 100, except if divisible by 400.
DECLARE y int, d int, cycle int
-- Extract y and d from yd.
SET y = yd / 512, d = yd % 512 - 1
SET cycle = y / 400, y = y % 400 -- The Gregorian calendar repeats every 400 years.
-- Result days come from cycles, from years having at least 365 days, from leap years and finally d.
-- 146097 is the number of the days in a 400 year cycle ( 400 * 365 + 97 leap years ).
RETURN cycle * 146097
+ y * 365
+ ( y + 3 ) / 4 - ( y + 99 ) / 100 + ( y + 399 ) / 400
+ d
END
Now the opposite conversion, Days to Year/Day:
CREATE FUNCTION [date].[DaysToYearDay]( days int ) returns int as
begin
-- Given a date represented by the number of days since 1 Jan 0000
-- calculate a date in Year/Day representation stored as
-- y * 512 + d where d is 1..366
DECLARE y int, d int, cycle int
-- 146097 is the number of the days in a 400 year cycle ( 400 * 365 + 97 leap years )
SET cycle = days / 146097
SET days = days % 146097
SET y = days / 365
SET d = days % 365
-- Need to adjust d to allow for leap years.
-- Leap years are 0, 4, 8, 12 ... 96, not 100, 104 ... not 200... not 300, 400, 404 ... not 500.
-- Adjustment as function of y is 0 => 0, 1 => 1, 2 =>1, 3 => 1, 4 => 1, 5 => 2 ..
SET d = d - ( y + 3 ) / 4 - ( y + 99 ) / 100 + ( y + 399 ) / 400
IF d < 0
BEGIN
SET y = y - 1
SET d = d + CASE WHEN date.IsLeapYear( y ) THEN 366 ELSE 365 END
END
RETURN date.YearDay( cycle * 400 + y, d + 1 )
END
The auxiliary function date.IsLeapYear:
CREATE FUNCTION [date].[IsLeapYear]( y int ) RETURNS bool AS
BEGIN
RETURN y % 4 = 0 AND ( y % 100 != 0 OR y % 400 = 0 )
END
and date.YearDay :
CREATE FUNCTION [date].[YearMonthDay]( year int, month int, day int ) RETURNS int AS
BEGIN
RETURN year * 512 + month * 32 + day
END
Conversion from Year/Day to Year/Month/Day:
CREATE FUNCTION [date].[YearDayToYearMonthDay]( yd int ) returns int AS
BEGIN
DECLARE y int, d int, leap bool, fdm int, m int, dim int
SET y = yd / 512
SET d = yd % 512 - 1
SET leap = date.IsLeapYear( y )
-- Jan = 0..30, Feb = 0..27 or 0..28
IF NOT leap AND d >= 59 SET d = d + 1
SET fdm = CASE
WHEN d < 31 THEN 0 -- Jan
WHEN d < 60 THEN 31 -- Feb
WHEN d < 91 THEN 60 -- Mar
WHEN d < 121 THEN 91 -- Apr
WHEN d < 152 THEN 121 -- May
WHEN d < 182 THEN 152 -- Jun
WHEN d < 213 THEN 182 -- Jul
WHEN d < 244 THEN 213 -- Aug
WHEN d < 274 THEN 244 -- Sep
WHEN d < 305 THEN 274 -- Oct
WHEN d < 335 THEN 305 -- Nov
ELSE 335 -- Dec
END
SET dim = d - fdm
SET m = ( d - dim + 28 ) / 31
RETURN date.YearMonthDay( y, m+1, dim+1 )
END
The auxiliary function date.YearMonthDay:
CREATE FUNCTION [date].[YearMonthDay]( year int, month int, day int ) RETURNS int AS
BEGIN
RETURN year * 512 + month * 32 + day
END
Finally conversion from Year/Month/Day to Year/Day:
CREATE FUNCTION [date].[YearMonthDayToYearDay]( ymd int ) RETURNS int AS
BEGIN
DECLARE y int, m int, d int
-- Extract y, m, d from ymd
SET d = ymd % 32, m = ymd / 32
SET y = m / 16, m = m % 16
-- Incorporate m into d ( assuming Feb has 29 days ).
SET d = d + CASE
WHEN m = 1 THEN 0 -- Jan
WHEN m = 2 THEN 31 -- Feb
WHEN m = 3 THEN 60 -- Mar
WHEN m = 4 THEN 91 -- Apr
WHEN m = 5 THEN 121 -- May
WHEN m = 6 THEN 152 -- Jun
WHEN m = 7 THEN 182 -- Jul
WHEN m = 8 THEN 213 -- Aug
WHEN m = 9 THEN 244 -- Sep
WHEN m = 10 THEN 274 -- Oct
WHEN m = 11 THEN 305 -- Nov
ELSE 335 -- Dec
END
-- Allow for Feb being only 28 days in a non-leap-year.
IF m >= 3 AND NOT date.IsLeapYear( y ) SET d = d - 1
RETURN date.YearDay( y, d )
END
I hope it's useful to someone, and I hope it's correct - I have tested by generating test ranges of days to check the generated calendar looks correct, with the correct number of days in each month, especially February. The functions do not check whether the input is valid, that is assumed. This is part of a project to implement SQL in C#.
I am trying to isolate data in a table based on user input.
I have the below-
sex=input("please input the gender (M/F): ", 's');
sysbp= input("enter styloic blood pressure: ");
diabp= input("enter dystolic blood pressure: ");
systoliclow=[-inf;-inf;-inf;-inf;-inf;-inf;-inf;-inf;-inf;-inf;
120;120;120;120;120;120;120;120;120;120;
130;130;130;130;130;130;130;130;130;130;
140;140;140;140;140;140;140;140;140;140;
160;160;160;160;160;160;160;160;160;160]
systolichigh =[119;119;119;119;119;119;119;119;119;119;
129;129;129;129;129;129;129;129;129;129;
139;139;139;139;139;139;139;139;139;139;
159;159;159;159;159;159;159;159;159;159;
inf;inf;inf;inf;inf;inf;inf;inf;inf;inf]
diastoliclow=[-inf; -inf ; 80; 80 ; 85; 85 ; 90; 90; 100; 100 ;
-inf; -inf ; 80; 80 ; 85; 85 ; 90; 90;100;100;
-inf; -inf ; 80; 80 ; 85; 85 ; 90; 90;100;100 ;
-inf; -inf ; 80; 80 ; 85; 85 ; 90; 90;100;100 ;
-inf; -inf ; 80; 80 ; 85; 85 ; 90; 90;100;100 ]
diastolichigh=[79; 79 ;84; 84; 89; 89; 99; 99; inf; inf;
79; 79 ;84; 84; 89; 89; 99; 99; inf; inf;
79; 79 ;84; 84; 89; 89; 99; 99; inf; inf
79; 79 ;84; 84; 89; 89; 99; 99; inf; inf
79; 79 ;84; 84; 89; 89; 99; 99; inf; inf]
gender={'F' ;'M'; 'F' ;'M'; 'F' ;'M'; 'F' ;'M';'F' ;'M';
'F' ;'M'; 'F' ;'M'; 'F' ;'M'; 'F' ;'M';'F' ;'M' ;
'F' ;'M'; 'F' ;'M'; 'F' ;'M'; 'F' ;'M';'F' ;'M';
'F' ;'M'; 'F' ;'M'; 'F' ;'M'; 'F' ;'M';'F' ;'M';
'F' ;'M'; 'F' ;'M'; 'F' ;'M'; 'F' ;'M';'F' ;'M' }
values= [-3 ;0; 0 ;0; 0; 1; 2 ;2; 3 ;3;
0;0;0;0;0;1;2;2;3;3;
0;1;0;1;0;1;2;2;3;3;
2;2;2;2;2;2;2;2;3;3;
3;3;3;3;3;3;3;3;3;3]
bpt= table(systoliclow, systolichigh, diastoliclow,diastolichigh, gender, values)
if sysbp>=bpt.systoliclow && sysbp<=bpt.systolichigh && diabp<=bpt.diastoliclow && diap>=bpt.diastolichigh && ismember(sex{'F','M'});
test = bpt.values
How do I loop through the table to get the values based on the user input.
You can use logical indexing, no loops required:
isIsolated = sysbp>=bpt.systoliclow & sysbp<=bpt.systolichigh & diabp>=bpt.diastoliclow & diabp<=bpt.diastolichigh & strcmp(bpt.gender,sex);
isolatedTable = bpt(isIsolated,:);
For inputs M, 120 and 85:
>> isolatedTable
isolatedTable =
1×6 table
systoliclow systolichigh diastoliclow diastolichigh gender values
___________ ____________ ____________ _____________ ______ ______
120 129 85 89 'M' 1
If you are only interested in the values variable:
>> isolatedValues = bpt(isIsolated,end)
isolatedValues =
2×1 table
values
______
1
You can query the rows which fit the user input and iterate through their ids:
rows = sysbp>=bpt.systoliclow & sysbp<=bpt.systolichigh & diabp>=bpt.diastoliclow & diabp<=bpt.diastolichigh & strcmp(sex, bpt.gender);
ind = find(rows == 1);
for i=ind
bpt(i, :)
end
The result:
ans =
systoliclow systolichigh diastoliclow diastolichigh gender values
___________ ____________ ____________ _____________ ______ ______
-Inf 119 90 99 'F' 2
-Inf 119 90 99 'M' 2
I'm extracting lines 8 through 11 from a file (example.c),
and I want the lines to be numbered 8,9,10,11.
Here's what I tried, but (unsurprisingly) it gives me the line numbers
1,2,3,4. There's got to be a simple way around this, right?
$ sed -n '8,11p;12q' example.c | cat -n
1 x = 5;
2 y = 6;
3 z = 7;
4 w = 8;
And here's my example.c file for completeness:
$ cat -n example.c
1 int x;
2 int y;
3 int z;
4 int w;
5
6 int main()
7 {
8 x = 5;
9 y = 6;
10 z = 7;
11 w = 8;
12
13 return x+y+z+w;
14 }
This is a tab-delimited txt that looks like
A 2000 a B 2001 b C 1999 c
X 2005 x Y 1995 y
There will be hundreds of rows like these.
I want to create matrices like
mat1 = [A 2000 a ; B 2001 b ; C 1999 c]
mat2 = [X 2005 x ; Y 1995 y]
I think this is doable if I just use for and if and so on.
But I am not sure if I can do it by some more efficient matlab command using block transpose.
id = fopen('input.txt');
tline = fgetl(id);
ii = 1;
while ischar(tline)
cell_{ii} = cellfun(#(x)(str2double(x)),reshape(regexp(tline,'\t','split')',3,[])');
ii = ii+1;
tline = fgetl(id);
end
fclose(id);
The output matrices are stored in the cell array , cell_
input file is
564 564 5646 65466 458 545
785 878 8745 555 547 5665 55966 66588 6654
output is
cell_{1}
ans =
564 564 5646
65466 458 545
cell_{2}
ans =
785 878 8745
555 547 5665
55966 66588 6654