8《项目八 燃气灶检测》题库答案_第1页
8《项目八 燃气灶检测》题库答案_第2页
8《项目八 燃气灶检测》题库答案_第3页
8《项目八 燃气灶检测》题库答案_第4页
8《项目八 燃气灶检测》题库答案_第5页
已阅读5页,还剩14页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

------《项目八》参考答案------一、单项选择题(每小题3分,共45分)题号12345678910答案BACDCDCACB二、判断题(每空1分,共10分)题号12345678910判断√√√×√√√√××三、填空题(每空1分共20分)1.热电 2.保持恒定3.热电偶4.低温 高温5.范围 精度6.片选信号 串行数据输出7.下降沿8.列表9.append10.sort四、操作题1.输入一年中的某一天,判断这一天是这一年的第几天:【输入格式:YYYY-MM-DD】,所有平年各月份的天数:[31,28,31,30,31,30,31,31,30,31,30,31]#定义一个函数,判断是否为闰年

defleapyear(y):

return(y%400==0or(y%4==0andy%100==0))

#定义一个数组,每个月的天数,由于python中的数组是从0开始,而月份是从1开始,所以数组第一个数为0

days=[0,31,28,31,30,31,30,31,31,30,31,30]

#存储月份的天数

res=0

#由用户输入年月日

year=int(input("请输入年份:"))

month=int(input("请输入月份:"))

day=int(input("请输入日期:"))

#如果是闰年的话,2月份加一天

ifleapyear(year):

days[2]+=1

#遍历一次days,对应月份中的天数,把对应的天数传递给res存储

foriinrange(month):

res+=days[i]

#打印出天数!

print(f"这是{year}年的第{res+day}天")请开发Python程序,利用list列表实现后台管理员管理前台会员信息系统,以下效果: 1.后台管理员只有一个用户:admin,密码:admin 2.当管理员登陆成功后,可以管理前台会员信息. 3.会员信息管理包含: 1.添加会员信息 2.删除会员信息 3.查看会员信息 -添加用户: 1).判断用户是否存在? 2).如果存在,报错; 3).如果不存在,添加用户名和密码分别到列表中; -删除用户 1).判断用户名是否存在 2).如果存在,删除; 3).如果不存在,报错;print('管理员登录'.center(50,'*'))

inuser=input('UserName:')

inpasswd=input('Password:')

#所有会员用户名

users=['root','westos']

#所有会员密码

passwds=['123','456']

ifinuser=='admin'andinpasswd=='admin':

print('管理员登录成功!')

print('会员管理'.center(50,'*'))

whileTrue:

print("""

操作目录

1.添加会员信息

2.删除会员信息

3.查看会员信息

4.退出

""")

choice=input('请选择你的操作:')

ifchoice=='1':

print('添加会员信息'.center(50,'*'))

AddUser=input('添加会员名:')

ifAddUserinusers:

print('用户%s已经存在'%(AddUser))

else:

AddPasswd=input('密码:')

users.append(AddUser)

passwds.append(AddPasswd)

print('添加用户%s成功!'%AddUser)

elifchoice=='2':

print('删除会员信息'.center(50,'*'))

DelUser=input('删除会员名:')

DelIndex=users.index(DelUser)

users.remove(DelUser)

passwds.pop(DelIndex)

print('删除会员%s成功!'%DelUser)

elifchoice=='3':

print('查看会员信息'.center(50,'*'))

print('\t用户名\t密码')

UserCount=len(users)

foriinrange(UserCount):

print('\t%s\t%s'%(users[i],passwds[i]))

elifchoice=='4':

exit()

else:

print('请输入正确的选择')

else:

print('管理员登录失败!')

将MAX6675模块和K型热电偶模块按照表4.1的对应接口连接至开发板,并且编写程序,实现效果如下:检测热电偶温度值,并且在程序消息栏中进行实时打印。importRPi.GPIOasGPIO

importtime

GPIO.setmode(GPIO.BCM)

GPIO.setup(13,GPIO.OUT)

GPIO.setup(6,GPIO.OUT)

GPIO.setup(5,GPIO.IN)

defMAX6675_Read():

value=0

GPIO.output(6,0)

GPIO.output(13,0)

forxinrange(16):

GPIO.output(6,1)

value<<=1

value|=GPIO.input(5)

GPIO.output(6,0)

GPIO.output(13,1)

returnvalue

defmain():

temp=0

con_flag=0

while(1):

