PLC程序中的配方应用

  1. 建立ARRAYDB
  • 集合配方需要的所有元素结构,组成一个UDT(包含范围最全)
  • 新建一组ARRAY DB,元素的个数就是配方需要的副本的个数
  • 数组DB勾选仅存储在装载内存中,以便数据量大的配方不占用数据工作存储器空间,节省资源
  • 在ARRAY DB的起始值处填写配方的具体值
  • 1200不支持ARRAY DB,所以用普通全局DB替代也可
  1. 配方表的导入导出
  • 导入
//export
#statExRecipe.req := #H_animinal.start_export_button;
#RecipeExport_Instance(REQ := #statExRecipe.req,
                       DONE => #statExRecipe.done,
                       BUSY => #statExRecipe.busy,
                       ERROR => #statExRecipe.error,
                       STATUS => #statExRecipe.status,
                       RECIPE_DB := "Product_Recipe");
  • 导出
//import
#statImRecipe.req := #H_animinal.start_import_button;
#RecipeImport_Instance(REQ:=#statImRecipe.req,
                       DONE=>#statImRecipe.done,
                       BUSY=>#statImRecipe.busy,
                       ERROR=>#statImRecipe.error,
                       STATUS=>#statImRecipe.status,
                       RECIPE_DB:="Product_Recipe");
  • 导入导出位置
  1. DBL的读出和写入
  • 从DBL读出到程序中使用,靠index索引,靠req使能,statReturnRDDBL=16#7002时表示读出完成
  • read_DBL本身是异步指令,整个过程会横跨多个扫描周期,另外因为是从存储卡读取而来,读取速度上不是很快
  • DBL因为使能了仅存储在装载内存中,故不能在线,它只有起始值,没有在线值。
  • 写入同理
//read_DBL
#statReadDBL.req := #H_animinal.start_readDBL_button;
#statReturnRDDBL:=READ_DBL(REQ := #statReadDBL.req, SRCBLK :="Product_Recipe"."THIS"[#H_animinal.recipe_index] , BUSY => #statReadDBL.busy, DSTBLK => #H_current_params);
IF 16#7002 = #statReturnRDDBL THEN
    #H_animinal.start_readDBL_button := FALSE;
END_IF;

//write DBL
#statWriteDBL.req := #H_animinal.start_writeDBL_button;
#statReturnWRDBL := WRIT_DBL(REQ := #statWriteDBL.req, SRCBLK :=#H_current_params, BUSY => #statWriteDBL.busy, DSTBLK => "Product_Recipe"."THIS"[#H_animinal.recipe_index]);
IF 16#7002 = #statReturnWRDBL THEN
    #H_animinal.start_writeDBL_button := FALSE;
END_IF;

posted @ 2024-04-30 23:22  不愿透露姓名的小村村  阅读(8)  评论(0编辑  收藏  举报