LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Connecting VISA to STOP and START buttons

Hi! We have a Labview diagram block that records sound until the stop is pressed and generates a wav file to redirec it to a python program. It then prints back its results. We want to conncet an ESP32 to our labview so that when the user clicks the start button in  the program the ESP32 runs a Mucode wich initializes the counting in a 7 segments display. When the user clicks stop the display stops the cronometer. We have used the VISA selection port but we dont know if our connections are ok... can someone help please?

maria2209_0-1748445619421.jpeg

the Mu code in question: 

from machine import I2C, Pin
from time import ticks_ms, sleep
from ht16k33 import Seg7x4
import sys
import select

# Inicializa I2C e display
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
display = Seg7x4(i2c)

start_time = 0
running = False

def start_timer():
global start_time, running
start_time = ticks_ms()
running = True

def stop_timer():
global running
running = False
display.fill(0) # Apaga o display

while True:
# Verifica se há dados na porta serial (USB)
if sys.stdin in select.select([sys.stdin], [], [], 0)[0]:
command = sys.stdin.readline().strip()
if command == "START":
start_timer()
elif command == "STOP":
stop_timer()

# Se estiver a contar, atualiza o display
if running:
elapsed_ms = ticks_ms() - start_time
seconds = elapsed_ms // 1000
minutes = seconds // 60
secs = seconds % 60
time_string = "{:02d}{:02d}".format(minutes, secs)
display.display(time_string, colon=True)

sleep(0.2)

0 Kudos
Message 1 of 1
(128 Views)