temp=MAX6675_Read()

con_flag=temp&0x04

con_flag=con_flag>>2

ifcon_flag==0:

temp=temp<<1

temp=temp>>4

real_temp=temp/4

print("当前的温度是:"+real_temp+"℃")

else:

print("MAX6675不在线请检查")

if__name__=='__main__':

main()将MAX6675模块和K型热电偶模块按照表4.1的对应接口连接至开发板,并且编写程序,实现效果如下:用程序命令控制台模拟灶台点火状态,当用户输入点火,开始检测热电偶温度值,并且在消息栏中打印数据。当用户输入熄火,停止检测热电偶温度值。importRPi.GPIOasGPIO

importtime

importmultiprocessing

GPIO.setmode(GPIO.BCM)

GPIO.setup(13,GPIO.OUT)

GPIO.setup(6,GPIO.OUT)

GPIO.setup(5,GPIO.IN)

defGet_Direct(direct):

defMAX6675_Read():

value=0

GPIO.output(6,0)

GPIO.output(13,0)

forxinrange(16):

GPIO.output(6,1)

value<<=1

value|=GPIO.input(5)

GPIO.output(6,0)

GPIO.output(13,1)

returnvalue

defmain():

temp=0

con_flag=0

q_direct=multiprocessing.Queue()

Get_thread=multiprocessing.Process(target=Get_Direct,args={q_direct,})

Get_thread.start()

while(1):

cmd=q_direct.get()

ifcmd=="开火":

temp=MAX6675_Read()

con_flag=temp&0x04

con_flag=con_flag>>2

ifcon_flag==0:

temp=temp<<1

temp=temp>>4

real_temp=temp/4

print("当前的温度是:"+real_temp+"℃")

else:

print("MAX6675不在线请检查")

ifcmd=="熄火":

print("当前熄火")

time.sleep(0.5)

if__name__=='__main__':

main()将MAX6675模块和K型热电偶模块按照表4.1的对应接口连接至开发板,并且编写程序,实现效果如下:实时检测灶台温度,每分钟都记录一次当前温度,在消息控制台中进行打印。importdatetime

importRPi.GPIOasGPIO

importtime

GPIO.setmode(GPIO.BCM)

GPIO.setup(13,GPIO.OUT)

GPIO.setup(6,GPIO.OUT)

GPIO.setup(5,GPIO.IN)

defMAX6675_Read():

value=0

GPIO.output(6,0)

GPIO.output(13,0)

forxinrange(16):

GPIO.output(6,1)

value<<=1

value|=GPIO.input(5)

GPIO.output(6,0)

GPIO.output(13,1)

returnvalue

defmain():

temp=0

con_flag=0

temp_list=[]

while(1):

temp=MAX6675_Read()

con_flag=temp&0x04

con_flag=con_flag>>2

ifcon_flag==0:

temp=temp<<1

temp=temp>>4

real_temp=temp/4

temp_list.append(datetime.datetime+":"+real_temp)

print(temp_list)

else:

print("MAX6675不在线请检查")

time.sleep(60)

if__name__=='__main__':

main()将MAX6675模块和K型热电偶模块按照表4.1的对应接口连接至开发板,并且编写程序,实现效果如下:实时检测灶台温度,当灶台温度过高时记录下时间,用户在控制台可以对灶台异常过热状态进行查询。importdatetime

importRPi.GPIOasGPIO

importtime

GPIO.setmode(GPIO.BCM)

GPIO.setup(13,GPIO.OUT)

GPIO.setup(6,GPIO.OUT)

GPIO.setup(5,GPIO.IN)

defMAX6675_Read():

value=0

GPIO.output(6,0)

GPIO.output(13,0)

forxinrange(16):

GPIO.output(6,1)

value<<=1

value|=GPIO.input(5)

GPIO.output(6,0)

GPIO.output(13,1)

returnvalue

defmain():

temp=0

con_flag=0

temp_list=[]

while(1):

temp=MAX6675_Read()

con_flag=temp&0x04

con_flag=con_flag>>2

ifcon_flag==0:

temp=temp<<1

temp=temp>>4

real_temp=temp/4

print("当前的温度是:"+real_temp+"℃")

ifreal_temp>800:

temp_list.append(datetime.datetime+":"+real_temp)

print("异常温度记录",temp_list)

else:

print("MAX6675不在线请检查")

if__name__=='__main__':

main()

