The array should be of WORDs if you want it to hold values greater than 255.Code:sineval var byte[36] sineval[0] = 512 sineval[1] = 583 ...
PROTEUS Rules!!
The array should be of WORDs if you want it to hold values greater than 255.Code:sineval var byte[36] sineval[0] = 512 sineval[1] = 583 ...
PROTEUS Rules!!
DT
What Darrel said.
AND
In a post made March 13th:You have several values larger than 796 (4*199 (which is what you have PR2 set to, remember we've been thru this)) in your lookuptable so you are "overdriving" the dutycycle register and "clipping" will occur.You answered your own question in (1) from the Midrange manual:
(1) " If the PWM duty cycle value is longer than the PWM period, the CCPx pin will not be cleared. This allows a duty cycle of 100%".
Any dutycycle value above 796 will result in 100% dutycycle. In other words your SIN-output will be distorted/clipped.
/Henrik.
Hi to all
I tried to modify the code according to Darrel Taylor and HenrikOlsson comments but the problem still exits, let me put in real hardware and see what happen.
And here is modified code but the output is still like that posted in the previous post.
Thanks.Code:define OSC 4 Wsave var byte $70system Wsave1 var byte $A0system Wsave2 var byte $120system Wsave3 var byte $1A0system STEPCOUNT var byte STEPCOUNT1 var byte LED1 VAR PORTB.1 STEPCOUNT = 0 'pointer for phase one in sinearray STEPCOUNT1 = 12 'pointer for phase two in sine array ADCON0 = %00000000 ADCON1 = %00000000 TRISB = %11111101 TRISC = %11111001 'PMW output for CCP1 AND CCP2 TRISA = %11111111 TMR2 = 0 PR2 = 199 'generate 5khz 'set for 18Khz HPWM CCP1CON = %00001100 'set CCP1 for PWM OPERATION CCP2CON = %00001100 'set CCP2 for PWM OPERATION T2CON = %00000100 'TIMER2ON and prescale of 1:1 sineval var word[36] sineval[0] = 512 sineval[1] = 556 sineval[2] = 599 sineval[3] = 640 sineval[4] = 676 sineval[5] = 707 sineval[6] = 733 sineval[7] = 752 sineval[8] = 763 sineval[9] = 767 sineval[10] =763 sineval[11] =752 sineval[12] =733 sineval[13] =707 sineval[14] =676 sineval[15] =640 sineval[16] =599 sineval[17] =556 sineval[18] =512 sineval[19] =468 sineval[20] =425 sineval[21] =385 sineval[22] =348 sineval[23] =317 sineval[24] =291 sineval[25] =272 sineval[26] =261 sineval[27] =257 sineval[28] =261 sineval[29] =272 sineval[30] = 291 sineval[31] = 317 sineval[32] = 348 sineval[33] = 385 sineval[34] = 425 sineval[35] = 468 timerone var word Temp var byte Temp1 var byte INCLUDE "DT_INTS-14.bas" ; Base Interrupt System emp 'INCLUDE "ReEnterPBP.bas" ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler TMR1_INT, _sine, PBP, yes endm INT_CREATE ; Creates the interrupt processor ENDASM T1CON = 000001 ; Prescaler = 1;1, TMR1 ON @ INT_ENABLE TMR1_INT ; Enable Timer 1 Interrupts timerone = 65080' gives1818hz nterruptfrequency or about 50 htz sine Main: PAUSE 5 GOTO Main '---[TMR1_INT - interrupt handler]------------------------------------------ sine: T1CON = 000000 'stop the timer TMR1L = timerone.byte0 'reload the timer TMR1H = timerone.byte1 T1CON = 000001 ' start the timer TeMP = sineval[STEPCOUNT] CCP1CON.4 = Temp.0 ' bit 0 CCP1CON.5 = Temp.1 ' bit 1 CCPR1L = Temp >>2 'Bit 2-7 TeMP1 = sineval[STEPCOUNT1] CCP2CON.4 = Temp1.0 ' bit 0 CCP2CON.5 = Temp1.1 ' bit 1 CCPR2L = Temp1 >>2 'Bit 2-7 TOGGLE LED1 stepcount = stepcount +1 stepcount1 = stepcount1 +1 if stepcount =36 then stepcount =0 if stepcount1 =36 then stepcount1 =0 @ INT_RETURN
Hi to all
I try to download my program from my computer(wind7)using PIC16f877 development board and ET-CAB10PIN V2 interfacing cable but WHEN I try to run winpic800 software.
the following problems arise.
(1)failed to import Smport.sys
(2)when I check the hardware it say hardware not responding
any one can help me how to solve this problems
thanks
Last edited by Demon; - 30th March 2012 at 18:25.
Hi every one
(1) Previous I thought that the problem of flat spot on my SPWM signal was due to the simulator(ISIS) but I was wrong because I implement it on the actual hardware using PIC16F877V1-V2 DEVELOPMENT BOARD board and DLIS40L oscilloscope but the problem still remain now I'm totally confused what cause that problem of flat spot to my wave form. I try to scale my look up table so that my dutycycle lie on the range of (0 to 4*199) but nothing was change to my signal
when viewed.
(2)ARE the ten bit look table is not working on 8bit chip like 16F877 0R 16F777 ? I think those values greater than 255 is one cause that problems
(3) I'm not clear on the WINPIC800V358 software parameter on the attachment.Code:define OSC 4 Wsave var byte $70system Wsave1 var byte $A0system Wsave2 var byte $120system Wsave3 var byte $1A0system STEPCOUNT var byte STEPCOUNT1 var byte LED1 VAR PORTB.1 STEPCOUNT = 0 'pointer for phase one in sinearray STEPCOUNT1 = 12 'pointer for phase two in sine array ADCON0 = %00000000 ADCON1 = %00000000 TRISB = %11111101 TRISC = %11111001 'PMW output for CCP1 AND CCP2 TRISA = %11111111 TMR2 = 0 PR2 = 199 'generate 5khz 'set for 18Khz HPWM CCP1CON = %00001100 'set CCP1 for PWM OPERATION CCP2CON = %00001100 'set CCP2 for PWM OPERATION T2CON = %00000100 'TIMER2ON and prescale of 1:1 sineval var word[36] sineval[0] = 512 sineval[1] = 556 sineval[2] = 599 sineval[3] = 640 sineval[4] = 676 sineval[5] = 707 sineval[6] = 733 sineval[7] = 752 sineval[8] = 763 sineval[9] = 767 sineval[10] =763 sineval[11] =752 sineval[12] =733 sineval[13] =707 sineval[14] =676 sineval[15] =640 sineval[16] =599 sineval[17] =556 sineval[18] =512 sineval[19] =468 sineval[20] =425 sineval[21] =385 sineval[22] =348 sineval[23] =317 sineval[24] =291 sineval[25] =272 sineval[26] =261 sineval[27] =257 sineval[28] =261 sineval[29] =272 sineval[30] = 291 sineval[31] = 317 sineval[32] = 348 sineval[33] = 385 sineval[34] = 425 sineval[35] = 468 timerone var word Temp var byte Temp1 var byte INCLUDE "DT_INTS-14.bas" ; Base Interrupt System emp INCLUDE "ReEnterPBP.bas" ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler TMR1_INT, _sine, PBP, yes endm INT_CREATE ; Creates the interrupt processor ENDASM T1CON = 000001 ; Prescaler = 1;1, TMR1 ON @ INT_ENABLE TMR1_INT ; Enable Timer 1 Interrupts timerone = 65080' gives1818hz nterruptfrequency or about 50 htz sine Main: PAUSE 5 GOTO Main '---[TMR1_INT - interrupt handler]------------------------------------------ sine: T1CON = 000000 TMR1L = timerone.byte0 TMR1H = timerone.byte1 T1CON = 000001 TeMP = sineval[STEPCOUNT] CCP1CON.4 = Temp.0 ' bit 0 CCP1CON.5 = Temp.1 ' bit 1 CCPR1L = Temp >>2 'Bit 2-7 TeMP1 = sineval[STEPCOUNT1] CCP2CON.4 = Temp1.0 ' bit 0 CCP2CON.5 = Temp1.1 ' bit 1 CCPR2L = Temp1 >>2 'Bit 2-7 TOGGLE LED1 stepcount = stepcount +1 stepcount1 = stepcount1 +1 if stepcount =36 then stepcount =0 if stepcount1 =36 then stepcount1 =0 @ INT_RETURN
Any one can help me to solve these problems
Thankx
Bookmarks