pulsin fails in real world


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2005
    Posts
    130

    Default pulsin fails in real world

    I have this program for pic 12F683, I resumed the program for the relevant parts (of course all variables are properly defined):

    @ device INTRC_OSC_NOCLKOUT
    DEFINE OSC 4
    DEFINE PULSIN_MAX 65535

    ansel=0
    trisio=%00100000

    pulso VAR WORD
    boton VAR GPIO.5
    LED VAR GPIO.2
    pwmduty VAR BYTE[7] '

    pwmduty[0]= 16
    pwmduty[1]= 32
    pwmduty[2]= 64
    pwmduty[3]= 127
    pwmduty[4]= 150
    pwmduty[5]= 192
    pwmduty[6]= 255


    prendido=0
    pwmstat=6
    frecu=250
    testigo=0


    LOOP:

    tdp=2
    PulsIn boton, 0, pulso
    Pause 10


    IF pulso >0 Then


    IF pulso > 20000 Then
    TDP=3
    Else
    tdp=1
    EndIF

    EndIF


    Select Case tdp

    Case 1
    IF prendido =1 Then
    prendido =0
    HPwm 1,0,frecu
    Else
    prendido=1
    HPwm 1,pwmduty[pwmstat],frecu
    EndIF

    Case 3

    GoSub spwm

    End Select

    tdp=2


    GoTo loop

    the program is the main loop for a multilevel light, the subroutine sets the pwm duty cycle.

    well it simulates ok, but in the real world, the circuit behaves totally erratic

    Im guess the problem is in the switch, but I'm completelly lost. Or maybe the Hardware PWM is not working ok?

    What can I do?

    thanks in advance
    Last edited by peu; - 5th March 2005 at 23:13.

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


    Did you find this post helpful? Yes | No

    Default

    i didn't check your whole code but, have you try with a pulse generator instead of the switches?? if so, what are the results?

    did you use a scope to see PWM and Switches signal. What about your supply line (again and again)
    Steve

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

Similar Threads

  1. Replies: 17
    Last Post: - 12th April 2014, 03:17
  2. Better understanding PULSIN
    By Wirecut in forum mel PIC BASIC
    Replies: 12
    Last Post: - 29th June 2008, 11:17
  3. Funny PULSIN values: what is going on???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th April 2008, 09:02
  4. Pulsin 16F819 problem
    By rekcahlaer in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 11th April 2007, 14:52
  5. PULSIN and RCTIME
    By Dwayne in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 4th November 2004, 15:45

Members who have read this thread : 0

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