Files
Feeding_control_system/vision/test_feed.py
2025-12-12 18:00:14 +08:00

62 lines
2.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import time
from hardware.relay import RelayController
from hardware.transmitter import TransmitterController
from test_feed import start_feeding
def start_feeding():
"""第一阶段下料:下料斗向模具车下料(低速)"""
print("开始下料")
# self.relay_controller.control
loc_relay=RelayController()
loc_mitter=TransmitterController(loc_relay)
initial_lower_weight=loc_mitter.read_data(2)
initial_upper_weight=loc_mitter.read_data(1)
first_finish_weight=0
start_time=None
# mould_need_weight=4000
while True:
current_weight = loc_mitter.read_data(2)
first_finish_weight=initial_lower_weight-current_weight
if current_weight<500:
#关5秒
if start_time is None or time.time()-start_time>5:
start_time=time.time()
loc_relay.control_arch_lower_open()
if current_weight<100:
start_time=None
loc_relay.control_lower_close()
break
print(f'------------已下料: {first_finish_weight}kg-------------')
time.sleep(1)
#打开上料斗出砼门开5就开三分之一下
loc_relay.control_upper_open_sync(5)
while True:
current_upper_weight = loc_mitter.read_data(1)
if current_upper_weight<3500:
#关5秒
loc_relay.control_upper_close()
break
time.sleep(1)
initial_lower_weight=loc_mitter.read_data(2)
while True:
current_weight = loc_mitter.read_data(2)
first_finish_weight=first_finish_weight+initial_lower_weight-current_weight
if current_weight<500:
#关5秒
if start_time is None or time.time()-start_time>5:
start_time=time.time()
loc_relay.control_arch_lower_open()
if current_weight<100:
start_time=None
loc_relay.control_lower_close()
break
print(f'------------已下料: {first_finish_weight}kg-------------')
time.sleep(1)
if __name__ == "__main__":
start_feeding()