将MAX6675模块和K型热电偶模块按照表4.1的对应接口连接至开发板,并且编写程序,实现效果如下:通过控制命令台模拟灶台操作,在打火时先判断传感器是否正常在线,在正常的基础上判断点火成功与否;点着火之后判断是否出现偶然自熄火情况,自动关闭电磁阀门;最后判断炒菜结束是否忘记关闭阀门,如出现自动关闭电磁阀门。importRPi.GPIOasGPIO

importtime

importrandom

GPIO.setmode(GPIO.BCM)

GPIO.setup(13,GPIO.OUT)

GPIO.setup(6,GPIO.OUT)

GPIO.setup(5,GPIO.IN)

defMAX6675_Read():

GPIO.output(13,0)

GPIO.output(6,0)

value=0

forxinrange(16):

GPIO.output(6,1)

value<<=1

value|=GPIO.input(5)

GPIO.output(6,0)

GPIO.output(13,1)

returnvalue

defget_realtemp(floattemp

):

temp=temp<<1

temp=temp>>4

real_temp=temp/4

returntemp

defmain():

list_check=[]

while(1):

iflen(list_check)>15:

print("该燃气灶的出错次数过多,为了安全起见,请及时为其进行安全检查")

list_check.clear()

str=input("请打火:")

temp=MAX6675_Read()

con_flag=temp&0x04

con_flag=con_flag>>2

ifcon_flag==0:

time.sleep(1)

real_temp=get_realtemp(temp)

print("当前的温度是:"+real_temp+"℃")

ifreal_temp<200:

print("没有正常打着火,自动关闭煤气管道,请再次打火。")

list_check.append("error")

else:

print("正常打着火了!")

while(1):

temp_now=MAX6675_Read()

real_temp_now=get_realtemp(temp_now)

ifreal_temp_now<200:

print("突然熄火,自动关闭电磁阀门")

list_check.append("error")

randint_data=random.randint(1,10)#模拟压力传感器,判断是否炒完菜

ifrandint_data<5:

print("现在炒完菜了")

time.sleep(5)

temp_done=MAX6675_Read()

real_temp_done=get_realtemp(temp_done)

ifreal_temp_done>200:

print("可能忘记关闭燃气灶,为了安全现在自动关闭煤气!")

continue

time.sleep(2)

else:

print("MAX6675不在线请检查,存在安全隐患!请立即联系维修人员")

if__name__=='__main__':

main()将MAX6675模块和K型热电偶模块按照表4.1的对应接口连接至开发板,并且编写程序,实现效果如下:通过控制命令台模拟灶台操作,在打火时先判断传感器是否正常在线,在正常的基础上判断点火成功与否;点着火之后判断是否出现偶然自熄火情况,自动关闭电磁阀门;最后判断炒菜结束是否忘记关闭阀门,如出现自动关闭电磁阀门。通过列表记录每一次异常操作,用户可以通过error命令查询。importRPi.GPIOasGPIO

importtime

importmultiprocessing

importrandom

GPIO.setmode(GPIO.BCM)

GPIO.setup(13,GPIO.OUT)

GPIO.setup(6,GPIO.OUT)

GPIO.setup(5,GPIO.IN)

defMAX6675_Read():

GPIO.output(13,0)

GPIO.output(6,0)

value=0

forxinrange(16):

GPIO.output(6,1)

value<<=1

value|=GPIO.input(5)

GPIO.output(6,0)

GPIO.output(13,1)

returnvalue

defget_realtemp(temp):

temp=temp<<1

temp=temp>>4

real_temp=temp/4

returntemp

defgetCmd(data):

cmd=input()

ifcmd=="error":

print("异常操作",data.get())

defmain():

list_check=[]

p_data=multiprocessing.Queue()

p_getCmd=multiprocessing.Process(target=getCmd,args={p_data,})

while(1):

iflen(list_check)>15:

print("该燃气灶的出错次数过多,为了安全起见,请及时为其进行安全检查")

list_check.clewhile(1):

iflen(list_check)>15:

print("该燃气灶的出错次数过多,为了安全起见,请及时为其进行安全检查")

list_check.clear()

str=input("请打火:")

temp=MAX6675_Read()

con_flag=temp&0x04

con_flag=con_flag>>2

ifcon_flag==0:

time.sleep(1)

real_temp=get_realtemp(temp)

print("当前的温度是:"+real_temp+"℃")

ifreal_temp<200:

print("没有正常打着火,自动关闭煤气管道,请再次打火。")

