Sign in to follow this  
Followers 0
professor_jonny

structured txt zebra print help

1 post in this topic

I have set up a structured txt program in cx programmer for printing to an epl formatted printer but the problem i have is that the cpu serial port does not seem to have a buffer and if i send another packet at the scan rate of the plc it fails to print. i have done it this way as i can easilly change the string with out converting the strings to hex and storing them in memory of the plc. i have my string below but im unsure how to implement a timer between each txd_cpu command without using a lot of if then statments and timers. i was thinking if i had a REPEAT UNTIL loop until the print string line number exceds the 13 lines of the label. it will increment by one each time and compair each print string with an IF THEN ELSE with multuple ELSEIF statments for each print string line. at the end of the repeat it will wait for the timer to time out add 1 ot the plint line number then reset the timer. it will then then do one print line per increment of the expression. but i dont really know how to do this im a noob in st programming and just dont know how to implement it. would someone be able to help point it out to me a simple way? i was thinking something like this but but i dont know how to implement it: PRINTLINENUMBER:=0 IF PRINT=P_On THEN; REPEAT IF print=p_on THEN; ELSEIF print line = 1 then TXD_CPU(START_PRINT_STRING_DELIMITER); ELSEIF . . rar rar rar . ELSE; ENDIF IF TIMER_DONE=P_On THEN; PRINTLINENUMBER:=PRINTLINENUMBER+1; TRSET(P_On,TIMER111); ELSE; ENDIF UNTIL print line number=13 ELSE; ENDIF (* ascii print string setup*) IF P_On=P_On THEN; START_PRINT_STRING_DELIMITER:= 'N$N'; TITLE_STRING:= 'A50,20,0,2,2,1,N,"Dynes Transport docket"$N'; TRUCK_NUMBER_STRING:= 'A100,40,0,2,2,1,N,"Truck number AA"$N'; TRAILER_NUMBER_STRING:= 'A150,60,0,2,2,1,N,"Trailer number BB"$N'; MONTH_NUMBER_STRING:= 'A200,80,0,2,2,1,N,"Month CC"$N'; DAY_NUMBER_STRING:= 'A250,100,0,2,2,1,N,"Day DD"$N'; HOUR_NUMBER_STRING:= 'A300,120,0,2,2,1,N,"Hour EE"$N'; SILOTEMP_NUMBER_STRING:= 'A350,120,0,2,2,1,N,"silo temp FF"$N'; LITRE_TRUCK_STRING:= 'A400,140,0,2,2,1,N,"Litre truck GG "$N'; LITRE_TRAILER_STRING:= 'A450,140,0,2,2,1,N,"Litre truck HH"$N'; SEAL_NUMBER_STRING:= 'A500,140,0,2,2,1,N,"Seal Number III"$N'; BARCODE_STRING:= 'B600,180,0,3,3,7,50,B," JJ"$N'; END_PRINT_STRING_DELIMITER:= 'P2$N'; ELSE; END_IF; (*insert data into string*) (* truck number string insersion*) TRUCK_NUMBER_STRING_INSERSION_POINT:= FIND(TRUCK_NUMBER_STRING,'AA'); TRUCK_NUMBER_STRING_OUTPUT:= REPLACE(TRUCK_NUMBER_STRING,TRUCK_NUMBER,2,TRUCK_NUMBER_STRING_INSERSION_POINT); (* trailer number string insersion*) TRAILER_NUMBER_STRING_INSERSION_POINT:= FIND(TRAILER_NUMBER_STRING,'BB'); TRAILER_NUMBER_STRING_OUTPUT:= REPLACE(TRAILER_NUMBER_STRING,TRAILER_NUMBER,2,TRAILER_NUMBER_STRING_INSERSION_POINT); (* month number string insersion*) MONTH_NUMBER_STRING_INSERSION_POINT:= FIND(MONTH_NUMBER_STRING,'CC'); MONTH_NUMBER_STRING_OUTPUT:= REPLACE(MONTH_NUMBER_STRING,MONTH_NUMBER,2,MONTH_NUMBER_STRING_INSERSION_POINT); (* day number string insersion*) DAY_NUMBER_STRING_INSERSION_POINT:= FIND(DAY_NUMBER_STRING,'DD'); DAY_NUMBER_STRING_OUTPUT:= REPLACE(DAY_NUMBER_STRING,DAY_NUMBER,2,DAY_NUMBER_STRING_INSERSION_POINT); (* hour number string insersion*) HOUR_NUMBER_STRING_INSERSION_POINT:= FIND(HOUR_NUMBER_STRING,'EE'); HOUR_NUMBER_STRING_OUTPUT:= REPLACE(HOUR_NUMBER_STRING,HOUR_NUMBER,2,HOUR_NUMBER_STRING_INSERSION_POINT); (* silotemp string insersion*) SILOTEMP_STRING_INSERSION_POINT:= FIND(SILOTEMP_NUMBER_STRING,'FF'); SILOTEMP_STRING_OUTPUT:= REPLACE(SILOTEMP_NUMBER_STRING,SILOTEMP_NUMBER,2,SILOTEMP_STRING_INSERSION_POINT); (* litre truck string insersion*) LITRE_TRUCK_STRING_INSERSION_POINT:= FIND(LITRE_TRUCK_STRING,'GG'); LITRE_TRUCK_STRING_OUTPUT:= REPLACE(LITRE_TRUCK_STRING,LITRE_TRUCK_NUMBER,2,LITRE_TRUCK_STRING_INSERSION_POINT); (* litre trailer string insersion*) LITRE_TRAILER_STRING_INSERSION_POINT:= FIND(LITRE_TRAILER_STRING,'HH'); LITRE_TRAILER_STRING_OUTPUT:= REPLACE(LITRE_TRAILER_STRING,LITRE_TRAILER_NUMBER,2,LITRE_TRAILER_STRING_INSERSION_POINT); (*seal number string insersion*) SEAL_NUMBER_STRING_INSERSION_POINT:= FIND(SEAL_NUMBER_STRING,'II'); SEAL_NUMBER_STRING_OUTPUT:= REPLACE(SEAL_NUMBER_STRING,SEAL_NUMBER,2,SEAL_NUMBER_STRING_INSERSION_POINT); (* barcode string insersion join strings together for barcode*) BARCODE_NUMBER:=CONCAT(TRUCK_NUMBER,TRAILER_NUMBER,LITRE_TRUCK_NUMBER,LITRE_TRAILER_NUMBER); BARCODE_NUMBER_STRING_INSERSION_POINT:= FIND(BARCODE_STRING,'JJ'); BARCODE_STRING_OUTPUT:= REPLACE(BARCODE_STRING,BARCODE_NUMBER,2,BARCODE_NUMBER_STRING_INSERSION_POINT); (* end string insersion*) (* print string contents to printer we may need to add delay in here to not send these at the scan cycle of the plc*) if P_On=PRINT THEN; (*send individual lines to cpu serial port*) TXD_CPU(START_PRINT_STRING_DELIMITER); TXD_CPU(TITLE_STRING); TXD_CPU(TRUCK_NUMBER_STRING_OUTPUT); TXD_CPU(TRAILER_NUMBER_STRING_OUTPUT); TXD_CPU(MONTH_NUMBER_STRING_OUTPUT); TXD_CPU(DAY_NUMBER_STRING_OUTPUT); TXD_CPU(HOUR_NUMBER_STRING_OUTPUT); TXD_CPU(SILOTEMP_STRING_OUTPUT); TXD_CPU(LITRE_TRUCK_STRING_OUTPUT); TXD_CPU(LITRE_TRAILER_STRING_OUTPUT); TXD_CPU(SEAL_NUMBER_STRING_OUTPUT); TXD_CPU(BARCODE_STRING_OUTPUT); TXD_CPU(END_PRINT_STRING_DELIMITER); END_IF; (*end print command*) Edited by professor_jonny

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0