-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from AccelerationConsortium/docs2
docs and src scripts openflexure rs232
- Loading branch information
Showing
12 changed files
with
241 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
title: Openflexure Microscope | ||
emoji: 🐨 | ||
colorFrom: yellow | ||
colorTo: green | ||
sdk: streamlit | ||
sdk_version: 1.38.0 | ||
app_file: app.py | ||
pinned: false | ||
license: mit | ||
--- | ||
|
||
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference |
File renamed without changes.
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
5 changes: 5 additions & 0 deletions
5
src/ac_training_lab/openflexure/huggingface/requirements copy.txt
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
paho-mqtt | ||
Pillow | ||
pymongo | ||
requests | ||
streamlit |
5 changes: 5 additions & 0 deletions
5
src/ac_training_lab/openflexure/huggingface/requirements-pinned.txt
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
paho-mqtt==2.1.0 | ||
Pillow==9.5.0 | ||
pymongo==3.11.0 | ||
requests==2.32.3 | ||
streamlit==1.37.1 |
10 changes: 5 additions & 5 deletions
10
src/ac_training_lab/openflexure/huggingface/requirements.txt
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
paho-mqtt==2.1.0 | ||
Pillow==9.5.0 | ||
pymongo==3.11.0 | ||
requests==2.32.3 | ||
streamlit==1.37.1 | ||
paho-mqtt | ||
Pillow | ||
pymongo | ||
requests | ||
streamlit |
28 changes: 28 additions & 0 deletions
28
src/ac_training_lab/picow/mass-balance/us-solid/_scripts/byte_conversion.py
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
def simulate_rs232_data(): | ||
# Define the ASCII codes for the components of "11.2 g" | ||
data = [ | ||
ord("+"), # Positive sign (+) | ||
ord(" "), # Space | ||
ord("1"), # First digit | ||
ord("1"), # Second digit | ||
ord("."), # Decimal point | ||
ord("2"), # Third digit | ||
ord(" "), # Space | ||
ord("g"), # Unit 1 | ||
ord(" "), # Unit 2 (can be another unit, if applicable) | ||
ord(" "), # Unit 3 (optional or placeholder) | ||
ord("\n"), # End/return (new line) | ||
] | ||
|
||
# Convert ASCII codes to characters and form the message | ||
message = "".join(chr(byte) for byte in data) | ||
|
||
# Simulate the RS232 data being sent/received | ||
return message | ||
|
||
|
||
# Test the function | ||
if __name__ == "__main__": | ||
rs232_message = simulate_rs232_data() | ||
print("Simulated RS232 Data:") | ||
print(rs232_message) |
50 changes: 50 additions & 0 deletions
50
src/ac_training_lab/picow/mass-balance/us-solid/_scripts/rs232_basic.py
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import time | ||
|
||
from machine import UART, Pin | ||
|
||
# Initialize UART interfaces | ||
uart1 = UART(1, baudrate=9600, tx=Pin(4), rx=Pin(5)) | ||
uart0 = UART(0, baudrate=9600, tx=Pin(0), rx=Pin(1)) | ||
|
||
# Data to be sent | ||
txData = b"RS232 receive test...\r\n" | ||
print(f"Writing to uart0: {txData}") | ||
uart0.write(txData) | ||
time.sleep(0.1) | ||
|
||
timeout = 10 # Timeout in seconds | ||
start_time = time.time() | ||
|
||
print("Starting UART communication...") | ||
|
||
while True: | ||
current_time = time.time() | ||
if current_time - start_time > timeout: | ||
print("Timeout exceeded. Exiting...") | ||
break | ||
|
||
# Check for data on uart0 | ||
if uart0.any() > 0: | ||
print("Data available on uart0") | ||
while uart0.any() > 0: # Channel 0 is spontaneous and self-collecting | ||
rxData0 = uart0.read() | ||
if rxData0: | ||
decoded_data = rxData0.decode("utf-8").strip() | ||
print(f"uart0 received: {decoded_data}") | ||
uart0.write(decoded_data) | ||
if uart0.any() == 0: | ||
uart0.write("\r\n") | ||
|
||
# Check for data on uart1 | ||
if uart1.any() > 0: | ||
print("Data available on uart1") | ||
while uart1.any() > 0: # Channel 1 is spontaneous and self-collecting | ||
rxData1 = uart1.read() | ||
if rxData1: | ||
decoded_data = rxData1.decode("utf-8").strip() | ||
print(f"uart1 received: {decoded_data}") | ||
uart1.write(decoded_data) | ||
if uart1.any() == 0: | ||
uart1.write("\r\n") | ||
|
||
time.sleep(0.5) # Add a small delay to avoid busy-waiting |
50 changes: 50 additions & 0 deletions
50
src/ac_training_lab/picow/mass-balance/us-solid/_scripts/rs232_two_channel.py
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import time | ||
|
||
from machine import UART, Pin | ||
|
||
# Initialize UART interfaces | ||
uart1 = UART(1, baudrate=9600, tx=Pin(4), rx=Pin(5)) | ||
uart0 = UART(0, baudrate=9600, tx=Pin(0), rx=Pin(1)) | ||
|
||
# Data to be sent | ||
txData = b"RS232 receive test...\r\n" | ||
print(f"Writing to uart0: {txData}") | ||
uart0.write(txData) | ||
time.sleep(0.1) | ||
|
||
timeout = 10 # Timeout in seconds | ||
start_time = time.time() | ||
|
||
print("Starting UART communication...") | ||
|
||
while True: | ||
current_time = time.time() | ||
if current_time - start_time > timeout: | ||
print("Timeout exceeded. Exiting...") | ||
break | ||
|
||
# Check for data on uart0 | ||
if uart0.any() > 0: | ||
print("Data available on uart0") | ||
while uart0.any() > 0: # Channel 0 is spontaneous and self-collecting | ||
rxData0 = uart0.read() | ||
if rxData0: | ||
decoded_data = rxData0.decode("utf-8").strip() | ||
print(f"uart0 received: {decoded_data}") | ||
uart0.write(decoded_data) | ||
if uart0.any() == 0: | ||
uart0.write("\r\n") | ||
|
||
# Check for data on uart1 | ||
if uart1.any() > 0: | ||
print("Data available on uart1") | ||
while uart1.any() > 0: # Channel 1 is spontaneous and self-collecting | ||
rxData1 = uart1.read() | ||
if rxData1: | ||
decoded_data = rxData1.decode("utf-8").strip() | ||
print(f"uart1 received: {decoded_data}") | ||
uart1.write(decoded_data) | ||
if uart1.any() == 0: | ||
uart1.write("\r\n") | ||
|
||
time.sleep(0.5) # Add a small delay to avoid busy-waiting |
33 changes: 33 additions & 0 deletions
33
src/ac_training_lab/picow/mass-balance/us-solid/_scripts/scale.py
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import time | ||
|
||
from machine import UART, Pin | ||
|
||
# Initialize UART interfaces | ||
uart0 = UART(0, baudrate=9600, tx=Pin(0), rx=Pin(1)) | ||
|
||
# Data to be sent | ||
# txData = b"RS232 receive test...\r\n" | ||
# print(f"Writing to uart0: {txData}") | ||
# uart0.write(txData) | ||
# time.sleep(0.1) | ||
|
||
timeout = 10 # Timeout in seconds | ||
start_time = time.time() | ||
|
||
print("Starting UART communication...") | ||
|
||
while True: | ||
current_time = time.time() | ||
if current_time - start_time > timeout: | ||
print("Timeout exceeded. Exiting...") | ||
break | ||
|
||
# Check for data on uart0 | ||
if uart0.any() > 0: | ||
print("Data available on uart0") | ||
while uart0.any() > 0: # Channel 0 is spontaneous and self-collecting | ||
rxData0 = uart0.read() | ||
print(f"rxData0: {rxData0}") | ||
print(rxData0) | ||
|
||
time.sleep(0.1) # Add a small delay to avoid busy-waiting |
38 changes: 38 additions & 0 deletions
38
src/ac_training_lab/picow/mass-balance/us-solid/_scripts/tx_rx_connected_debug_test.py
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# connect the TX and RX pins of the Pico to test the UART communication | ||
import time | ||
|
||
from machine import UART, Pin | ||
|
||
# Initialize UART interface | ||
uart0 = UART(0, baudrate=9600, tx=Pin(0), rx=Pin(1)) | ||
|
||
# Data to be sent | ||
txData = b"RS232 receive test...\r\n" | ||
print(f"Writing to uart0: {txData}") | ||
uart0.write(txData) | ||
time.sleep(0.1) | ||
|
||
timeout = 10 # Timeout in seconds | ||
start_time = time.time() | ||
|
||
print("Starting UART communication...") | ||
|
||
while True: | ||
current_time = time.time() | ||
if current_time - start_time > timeout: | ||
print("Timeout exceeded. Exiting...") | ||
break | ||
|
||
# Check for data on uart0 | ||
if uart0.any() > 0: | ||
print("Data available on uart0") | ||
while uart0.any() > 0: # Channel 0 is spontaneous and self-collecting | ||
rxData0 = uart0.read() | ||
if rxData0: | ||
decoded_data = rxData0.decode("utf-8") | ||
print(f"uart0 received: {decoded_data}") | ||
uart0.write("{}".format(decoded_data)) | ||
if uart0.any() == 0: | ||
uart0.write("\r\n") | ||
|
||
time.sleep(0.5) # Add a small delay to avoid busy-waiting |