Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
processer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anders Blomdell
processer
Commits
fe853aa5
Commit
fe853aa5
authored
5 years ago
by
Anders Blomdell
Browse files
Options
Downloads
Patches
Plain Diff
Correct type error, update calibrator
parent
8c49bb10
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
china_io-2019/avr/china-io.c
+10
-11
10 additions, 11 deletions
china_io-2019/avr/china-io.c
china_io-2019/python/calibrator.py
+4
-1
4 additions, 1 deletion
china_io-2019/python/calibrator.py
with
14 additions
and
12 deletions
china_io-2019/avr/china-io.c
+
10
−
11
View file @
fe853aa5
...
...
@@ -192,7 +192,7 @@ SIGNAL(TIMER1_COMPA_vect)
PORT_SPI
|=
(
1
<<
DD_SS
);
// Chip deselect
union
{
int32_t
i
;
u
int32_t
i
;
unsigned
char
b
[
4
];
}
v
;
uint8_t
chan
;
...
...
@@ -204,10 +204,10 @@ SIGNAL(TIMER1_COMPA_vect)
adc
.
value
[
chan
]
=
(
v
.
i
>>
6
);
}
static
uint32_t
conf_millivolt
(
u
int32_t
value
)
static
uint32_t
conf_millivolt
(
int32_t
value
)
{
if
(
value
<
0
)
{
return
CONF_NEGATIVE_MILLIVOLT
(
value
);
return
CONF_NEGATIVE_MILLIVOLT
(
-
value
);
}
else
{
return
CONF_POSITIVE_MILLIVOLT
(
value
);
}
...
...
@@ -271,30 +271,31 @@ int main()
cli
();
// Global interrupt disable
if
(
readchannels
==
0
)
{
// Process all old readchannels before updating
readchannels
=
serial_readchannels
;
serial_readchannels
=
0
;
}
local_adc
=
adc
;
config
=
serial_readconfig
;
serial_readconfig
=
0
;
local_adc
=
adc
;
sei
();
// Global interrupt enable
if
(
readchannels
&
0x01
)
{
serialio_putchannel
(
0
,
local_adc
.
value
[
0
]);
serialio_putchannel
(
0
,
local_adc
.
value
[
0
]
&
0x3ffff
);
readchannels
&=
~
0x01
;
}
else
if
(
readchannels
&
0x02
)
{
serialio_putchannel
(
1
,
local_adc
.
value
[
1
]);
serialio_putchannel
(
1
,
local_adc
.
value
[
1
]
&
0x3ffff
);
readchannels
&=
~
0x02
;
}
else
if
(
readchannels
&
0x04
)
{
serialio_putchannel
(
2
,
local_adc
.
value
[
2
]);
serialio_putchannel
(
2
,
local_adc
.
value
[
2
]
&
0x3ffff
);
readchannels
&=
~
0x04
;
}
else
if
(
readchannels
&
0x08
)
{
serialio_putchannel
(
3
,
local_adc
.
value
[
3
]);
serialio_putchannel
(
3
,
local_adc
.
value
[
3
]
&
0x3ffff
);
readchannels
&=
~
0x08
;
}
if
(
i2c_idle
())
{
cli
();
dac8574_set_chan
(
&
dac8574
.
a
,
calibration
.
channel
[
0
].
offset
);
dac8574_set_chan
(
&
dac8574
.
b
,
calibration
.
channel
[
0
].
offset
);
dac8574_set_chan
(
&
dac8574
.
b
,
calibration
.
channel
[
1
].
offset
);
dac8574_set_chan
(
&
dac8574
.
c
,
dac
.
value
[
0
]);
dac8574_set_chan
(
&
dac8574
.
d
,
dac
.
value
[
1
]);
sei
();
...
...
@@ -316,8 +317,6 @@ int main()
CONF_ANALOG_IN
(
3
,
CONF_MAX
(
CONF_POSITIVE_MILLIVOLT
(
10000
)));
CONF_ANALOG_OUT
(
0
,
CONF_RESOLUTION
(
16
));
// Analog Out 0
//CONF_ANALOG_OUT(0, CONF_MIN(CONF_NEGATIVE_MILLIVOLT(10000)));
//CONF_ANALOG_OUT(0, CONF_MAX(CONF_POSITIVE_MILLIVOLT(10000)));
CONF_ANALOG_OUT
(
0
,
CONF_MIN
(
conf_millivolt
(
calibration
.
channel
[
0
].
min
)));
CONF_ANALOG_OUT
(
0
,
CONF_MAX
(
conf_millivolt
(
calibration
.
channel
[
0
].
max
)));
CONF_ANALOG_OUT
(
1
,
CONF_RESOLUTION
(
16
));
// Analog Out 1
...
...
This diff is collapsed.
Click to expand it.
china_io-2019/python/calibrator.py
+
4
−
1
View file @
fe853aa5
...
...
@@ -119,6 +119,10 @@ class ChinaIO:
if
c
.
bits
!=
18
:
raise
Exception
(
'
analogIn[%d] is not 18 bit (%d)
'
%
(
i
,
c
.
bits
))
pass
for
i
,
c
in
analogOut
.
items
():
if
c
.
bits
!=
16
:
raise
Exception
(
'
analogOut[%d] is not 16 bit (%d)
'
%
(
i
,
c
.
bits
))
pass
# Set offset calibration to default value
# self.io.setchannel(31, (0x8000 << 8) | 0x00)
...
...
@@ -133,7 +137,6 @@ class ChinaIO:
(
-
0.1
,
0.1
),
(
-
0.1
,
0.1
)
],
N
=
500
,
message
=
'
Ground all input pins
'
):
break
pass
# Connect AOut0 -> AIn0,AIn2 (+9V)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment