Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
DIOT reliability studies project
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Projects
DIOT reliability studies project
Commits
5c044d95
Commit
5c044d95
authored
Mar 23, 2022
by
Alén Arias Vázquez
😎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- change default value of tty \ - change the prints \ - add function to read parameters
parent
6e7d6584
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
cpx400dp.py
cpx400dp/cpx400dp.py
+14
-5
No files found.
cpx400dp/cpx400dp.py
View file @
5c044d95
...
...
@@ -5,7 +5,7 @@ import argparse
class
CPX400DP
(
object
):
def
__init__
(
self
,
name
=
'CPX400DP'
,
devname
=
'/dev/tty
_CPX
'
,
baudrate
=
115200
,
log_level
=
logging
.
INFO
):
def
__init__
(
self
,
name
=
'CPX400DP'
,
devname
=
'/dev/tty
ACM0
'
,
baudrate
=
115200
,
log_level
=
logging
.
INFO
):
logging
.
basicConfig
(
format
=
'
%(asctime)
s.
%(msecs)03
d
%(name)
s-
%(levelname)-
s:
%(message)
s'
,
datefmt
=
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
,
level
=
log_level
)
self
.
name
=
name
self
.
log
=
logging
.
getLogger
(
self
.
name
)
...
...
@@ -34,7 +34,7 @@ class CPX400DP(object):
cmd
=
'V'
+
str
(
chan
)
+
'O?
\n
'
self
.
send_cmd
(
cmd
)
answer
=
self
.
recv_cmd
()
self
.
log
.
info
(
"
Channel {} ---- {}
}V"
.
format
(
chan
,
float
(
answer
[:
-
3
])))
self
.
log
.
info
(
"
Voltage channel {}: {
}V"
.
format
(
chan
,
float
(
answer
[:
-
3
])))
return
float
(
answer
[:
-
3
])
def
set_current
(
self
,
amps
,
chan
=
1
):
...
...
@@ -46,7 +46,7 @@ class CPX400DP(object):
cmd
=
'I'
+
str
(
chan
)
+
'O?
\n
'
self
.
send_cmd
(
cmd
)
answer
=
self
.
recv_cmd
()
self
.
log
.
info
(
"C
hannel {} ----
{}A"
.
format
(
chan
,
float
(
answer
[:
-
3
])))
self
.
log
.
info
(
"C
urrent channel {}:
{}A"
.
format
(
chan
,
float
(
answer
[:
-
3
])))
return
float
(
answer
[:
-
3
])
def
unlock
(
self
):
...
...
@@ -72,8 +72,17 @@ class CPX400DP(object):
self
.
set_current
(
amps
=
amps
,
chan
=
chan
)
self
.
turn_on
(
chan
=
chan
)
def
get_values
(
self
,
chan
=
1
,
volts
=
10.0
,
amps
=
0.3
):
for
i
in
range
()
def
get_parameters_chan
(
self
,
chan
=
1
):
V
=
self
.
get_voltage
(
chan
=
chan
)
I
=
self
.
get_current
(
chan
=
chan
)
return
V
,
I
def
get_parameters
(
self
):
V1
,
I1
=
self
.
get_parameters_chan
(
chan
=
1
)
V2
,
I2
=
self
.
get_parameters_chan
(
chan
=
2
)
P1
=
V1
*
I1
P2
=
V2
*
I2
return
V1
,
V2
,
I1
,
I2
,
P1
,
P2
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
'Control CPX400DP from USB'
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment