Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
labcode
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CST
labcode
Commits
e126be73
Commit
e126be73
authored
8 months ago
by
Alexandros Asonitis
Browse files
Options
Downloads
Patches
Plain Diff
Binary to Octal and Octal to Binary functions!
parent
194d360b
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
TLM_tool/convert_test.ipynb
+43
-6
43 additions, 6 deletions
TLM_tool/convert_test.ipynb
TLM_tool/hp3497a_lib.py
+13
-0
13 additions, 0 deletions
TLM_tool/hp3497a_lib.py
with
56 additions
and
6 deletions
TLM_tool/
DAQ
_test.ipynb
→
TLM_tool/
convert
_test.ipynb
+
43
−
6
View file @
e126be73
...
...
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count":
2
,
"execution_count":
1
,
"id": "b3965c31-edec-4d04-856c-c4bb850bd22a",
"metadata": {},
"outputs": [],
...
...
@@ -12,18 +12,55 @@
},
{
"cell_type": "code",
"execution_count":
3
,
"id": "
2c7d107a-4035-48b6-8024-2fe5a438b1b7
",
"execution_count":
2
,
"id": "
a4f45391-ec6d-47c2-ae1e-445097197bdb
",
"metadata": {},
"outputs": [],
"source": [
"daq = hp3497a_lib.hp3497a()"
"bin = hp3497a_lib.octal_to_bin(177777)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "dad4cac4-c0fb-438a-8928-da8332701f2c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1111111111111111\n"
]
}
],
"source": [
"print(bin)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "73e839ca-fb78-47f4-8076-43676d6bb4ad",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"177777\n"
]
}
],
"source": [
"octal = hp3497a_lib.bin_to_octal(bin)\n",
"print(octal)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "
a4f45391-ec6d-47c2-ae1e-445097197bdb
",
"id": "
b21fc931-38d2-492b-8b16-1703421366d3
",
"metadata": {},
"outputs": [],
"source": []
...
...
@@ -45,7 +82,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.1
1.1
"
"version": "3.1
2.0
"
}
},
"nbformat": 4,
...
...
%% Cell type:code id:b3965c31-edec-4d04-856c-c4bb850bd22a tags:
```
python
import
hp3497a_lib
```
%% Cell type:code id:
2c7d107a-4035-48b6-8024-2fe5a438b1b7
tags:
%% Cell type:code id:
a4f45391-ec6d-47c2-ae1e-445097197bdb
tags:
```
python
daq
=
hp3497a_lib
.
hp3497a
(
)
bin
=
hp3497a_lib
.
octal_to_bin
(
177777
)
```
%% Cell type:code id:a4f45391-ec6d-47c2-ae1e-445097197bdb tags:
%% Cell type:code id:dad4cac4-c0fb-438a-8928-da8332701f2c tags:
```
python
print
(
bin
)
```
%% Output
1111111111111111
%% Cell type:code id:73e839ca-fb78-47f4-8076-43676d6bb4ad tags:
```
python
octal
=
hp3497a_lib
.
bin_to_octal
(
bin
)
print
(
octal
)
```
%% Output
177777
%% Cell type:code id:b21fc931-38d2-492b-8b16-1703421366d3 tags:
```
python
```
...
...
This diff is collapsed.
Click to expand it.
TLM_tool/hp3497a_lib.py
+
13
−
0
View file @
e126be73
...
...
@@ -433,4 +433,17 @@ class hp3497a(object):
"""
self
.
inst
.
write
(
f
"
VW
{
n
}
"
)
# This to convert binary to octal and vise versa
def
bin_to_octal
(
bin
):
decimal
=
int
(
str
(
bin
),
2
)
octal
=
format
(
decimal
,
'
o
'
)
return
octal
def
octal_to_bin
(
octal
):
decimal
=
int
(
str
(
octal
),
8
)
bin
=
format
(
decimal
,
'
b
'
)
return
bin
\ No newline at end of file
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