Variable PWM PIC18F2431


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    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

  2. #2
    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 21:22.

  3. #3
    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, 00:06
  2. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  3. Variable PWM on 2 Channels using software.
    By Tissy in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd September 2006, 01:34
  4. pwm to pin using variable
    By wsmrite in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 7th April 2006, 17:08
  5. Tidying Up PWM Routine
    By Tissy in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 21st February 2005, 00: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