Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
As for the crappy screen shot video, Have yet to figure out why the wave forms are way different but they appear close to being 180 degrees out of phase with the delay issue.
....Maybe this will help someone using the logic tool....
This is true, but it is only a theory. In practice you would want to sample about five times in one cycle (of the highest sine freq.). If you have proper low-pass filtering etc.If the sample rate is less than twice the highest frequency of the data, it will alias – it will look like something it's not.
One of the great programmer of all times or I think he is said if you can write code good code in a loop you'll never write good code using timers or interrupts I see his point.
As I was viewing the logic tool I did view all the different sample rates and investigated the different signal outputs by sliding the view bar across the bottom of the view window. I found the wave changes as I went from left to right. I didn't realize about the alliseding.
Thanks for all the interesting reading. I have a folder which I put sections of this thread into for reference as I do for most all my projects.
**broken link removed**Thanks for the suggestion Eric. I think there's almost enough info here for an article – it shouldn't be buried in a 20 page forum post. I'll work on fleshing it out. The PICkit 2 is a versatile tool to have available.
// this assigns PWM output onto P1A, P1B, and P1C pins
// Note: The PWM Steering mode is available only when the CCP1CON register bits
// CCP1M<3:2> = 11 and P1M<1:0> = 00. Also, the TRIS bits must be set to output
// mode ('0') to enable the pin output driver in order to see the PWM signal on the pin
PSTRCON = $07 // sets all outputs
// P1A-P1B polarity
// CCP1CON bits 3-0 CCP1M<3:0>: Enhanced CCP Mode Select bits
// 1100 = PWM mode; P1A, P1C active-high; P1B, P1D active-high
// 1101 = PWM mode; P1A, P1C active-high; P1B, P1D active-low
// 1110 = PWM mode; P1A, P1C active-low; P1B, P1D active-high
// 1111 = PWM mode; P1A, P1C active-low; P1B, P1D active-low
//
// calling pwm.Start1() sets CCP1CON = $0C, so bits[3:0] = 1100 (setting all active high)
// to get P1A and P1B opposite, try setting bit1 = 0 and bit0 = 1
CCP1CON.bits(1) = 0
CCP1CON.bits(0) = 1
{
****************************************************************************
* Name : Start1 *
* Purpose : Start PWM Channel 1 *
****************************************************************************
}
Public Sub Start1()
CCP1CON = $0c ' $0c PWM mode P1A, P1C active high :P1B, P1D active high
Output(FPWM1Pin)
Output(FPWM2Pin)
Output(FPWM3Pin)
FTMR2ON = 1
PSTRCON = $0F ' PWM output steering register
End Sub
{
I had the CCP1CON in the PWM2 module but set the wrong bits. I never tried running with the correct CCP1CON in the PWM2 module
but need to set bit 1 and 0Code:{ **************************************************************************** * Name : Start1 * * Purpose : Start PWM Channel 1 * **************************************************************************** } Public Sub Start1() CCP1CON = $0c ' $0c PWM mode P1A, P1C active high :P1B, P1D active high Output(FPWM1Pin) Output(FPWM2Pin) Output(FPWM3Pin) FTMR2ON = 1 PSTRCON = $0F ' PWM output steering register End Sub {
correct bit settings
CCP1CON.bits(1) = 0
CCP1CON.bits(0) = 1