Sunteți pe pagina 1din 1

'Timing info: 'There are 120 half-cycles in a 60Hz AC waveform 'We want to be able to trigger a triac at any of 256

'points inside each half-cycle. So: '1 Half cycle takes 8 1/3 mS '1/256 of one half cycle takes about 32.6uS 'The Pause function here waits (34 * 0xD)uS, plus 3uS overhead 'Overhead includes CALL PAUSE. 'This was originally assembled using Parallax's "8051 style" 'assembler, and was not optimized any further. I suppose 'it could be modified to be closer to 32 or 33uS, but it is 'sufficient for my testing purposes. list 16c84 movlw tris movlw tris WaitLow: btfss goto WaitHigh: btfsc goto call bcf movlw movwf call bsf decf movf movwf goto Pause: movlw movwf Label1: decfsz goto decfsz goto return 0xC Label1 0xD Pause 'Decrement C 'If C is not zero, goto Label1 'Decrement D 'If D is not zero, goto Pause 'Return 0xFD 0x5 0xFF 0x6 '11111101 'Port A '11111111 'Port B 'Wait for zero-crossing start 0x5,0x0 'Port A, Bit 1 WaitLow 'If high, goto WaitLow 'Wait for end of Zero Crossing 0x5,0x0 'Port A, Bit 1 WaitHigh'If low, goto waitHigh Pause 'Wait for 0xD * 34 + 3 uS 0x5,0x1 'Put Low on port A, Bit 1 0x3 'Put 3 into W 0xD 'Put W into 0xD Pause 'Call Pause, 105 uS 0x5,0x1 'Put High on Port A, Bit 1 0xE 'Decrement E 0x6,W 'Copy Port B to W 0xD 'Copy W to 0xD Start 'Wait for zero Crossing 'This pauses for 0xD * 34 + 3 Micro Seconds 'Our goal is approx. 32 uS per 0xD 'But this is close enough for testing 0xA 'Move 10 to W 0xC 'Move W to 0xC

S-ar putea să vă placă și