Thank TiagoSilva...
I also have the voltage divider approach in my mind. For my case i will scale down my 20Vdc to 5Vdc so that I can input to PIC A/D I/P Pin. (Can I apply a voltage greater than 5Vdc to the A/D i/p pin) or do you know what is the maximum voltage that I can apply to the A/D i/p pin?
Previously I use a few comparator to generate an 10Vdc PWM signal and it works well with IR2101 gate driver but now my problem is that the pwm output on CCP1 pin is only 5Vdc and when I connect this signal to IR2101 gate driver it won't work well. (did I miss out any thing before connecting to the gate driver. for e.g. buffer?)
Btw... is it possible to invert the signal on CCP1 meaning that instead of 1001 1001.. is it possible to invert it to 0110 0110? Heez...
Regarding the max voltage of the ADC i think i have read somewhere that the max positive voltage is = to the max positive voltage reference to the ADC, if no voltage reference is specified then the max is the chip positive voltage, i guess that yours is the last option... only the more crafty chips have voltage reference inputs
In any case try tho ready on the datasheet of your Pic everything regarding the internal ADC, try to find something about the voltage references and if it is internal then you won't have to connect anything else, but you'l be limited... usually it might sufice
Regarding the PWM output, you can *try* (on the simulator first might be a good idea) to use an bipolar transistor to drive the gate on the IR2101 !
Have fun !
P.S. : Regarding the logic you can try to find some ASM mnemonic to do the One's Complement or if using C/C++ use the "~" bitwise operator !
I don't know how you have the PWM setup but lets say you have it setup for 8 bits of duty cycle resolution. When setup like this, zero will be completely off and 255 will be completely on. If you want this to be the reverse then you complement the value before you put it in CCPRxL by doing xorlw 0xff.
Mike.
Hello,
weird stuff... have you checked if you're on the right register adress (to get the desired data) ???
Sometimes we can err on simple things and start looking for the more complex lol
Have a nice weekend or whats left of it !
Hi,
It's better to post the code here so that we can see what's going wrong and anything missing.
ADCON0bits.ADON = 1;
ADCON0bits.CHS0 = 1;
ADCON0bits.CHS1 = 0;
ADCON0bits.CHS2 = 0;
ADCON0bits.CHS3 = 0;
Hi,
May I know which one of them is not working? PWM of CCP1 or PWM of CCP2? Or both of them?
For the ADC part, if you're using only a single channel, why don't you use AN0 and set PCFG3CFG0 to 1110. And I don't see why do you need these:
while sampling, just put them in the initialize portion. Also, ADCON2 is not configured. Since you're using only 8-bit, the AD result should be set left justified. You should set the acquisition time and the AD clock as well.Code:ADCON0bits.ADON = 1; ADCON0bits.CHS0 = 1; ADCON0bits.CHS1 = 0; ADCON0bits.CHS2 = 0; ADCON0bits.CHS3 = 0;
Hi,Oppz.. Sorry man... I forgot to tell you that my AN0 is malfunction, that is the reason I use AN1 instead. Everything works already. The only that is not working is that I can't complement my signal from CCP1.
The code that I write on CCP2 is just having complement duty cycle.
It is just like from 1001 1111 (CCP1) become 1111 1001 (CCP2).
The problem that i'm facing is that I can't make my 1001 1111 to 0000 0110 which is bit by bit complemented or inverted.
Any suggestion?
CCPR2L = n;
CCPR1L = ~n;
Hi,
Don't really get you
Do you mean, you want the ADC result to be PWMed on CCP2 and the inverted result on CCP1?
That's what I meant. The complement operator (~) doesn't work?
Yes, that's the proper setting for ADC. Read the datasheet under ADCON2.Ya... It doesn't work... Just now u said ADCON2 I nv set up? How should I come about setting it?
Yes, that's the proper setting for ADC. Read the datasheet under ADCON2.
This register is used to select the AD clock source, the acquisition time and the result (left or right justified).
Can I know how to you see the CCP2 result? From the oscilloscope? What's the analog input voltage?
Yes you're right.
But have you tried other than 5 V? For example, if the analog input is 5 V, then the PWM duty cycle is almost 100 % and the complemented is almost 0 %. It is very difficult to read from the oscilloscope. Try 1.5 V or 2 V and see both the output.
Ya... it is about 94% duty cycle. I can see clearly that CCP2 is not inverted of CCP1. The thing that is complement is the duty cycle. meaning CCP1 having 94% duty cycle, than CCP2 is having 6% duty cycle which is not I want.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?