medir duty y frecuencia


+ Reply to Thread
Results 1 to 7 of 7
  1. #1

    Default medir duty y frecuencia

    hola tengo problema con mi código me parpadea la pantalla y no logro una medición estable alguna idea de como mejorarlo y que tenga mas fluidez
    DEFINE LCD_DREG PORTC
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTC
    DEFINE LCD_RSBIT 1
    DEFINE LCD_EREG PORTC
    DEFINE LCD_EBIT 0
    define lcd_lines 2
    define intosc 4
    low portc.2
    DEFINE ADC_BITS 8
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 50
    ANSEL = %11111111
    ANSELH = %00000000
    lectura var word
    lectura2 var word
    resultado VAR word
    resultado2 var word
    f var word
    bajo VAR WORD
    alto VAR WORD
    total VAR WORD
    duty VAR WORD



    lcdout $fe,1," iniciando "
    PAUSE 500
    LCDOUT $FE, 1

    inicio:


    ADCIN 1, LECTURA
    RESULTADO = (LECTURA */ 500)
    adcin 3,lectura2
    resultado2 = (lectura2 */500)
    PULSIN PORTB.0 , 0 , bajo
    PULSIN PORTB.0 , 1 , alto
    total=bajo + alto
    duty = ( bajo * 100 ) / total
    if duty < 5 then duty = 0
    if duty > 90 then duty = 100
    count portB.0,200,f
    f=f *5



    paUSE 100
    LCDOut $fe , 1
    lcdout $fe ,$80 ,"DUTY:" , DEC2 duty ,"%"
    LCDOUT $fe , $C0 ,"CPS:" , DEC3 f ,"hz"
    LCDOUT $fe, $8a, "V=", DEC (RESULTADO/10),".",dec1 resultado
    lcdout $fe,$c9, " A=", dec (resultado2/100),".",dec1 resultado2



    GOTO inicio
    end

  2. #2
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305

    Default Re: medir duty y frecuencia

    Well, I don't see a chip number in there anywhere and a schematic would be nice. Would be good also if you gave the part number of the display.

    I've yet to see the oscillator set using define intosc 4 but I've been wrong recently.

  3. #3

    Default Re: medir duty y frecuencia

    perdon pic16f883

  4. #4

    Default Re: medir duty y frecuencia

    subo simulacion en proteus y archivos
    Attached Files Attached Files

  5. #5
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305

    Default Re: medir duty y frecuencia

    Well I don't have Proteus so I can't look at your simulation. However define lcd_lines 2 needs to be define LCD_LINES 2. Define can be anything but just like all your other lcd stuff the define itself has to be in upper case.

    It looks like you need to do some setting of configs for the oscillator also.

  6. #6

    Default Re: medir duty y frecuencia

    Cambie el oscilador a 8mhz y puse en mayúsculas las definiciones lcd y sigue andando mal algún ejemplo para hacerlo con el timer1 voy usar pic16f883

  7. #7
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305

    Default Re: medir duty y frecuencia

    So Google translate is failing me but if you're still using the code from post #1 and using a 16f883 you need to set the OSCCON and maybe the CONFIG1 register. Telling PBP3 to interpret the code at 8 MHZ is done by "define OSC 8" where you've got define intosc 4. The OSCCON register is where you set the chip to run at 8 MHz. If you've updated your code please use the code tags box and post your code.

    Sometimes the issue is the LCD so giving the part number of it may help. There are quite a few examples in this forum using timer 1 but I'm not sure why, with above code, you need it. Although some will scream heresy I'd recommend slowing down the display of the values so you can see what's going on. PAUSE 100 may not allow you to see what's happening.

    I also think your LCDOUT lines need work. I'm not sure where lines $8a or $c9 are located. At least they're not in the PBP chart. Maybe $80 and $C0 will work better.

Similar Threads

  1. Duty cycle - Another Math dilemma
    By Ramius in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 28th September 2012, 01:33
  2. Duty Cycle
    By Gord11 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 29th September 2011, 08:53
  3. How can I measure Duty cycle ?
    By MaxiBoost in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 28th December 2006, 15:02
  4. Help with PWM and duty and integers
    By JDM160 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th March 2005, 06:03
  5. Duty Cycle Dilemmas
    By crankshaft in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 27th February 2003, 12:40

Posting Permissions

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