signal integrity - Page 2


Closed Thread
Page 2 of 2 FirstFirst 12
Results 6 to 10 of 10
  1. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    O.K., for now i've to go out for few hours, but as soon i return, i'll figure out something. IMO using some TIMER interrupts will be more efficient and easier. I'll let you know.

    All we need it's an interrupt every 8.3333333 msec. Once we have it, we just have to play with HIGH and LOW timing to the outputs.

    And then loop it 600 time will gives you 5 secondes.
    Last edited by mister_e; - 21st January 2005 at 18:21.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Lightbulb

    Before i really left my home,

    Is 60Hz is your AC line frequency? In this case, use this frequency to generate interrupt and then play with timing.

    One another thought, i don't know if your PIC have a PWM module. Case yes, Use this pin an let it run @ 120 HZ at whatever duty cycle. Connect this PWM pin to another pin who can give you interrupt. When you jump to the interrupt routine, play with the duty cycle you need. This is the easyest i can figure now.

    Now i really go
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #8
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    The attached code is based on the TIMER1 interrupt. For an 16F877 but the theory is there.

    Have fun!
    Attached Files Attached Files
    Last edited by mister_e; - 24th January 2005 at 10:36.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #9
    Join Date
    Jul 2004
    Location
    CA
    Posts
    78


    Did you find this post helpful? Yes | No

    Default

    I was wondering how do I control the pwm for this. lets say I have a button .. and while I pressed the button the PWM will increase.. but when the button is not pressed the pwm pauses. and when the button is pressed again the pwm resumes where it was paused.

    I can think of it like this

    for i = 0 to 100
    if(i < PwmIncSTEP) PortD.1 = 1
    if(i >= PwmINCStep) PortD.1 = 0

    Next i

    There is one questionable thing about this, when I have a led at the output to test the pwm. i see like a flickering. the reason why I think this is the case. is because the correct pause sequence is not there. Can you please help with a better solution
    thanks.

    Srig

  5. #10
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    There is one questionable thing about this, when I have a led at the output to test the pwm. i see like a flickering. the reason why I think this is the case. is because the correct pause sequence is not there. Can you please help with a better solution
    remove the capacitor around your 20MHZ crystal an post the answer.

    I was wondering how do I control the pwm for this. lets say I have a button .. and while I pressed the button the PWM will increase
    refer to this section
    Code:
        ' Let's see how many time we have come here
        ' -----------------------------------------
        '
    	if PWMIncStep<600 then
    		PWMIncStep=PWMIncStep + 1  ' not enough, come again and do 
    		                           ' one more PWM increment step.
    	else
            pwmincstep = 0  ' enough is enough, pass go and claim 200$
                            ' Also, since you're there redo the ramp-up
                            '
            toggle timerled ' toggle status LED
    	endif
    the easyest solution is to add a simple IF THEN statement

    Code:
        ' Let's see how many time we have come here
        ' -----------------------------------------
        '
    	if PWMIncStep<600 then
                If PushButton  then   	' If pushbutton is pressed    
                   PWMIncStep=PWMIncStep + 1  ' do the PWM
                endif 
    	else
            pwmincstep = 0  ' enough is enough, pass go and claim 200$
                            ' Also, since you're there redo the ramp-up
                            '
            toggle timerled ' toggle status LED
    	endif
    Last edited by mister_e; - 25th January 2005 at 01:26.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Replies: 24
    Last Post: - 1st December 2009, 08:01
  2. Measuring p-p of a 1.5v to 12v ac signal?
    By sccoupe in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th October 2009, 16:22
  3. Decoding an incoming infrared signal: need advice
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 9th May 2008, 16:28
  4. PIC16F684 + LCD to use the 256bytes of EEPROM - HELP
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 7th March 2008, 14:19
  5. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts