Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
total_control_app
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Martin Drechsler
total_control_app
Commits
d7b8c028
Commit
d7b8c028
authored
May 31, 2018
by
Martin Drechsler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parents
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
0 deletions
+82
-0
ADoutputs.py
ADoutputs.py
+82
-0
No files found.
ADoutputs.py
0 → 100644
View file @
d7b8c028
# -*- coding: utf-8 -*-
"""
Created on Wed May 30 15:27:17 2018
@author: martindrech
"""
from
__future__
import
absolute_import
,
division
,
print_function
from
mcculw
import
ul
from
mcculw.enums
import
DigitalIODirection
,
ULRange
from
examples.props.digital
import
DigitalProps
from
examples.props.ao
import
AnalogOutputProps
from
mcculw.ul
import
ULError
ao_range
=
ULRange
.
BIP10VOLTS
class
daq_DO
(
object
):
def
__init__
(
self
,
out_num
):
self
.
board_num
=
0
self
.
digital_props
=
DigitalProps
(
self
.
board_num
)
# Find the first port that supports output, defaulting to None
# if one is not found.
self
.
port
=
next
(
(
port
for
port
in
self
.
digital_props
.
port_info
if
port
.
supports_output
),
None
)
# If the port is configurable, configure it for output
if
self
.
port
!=
None
and
self
.
port
.
is_port_configurable
:
try
:
ul
.
d_config_port
(
self
.
board_num
,
self
.
port
.
type
,
DigitalIODirection
.
OUT
)
except
ULError
as
e
:
self
.
show_ul_error
(
e
)
self
.
out_num
=
out_num
def
set_digital_out
(
self
,
bit_value
):
try
:
# Output the value to the board
ul
.
d_bit_out
(
self
.
board_num
,
self
.
port
.
type
,
self
.
out_num
,
bit_value
)
except
ULError
as
e
:
self
.
show_ul_error
(
e
)
def
get_digital_out
(
self
):
try
:
state
=
ul
.
d_bit_in
(
self
.
board_num
,
self
.
port
.
type
,
self
.
out_num
)
print
(
state
)
except
ValueError
:
return
0
class
daq_AO
(
object
):
def
__init__
(
self
,
out_num
):
self
.
board_num
=
0
self
.
ao_props
=
AnalogOutputProps
(
self
.
board_num
)
self
.
out_num
=
out_num
def
set_analog_out
(
self
,
value
):
#ao_range = self.ao_props.available_ranges[0]
try
:
ul
.
v_out
(
self
.
board_num
,
self
.
out_num
,
ao_range
,
value
)
except
ULError
as
e
:
self
.
show_ul_error
(
e
)
def
get_analog_out
(
self
):
#ao_range = self.ao_props.available_ranges[0]
try
:
state
=
ul
.
a_in
(
self
.
board_num
,
self
.
out_num
,
ao_range
)
print
(
state
)
except
ValueError
:
return
0
######################################################################################
\ No newline at end of file
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