LDmicro0.1 MICRO=Microchip PIC16F887 40-PDIP CYCLE=200 us at Timer1, YPlcCycleDuty:0, ConfigurationWord(s):0x3F72 CRYSTAL=20000000 Hz BAUD=2400 Hz COMPILED=C:\Users\jm\Documents\LDmicro\PTO_drukkerij\PTO_drukpers_F887.hex IO LIST XSTART at 33 0 0 Xadd at 34 0 0 Xsub at 35 0 0 YPTO at 26 0 0 Ycom_digit0 at 15 0 0 Ycom_digit1 at 16 0 0 Ycom_digit2 at 17 0 0 Ycom_digit3 at 18 0 0 Yled at 30 0 0 Yseg_a at 19 0 0 Yseg_b at 20 0 0 Yseg_c at 21 0 0 Yseg_d at 22 0 0 Yseg_e at 27 0 0 Yseg_f at 28 0 0 Yseg_g at 29 0 0 END PROGRAM RUNG COMMENT -- Drukpers folie oprolsysteem MGP Okt 18 END RUNG PARALLEL SERIES CONTACTS Rplus 1 0 CONTACTS Rmin 1 0 TON Tdel 500000 0 END OSR END PERSIST PULSE1 END RUNG COMMENT -- UP/DWN buttons, only when stepper is not working (Rgo) END RUNG CONTACTS Xadd 1 0 CONTACTS Rgo 1 0 TON T5 10000 0 COIL Rplus 0 0 0 0 END RUNG CONTACTS Xsub 1 0 CONTACTS Rgo 1 0 TON T7 10000 0 COIL Rmin 0 0 0 0 END RUNG COMMENT --button repeat speed and value of counting pulses END RUNG PARALLEL CONTACTS Rplus 0 0 CONTACTS Rmin 0 0 END TON T6 500000 0 CONTACTS Rbtspd 1 0 TON T1 8000 0 TOF T2 6000 0 COIL Rbtspd 0 0 0 0 END RUNG PARALLEL CONTACTS Rplus 0 0 CONTACTS Rmin 0 0 END CONTACTS Rbtspd2 1 0 TON T3 40000 0 TOF T4 40000 0 COIL Rbtspd2 0 0 0 0 END RUNG CONTACTS Rplus 0 0 PARALLEL SERIES CONTACTS Rbtspd2 1 0 OSR END SERIES CONTACTS Rbtspd 1 0 OSR END END COIL Radd 0 0 0 0 END RUNG CONTACTS Rmin 0 0 PARALLEL SERIES CONTACTS Rbtspd2 1 0 OSR END SERIES CONTACTS Rbtspd 0 0 OSR END END COIL Rsub 0 0 0 0 END RUNG SHORT CONTACTS Radd 0 0 OSR LES PULSE1 8000 ADD PULSE1 PULSE1 200 END RUNG SHORT CONTACTS Rsub 0 0 OSR GEQ PULSE1 200 SUB PULSE1 PULSE1 200 END RUNG PARALLEL EQU PULSE1 8000 EQU PULSE1 0 END COIL Yled 0 0 0 0 END RUNG COMMENT -- Start cyclus of xxx pulses END RUNG PARALLEL SERIES CONTACTS XSTART 1 0 OSR END SERIES CONTACTS REND 1 0 CONTACTS Rgo 0 0 END END COIL Rgo 0 0 0 0 END RUNG COMMENT -- Generating clock for the fastes clock, one clock in the same cycle END RUNG ADD clock clock 1 END RUNG EQU clock 3 COIL Rclock 0 0 0 0 END RUNG COMMENT -- PTO puls train output pin. END RUNG CONTACTS Rgo 0 0 CONTACTS Rclock 0 0 OSR PARALLEL COIL YPTO 0 0 0 0 ADD COUNT COUNT 1 END END RUNG EQU COUNT PULSE1 OSR PARALLEL MOVE COUNT 0 COIL REND 0 0 0 0 END END RUNG COMMENT ------- DISPLAY ROUTINE ------------------------------------------------------------------- END RUNG COMMENT Common program: how to drive a multiplexed 7-segment LED display.\r\nThis is for a 4-digit common-anode display but it is easy to modify to CC display's. END RUNG COMMENT ---------------------------------------------------------------------------------------------- END RUNG MOVE speed PULSE1 END RUNG PARALLEL DIV digit3 speed 1000 MUL digit3x digit3 1000 SUB val speed digit3x DIV digit2 val 100 MUL digit2x digit2 100 SUB valp val digit2x DIV digit1 valp 10 MUL digit1x digit1 10 SUB digit0 valp digit1x END END RUNG CONTACTS Rdosc 1 0 COIL Rdosc 0 0 0 0 END RUNG CONTACTS Rdosc 0 0 CTC Cdigit 15 0 / END RUNG COMMENT Use the Ycom_digitx lines to drive the base of the PNP transistor for CA display's END RUNG PARALLEL SERIES GEQ Cdigit 1 LEQ Cdigit 3 PARALLEL COIL Ycom_digit0 1 0 0 0 MOVE digit digit0 END END SERIES GEQ Cdigit 5 LEQ Cdigit 7 PARALLEL COIL Ycom_digit1 1 0 0 0 MOVE digit digit1 END END SERIES GEQ Cdigit 9 LEQ Cdigit 11 PARALLEL COIL Ycom_digit2 1 0 0 0 MOVE digit digit2 END END SERIES GEQ Cdigit 13 LEQ Cdigit 15 PARALLEL COIL Ycom_digit3 1 0 0 0 MOVE digit digit3 END END END END RUNG COMMENT ---Driving the segment pins of the display directly from the GPIO pins to the GND END RUNG COMMENT --add comment here-- END RUNG NEQ Cdigit 0 NEQ Cdigit 4 NEQ Cdigit 8 NEQ Cdigit 12 MASTER_RELAY END RUNG PARALLEL SERIES NEQ digit 1 NEQ digit 4 COIL Yseg_a 1 0 0 0 END SERIES NEQ digit 5 NEQ digit 6 COIL Yseg_b 1 0 0 0 END SERIES NEQ digit 2 COIL Yseg_c 1 0 0 0 END SERIES NEQ digit 1 NEQ digit 4 NEQ digit 7 COIL Yseg_d 1 0 0 0 END SERIES PARALLEL EQU digit 0 EQU digit 2 EQU digit 6 EQU digit 8 END COIL Yseg_e 1 0 0 0 END SERIES NEQ digit 1 NEQ digit 2 NEQ digit 3 NEQ digit 7 COIL Yseg_f 1 0 0 0 END SERIES NEQ digit 0 NEQ digit 1 NEQ digit 7 COIL Yseg_g 1 0 0 0 END END END RUNG MASTER_RELAY END RUNG COMMENT -------------- END DISPLAY ROUTINE ----------------------------------------------------- END RUNG COMMENT ---Reset the clock output within the same cycle END RUNG EQU clock 3 MOVE clock 0 END