list_check.append("error")

p_data.put("没有正常打着火,自动关闭煤气管道,请再次打火。")

else:

print("正常打着火了!")

while(1):

temp_now=MAX6675_Read()

real_temp_now=get_realtemp(temp_now)

ifreal_temp_now<200:

print("突然熄火,自动关闭电磁阀门")

list_check.append("error")

p_data.put("突然熄火,自动关闭电磁阀门")

randint_data=random.randint(1,10)#模拟压力传感器,判断是否炒完菜

ifrandint_data<5:

print("现在炒完菜了")

time.sleep(5)

temp_done=MAX6675_Read()

real_temp_done=get_realtemp(temp_done)

ifreal_temp_done>200:

print("可能忘记关闭燃气灶,为了安全现在自动关闭煤气!")

p_data.put("可能忘记关闭燃气灶,为了安全现在自动关闭煤气!")

continue

time.sleep(2)

else:

print("MAX6675不在线请检查,存在安全隐患!请立即联系维修人员")

str=input("请打火:")

temp=MAX6675_Read()

con_flag=temp&0x04

con_flag=con_flag>>2

ifcon_flag==0:

time.sleep(1)

real_temp=get_realtemp(temp)

print("当前的温度是:"+real_temp+"℃")

ifreal_temp<200:

print("没有正常打着火,自动关闭煤气管道,请再次打火。")

list_check.append("error")

p_data.put("可能忘记关闭燃气灶,为了安全现在自动关闭煤气!")

else:

print("正常打着火了!")

while(1):

temp_now=MAX6675_Read()

real_temp_now=get_realtemp(temp_now)

ifreal_temp_now<200:

print("突然熄火,自动关闭电磁阀门")

list_check.append("error")

p_data.put("突然熄火,自动关闭电磁阀门")

randint_data=random.randint(1,10)#模拟压力传感器,判断是否炒完菜

ifrandint_data<5:

print("现在炒完菜了")

time.sleep(5)

temp_done=MAX6675_Read()

real_temp_done=get_realtemp(temp_done)

ifreal_temp_done>200:

print("可能忘记关闭燃气灶,为了安全现在自动关闭煤气!")

p_data.put("可能忘记关闭燃气灶,为了安全现在自动关闭煤气!")

continue

time.sleep(2)

else:

print("MAX6675不在线请检查,存在安全隐患!请立即联系维修人员")

if__name__=='__main__':

main()

将MAX6675模块和K型热电偶模块按照表4.1的对应接口连接至开发板,并且编写程序,实现效果如下:通过控制命令台模拟灶台操作,在打火时先判断传感器是否正常在线,在正常的基础上判断点火成功与否;点着火之后判断是否出现偶然自熄火情况,自动关闭电磁阀门;最后判断炒菜结束是否忘记关闭阀门,如出现自动关闭电磁阀门。在起火状态后开始检测灶台温度值,并实时打印在程序消息栏内。importRPi.GPIOasGPIO

importtime

importrandom

GPIO.setmode(GPIO.BCM)

GPIO.setup(13,GPIO.OUT)

GPIO.setup(6,GPIO.OUT)

GPIO.setup(5,GPIO.IN)

defMAX6675_Read():

GPIO.output(13,0)

GPIO.output(6,0)

value=0

forxinrange(16):

GPIO.output(6,1)

value<<=1

value|=GPIO.input(5)

GPIO.output(6,0)

GPIO.output(13,1)

returnvalue

defget_realtemp(floattemp

):

temp=temp<<1

temp=temp>>4

real_temp=temp/4

returntemp

defmain():

list_check=[]

while(1):

iflen(list_check)>15:

print("该燃气灶的出错次数过多,为了安全起见,请及时为其进行安全检查")

list_check.clear()

str=input("请打火:")

temp=MAX6675_Read()

con_flag=temp&0x04

con_flag=con_flag>>2

ifcon_flag==0:

time.sleep(1)

real_temp=get_realtemp(temp)

print("当前的温度是:"+real_temp+"℃")

ifreal_temp<200:

print("没有正常打着火,自动关闭煤气管道,请再次打火。")

list_check.append("error")

else:

print("正常打着火了!")

while(1):

temp_now=MAX6675_Read()

real_temp_now=get_realtemp(temp_now)

ifreal_temp_now<200:

print("突然熄火,自动关闭电磁阀门")

list_check.append("error")

