Variable PWM PIC18F2431


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    May 2009
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    Thank you for your answer sougata Today I have changed to a digital scope, but I dont undestand why the pwm output some times stay freeze, or start doing the work and go to 0 volts the pwm output, other times stay in 5 volts, what can be doing it ?

    I have modified my code using pwm and a/d interrup... each time that PTMR match PTPER, the PWM module go to interrup, in PWM interrupt I start A/D conversion and load the result to Duty cycle register, after I turn off PWM interrupt, I attach here the code, I hope u can check it please and tell me some suggestion, thank you.

    Regards.
    Tom.
    Attached Files Attached Files

  2. #2
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Have you tried the R-C Filter ?

    Hi,

    In your DSO you should find a menu called acquire. In that menu there should be different options like :

    1. Sample
    2. Average
    3. Peak-Detect
    ....
    ......

    or so.

    Select the average mode --> if it supports number of samples to be programmed, select it to 128 or higher now watch the waveform with a timebase between 1ms and 5ms.

    Your PWM runs at a high frequency and is continuously changing. If your scope is running in automatic trigger mode, it is repeating the trigger as per the timebase. If you try "Autoset" on the scope, it will perhaps try to lock onto the PWM frequency. But what you are interested is the PWMed envelope.

    Using a simple RC may help.

    If I find some time I would try to duplicate your setup here. But I still doubt Your scope is not set up properly to visualize the modulation
    Regards

    Sougata

  3. #3
    Join Date
    May 2009
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    Thank you Sougata, I will test today it, later I will put here the results.

    Regards.
    Tom.

  4. #4
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Wink

    I can't see any 100nF-Cs round your PIC - is he resetting ? You can use a portpin to see it!
    Maybe it will better the AD-Converter by filtering his AVDD via 56 Ohm and 100nF against ground, but this is not the reason for your problem.

    The INTHIGH-routine starts the AD-conversion on every Interrupt, because the bit-check is faulty (or not complete).

    For PIC18-uCs: Writing to a port (PORTA) is better done by writing to the LAT-register instead of a PORT-register.
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  5. #5
    Join Date
    May 2009
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    Hi guys, I have modified my code, I removed PWM interrupt, and now Im using ADC interrup, in Continuous Loop mode each time that ADC do a conversion Interrupt is generated when the 2nd and 4th words are written to the buffer, in the interrupt service routine I load the ADC result to Duty Cycle register, I did some test using a pot, now my ADC is working correctly, 0.5 V = 10% Duty Cycle in PWM, so 5 Volts = 100 % Duty Cycle PWM, Im loading the 10 ADC result bits to 10 resolution bits from PCPWM (duty cycle registers), Im using Digital Scope, when I get the PWM output the signal stay some seconds, after I luse the PWM signal, after some second the signal come back, after the signal down, after back, etc...
    Im getting the correctly variable PWM output but the signal isnt constant, and its not good to use in a DC-DC converter, I need dont luse my PWM output.
    I think the ADC interrupt is the trouble because I luse the PWM output, I hope u can help me guys thank for ur help and time.
    I have uploaded my new code.

    Regards.
    Tom.
    Attached Files Attached Files
    Last edited by trr1985; - 11th June 2009 at 22:22.

  6. #6
    Join Date
    May 2009
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    Im back from university, I get new results, The A/D module is working fine I tested it loading the ADC result to a port C and A from pic, I used a led bar (10 leds) to check it, when I tested in PWM it work fine load the correctly value to duty cycle register, if I load 2.5 Volts in analog input, I get 50% from duty cycle in PWM output signal, my trouble now is that my signal is flickering a lot, some times stay some value for some seconds and after load other value, I think that FIFO buffer from ADC is doing wrong some thing, I changed my code today, Im using PWM interrup each time that PTMR match PTPER start the Hight priority interrupt routine service, in this interrupt service Im reading and loading the ADC result to duty cycle registers, I have attached my new code here, I have disallowed ADC interrupt.

    I hope someone can help me, thanks.

    Regards.
    Attached Files Attached Files

Similar Threads

  1. EEPROM Variables (EE_Vars.pbp)
    By Darrel Taylor in forum Code Examples
    Replies: 79
    Last Post: - 26th October 2012, 01:06
  2. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 21:36
  3. Variable PWM on 2 Channels using software.
    By Tissy in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd September 2006, 02:34
  4. pwm to pin using variable
    By wsmrite in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 7th April 2006, 18:08
  5. Tidying Up PWM Routine
    By Tissy in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 21st February 2005, 01:26

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