-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
68 changed files
with
1,155 additions
and
119,736 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,11 @@ | |
@disc: ADC readout Sensor Test (Analog Devices LTC2308) | ||
Fast way over the virtual memory | ||
@date: 21.01.2020 | ||
@date: 22.06.2020 | ||
@device: Intel Cyclone V | ||
@author: Robin Sebastian | ||
(https://github.com/robseb) | ||
([email protected]) | ||
''' | ||
import os | ||
import time | ||
|
@@ -21,9 +22,9 @@ | |
import devmem | ||
|
||
# Demo duration | ||
TEST_DURATIONS =30 | ||
TEST_DURATIONS =100 | ||
|
||
# the Lightweight HPS-to-FPGA Bus base address offset | ||
# The Lightweight HPS-to-FPGA Bus base address offset | ||
HPS_LW_ADRS_OFFSET = 0xFF200000 | ||
|
||
# LTC2308 Address offset | ||
|
@@ -41,11 +42,20 @@ | |
### FIFO Convention Data Size for average calculation | ||
FIFO_SIZE = 255 # MAX=1024 | ||
|
||
VALUE_OR_VOLTAGE_OUTPUT = 0 # 1: Raw Value output | 0: Volage | ||
|
||
if __name__ == '__main__': | ||
print("ADC readout Demo for LTC2308 ADC with Channel "+str(ADC_CH)) | ||
|
||
# Read the name of the used development board | ||
#-> Only the Terasic DE10 Standard and Nano Boards are allowed! | ||
# The Board name for the image is located here: "/usr/rsyocto/suppBoard.txt" | ||
if os.path.isfile("/usr/rsyocto/suppBoard.txt"): | ||
supportStr = "" | ||
with open("/usr/rsyocto/suppBoard.txt", "r") as f: | ||
supportStr = f.read() | ||
if not supportStr.find('Terasic HAN Pilot') ==-1 : | ||
print('The Terasic HAN Pilot Board has no LTC2308 and is not supported!') | ||
sys.exit() | ||
|
||
# The ADC is only supported with rsYocto Version 1.031 or later | ||
versionNo = 0 | ||
# The rsYocto Version Number is located here: "/usr/rsyocto/version.txt" | ||
|
@@ -68,9 +78,13 @@ | |
# (Base address, byte length to acceses, interface) | ||
de = devmem.DevMem(HPS_LW_ADRS_OFFSET, ADC_ADDRES_OFFSET+0x8, "/dev/mem") | ||
|
||
print('Reading the current ADC value ...') | ||
|
||
# Enter test loop | ||
for var in range(TEST_DURATIONS): | ||
|
||
print('Sample: '+str(var)+'/'+str(TEST_DURATIONS)) | ||
|
||
# Set meassure number for ADC convert | ||
de.write(ADC_ADDRES_OFFSET+ADC_DATA_REG_OFFSET,[FIFO_SIZE]) | ||
# Enable the convention with CH0 | ||
|
@@ -95,14 +109,19 @@ | |
|
||
value = rawValue / FIFO_SIZE | ||
|
||
if VALUE_OR_VOLTAGE_OUTPUT: | ||
value = round(value,2) | ||
print("ADC AVG: "+str(value)) | ||
else: | ||
# Convert ADC Value to Volage | ||
volage = round(value/1000,2) | ||
print("U AVG: "+str(volage)+"V") | ||
value = round(value,2) | ||
print("-> ADC AVG: "+str(value)) | ||
|
||
# Convert ADC Value to Volage | ||
volage = round(value/1000,2) | ||
print("-> U AVG: "+str(volage)+"V") | ||
|
||
time.sleep(.2) # 200ms delay | ||
|
||
if var != TEST_DURATIONS-1: | ||
# Delate last 3 console line | ||
sys.stdout.write("\033[F") | ||
sys.stdout.write("\033[F") | ||
sys.stdout.write("\033[F") | ||
|
||
print('End of demo...') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,24 +4,48 @@ | |
''' | ||
@disc: Toggling the HPS LED Demo | ||
@device: Intel Cyclone V | ||
@date: 23.09.2019 | ||
@device: Intel Cyclone V & Intel Arria 10 SX | ||
@date: 22.06.2020 | ||
@author: Robin Sebastian | ||
(https://github.com/robseb) | ||
([email protected]) | ||
''' | ||
import os | ||
import time | ||
import sys | ||
|
||
# Demo duration | ||
TEST_DURATIONS = 20 | ||
|
||
|
||
PATH_OF_HPS_LED_DRIVER = '/sys/class/leds/hps_led0/brightness' | ||
|
||
if __name__ == '__main__': | ||
print('Hello from a Python Application running on a SoC-FPGA !\n') | ||
print('Toggling HPS LED Example') | ||
# Repeat 20 times | ||
for var in range(20): | ||
print("turn: ",var) | ||
|
||
# Read the name of the used development board | ||
# The Board name for the image is located here: "/usr/rsyocto/suppBoard.txt" | ||
if os.path.isfile("/usr/rsyocto/suppBoard.txt"): | ||
supportStr = "" | ||
with open("/usr/rsyocto/suppBoard.txt", "r") as f: | ||
supportStr = f.read() | ||
print('Your dev board: '+supportStr) | ||
|
||
for var in range(TEST_DURATIONS): | ||
print('Sample: '+str(var)+'/'+str(TEST_DURATIONS)) | ||
|
||
# Turn the HPS LED 0 ON | ||
os.system("echo 100 > /sys/class/leds/hps_led0/brightness") | ||
os.system("echo 100 > "+PATH_OF_HPS_LED_DRIVER) | ||
time.sleep(.200) | ||
|
||
# Turn the HPS LED 0 OFF | ||
os.system("echo 0 > /sys/class/leds/hps_led0/brightness") | ||
os.system("echo 0 > "+PATH_OF_HPS_LED_DRIVER) | ||
time.sleep(.500) | ||
|
||
# Delate last console line | ||
sys.stdout.write("\033[F") | ||
|
||
# Turn the HPS LED 0 OFF | ||
os.system("echo 0 > /sys/class/leds/hps_led0/brightness") | ||
print('End of demo...') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,25 +5,40 @@ | |
@disc: Toggling a FPGA LED with a rstools Linux | ||
Shell command | ||
@date: 21.10.2019 | ||
@date: 22.06.2020 | ||
@device: Intel Cyclone V | ||
@author: Robin Sebastian | ||
(https://github.com/robseb) | ||
([email protected]) | ||
''' | ||
import os | ||
import time | ||
import sys | ||
|
||
# Demo duration | ||
TEST_DURATIONS = 20 | ||
|
||
if __name__ == '__main__': | ||
print('Toggling the FPGA LED[7] with a Shell command\n') | ||
print('Toggling the FPGA LED[7] with a Linux Shell command') | ||
# Turn all FPGA LEDs Off | ||
os.system("FPGA-writeBridge -lw 20 0 -b") | ||
for var in range(20): | ||
print("turn: ",var) | ||
for var in range(TEST_DURATIONS): | ||
print('Sample: '+str(var)+'/'+str(TEST_DURATIONS)) | ||
|
||
# Turn the FPGA LED 7 ON | ||
os.system("FPGA-writeBridge -lw 20 -b 7 1 -b") | ||
# Wait for 50ms | ||
time.sleep(.50) | ||
|
||
# Turn the FPGA LED 7 ON | ||
os.system("FPGA-writeBridge -lw 20 -b 7 0 -b") | ||
# Wait for 50ms | ||
time.sleep(.50) | ||
|
||
# Delate last console line | ||
sys.stdout.write("\033[F") | ||
|
||
# Turn all FPGA LEDs Off | ||
os.system("FPGA-writeBridge -lw 20 0 -b") | ||
|
||
print('End of demo...') |
Oops, something went wrong.