LDmicro0.1 MICRO=Atmel AVR ATmega128 64-TQFP CYCLE=2000 CRYSTAL=8000000 BAUD=2400 COMPILED=C:\Documents and Settings\Administrator\デスクトップ\Ladder Logic for PIC and AVR\新しいフォルダ\ATmega128_7seg-display_AD.hex IO LIST Ycom_digit0 at 2 Ycom_digit1 at 3 Ycom_digit2 at 4 Ycom_digit3 at 5 Yseg_a at 10 Yseg_b at 11 Yseg_c at 12 Yseg_d at 13 Yseg_e at 14 Yseg_f at 15 Yseg_g at 16 END PROGRAM RUNG CONTACTS RCINC 1 TON T1 20000 TOF T2 20000 COIL RCINC 0 0 0 END RUNG CONTACTS RCINC 0 CTC CAIN 9999 END RUNG MUL SCALE CAIN 1 END RUNG DIV ACTUAL SCALE 1 END RUNG COMMENT Sample program: how to drive a multiplexed 7-segment LED display. This is\r\nfor a 4-digit(SEC20100525) common-Anode(SEC20100525) display but it is easy to modify. END RUNG COMMENT With a 5 ms cycle time, this will oscillate at 100 Hz, which should be\r\nokay (33 Hz refresh rate, 1/3 duty cycle). END RUNG CONTACTS Rdosc 1 COIL Rdosc 0 0 0 END RUNG CONTACTS Rdosc 0 CTC Cdigit 3 END RUNG COMMENT Use the Ycom_digitx lines to drive the base/gate of the NPN transistor/\r\nn-FET used to switch the cathode of digit x. END RUNG PARALLEL SERIES EQU Cdigit 0 PARALLEL COIL Ycom_digit0 0 0 0 MOVE digit digit0 END END SERIES EQU Cdigit 1 PARALLEL COIL Ycom_digit1 0 0 0 MOVE digit digit1 END END SERIES EQU Cdigit 2 PARALLEL COIL Ycom_digit2 0 0 0 MOVE digit digit2 END END SERIES EQU Cdigit 3 PARALLEL COIL Ycom_digit3 0 0 0 MOVE digit digit3 END END END END RUNG COMMENT You can drive the segment pins of the display directly from the GPIO pins,\r\nYseg_a to Yseg_b. REGISTER= 1.0 K OHM X 7 END RUNG PARALLEL SERIES NEQ digit 1 NEQ digit 4 COIL Yseg_a 1 0 0 END SERIES NEQ digit 5 NEQ digit 6 COIL Yseg_b 1 0 0 END SERIES NEQ digit 2 COIL Yseg_c 1 0 0 END SERIES NEQ digit 1 NEQ digit 4 NEQ digit 7 COIL Yseg_d 1 0 0 END SERIES PARALLEL EQU digit 0 EQU digit 2 EQU digit 6 EQU digit 8 END COIL Yseg_e 1 0 0 END SERIES NEQ digit 1 NEQ digit 2 NEQ digit 3 NEQ digit 7 COIL Yseg_f 1 0 0 END SERIES NEQ digit 0 NEQ digit 1 NEQ digit 7 COIL Yseg_g 1 0 0 END END END RUNG COMMENT Fill in your program here; just set the output that you want on digit0,\r\ndigit1, and digit2. END RUNG DIV digit3 ACTUAL 1000 END RUNG MUL B digit3 1000 END RUNG SUB C ACTUAL B END RUNG DIV digit2 C 100 END RUNG MUL B1 digit2 100 END RUNG SUB C1 C B1 END RUNG DIV digit1 C1 10 END RUNG MUL B2 digit1 10 END RUNG SUB digit0 C1 B2 END RUNG COMMENT by Jonathan Westhues, June 2005 END