randint_data=random.randint(1,10)#模拟压力传感器,判断是否炒完菜

ifrandint_data<5:

print("现在炒完菜了")

time.sleep(5)

temp_done=MAX6675_Read()

real_temp_done=get_realtemp(temp_done)

ifreal_temp_done>200:

print("可能忘记关闭燃气灶,为了安全现在自动关闭煤气!")

continue

time.sleep(2)

else:

print("MAX6675不在线请检查,存在安全隐患!请立即联系维修人员")

if__name__=='__main__':

main()

将MAX6675模块和K型热电偶模块按照表4.1的对应接口连接至开发板,并且编写程序,实现效果如下:通过控制命令台模拟灶台操作,在打火时先判断传感器是否正常在线,在正常的基础上判断点火成功与否;点着火之后判断是否出现偶然自熄火情况,自动关闭电磁阀门;最后判断炒菜结束是否忘记关闭阀门,如出现自动关闭电磁阀门。在起火状态后开始检测灶台温度值,并实时打印在程序消息栏内。在创建温度检测表和异常记录表,用来实时记录灶台温度与异常记录,用户可以通过命令台进行查询。importRPi.GPIOasGPIO

importtime

importmultiprocessing

importrandom

GPIO.setmode(GPIO.BCM)

GPIO.setup(13,GPIO.OUT)

GPIO.setup(6,GPIO.OUT)

GPIO.setup(5,GPIO.IN)

defMAX6675_Read():

GPIO.output(13,0)

GPIO.output(6,0)

value=0

forxinrange(16):

GPIO.output(6,1)

value<<=1

value|=GPIO.input(5)

GPIO.output(6,0)

GPIO.output(13,1)

returnvalue

defget_realtemp(temp):

temp=temp<<1

temp=temp>>4

real_temp=temp/4

returntemp

defgetCmd(data):

cmd=input()

ifcmd=="error":

print("异常操作",data.get())

defmain():

list_check=[]

p_data=multiprocessing.Queue()

p_getCmd=multiprocessing.Process(target=getCmd,args={p_data,})

while(1):

iflen(list_check)>15:

print("该燃气灶的出错次数过多,为了安全起见,请及时为其进行安全检查")

list_check.clewhile(1):

iflen(list_check)>15:

print("该燃气灶的出错次数过多,为了安全起见,请及时为其进行安全检查")

list_check.clear()

str=input("请打火:")

temp=MAX6675_Read()

con_flag=temp&0x04

con_flag=con_flag>>2

ifcon_flag==0:

time.sleep(1)

real_temp=get_realtemp(temp)

print("当前的温度是:"+real_temp+"℃")

ifreal_temp<200:

print("没有正常打着火,自动关闭煤气管道,请再次打火。")

list_check.append("error")

p_data.put("没有正常打着火,自动关闭煤气管道,请再次打火。")

else:

print("正常打着火了!")

while(1):

temp_now=MAX6675_Read()

real_temp_now=get_realtemp(temp_now)

ifreal_temp_now<200:

print("突然熄火,自动关闭电磁阀门")

list_check.append("error")

p_data.put("突然熄火,自动关闭电磁阀门")

randint_data=random.randint(1,10)#模拟压力传感器,判断是否炒完菜

ifrandint_data<5:

print("现在炒完菜了")

time.sleep(5)

temp_done=MAX6675_Read()

real_temp_done=get_realtemp(temp_done)

ifreal_temp_done>200:

print("可能忘记关闭燃气灶,为了安全现在自动关闭煤气!")

p_data.put("可能忘记关闭燃气灶,为了安全现在自动关闭煤气!")

continue

time.sleep(2)

else:

print("MAX6675不在线请检查,存在安全隐患!请立即联系维修人员")

str=input("请打火:")

temp=MAX6675_Read()

con_flag=temp&0x04

con_flag=con_flag>>2

ifcon_flag==0:

time.sleep(1)

real_temp=get_realtemp(temp)

print("当前的温度是:"+real_temp+"℃")

ifreal_temp<200:

print("没有正常打着火,自动关闭煤气管道,请再次打火。")

list_check.append("error")

p_data.put("可能忘记关闭燃气灶,为了安全现在自动关闭煤气!")

else:

print("正常打着火了!")

while(1):

temp_now=MAX6675_Read()

real_temp_now=get_realtemp(temp_now)

ifreal_temp_now<200:

print("突然熄火,自动关闭电磁阀门")

list_check.

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论