SERIN and PWM on 12f615


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2011
    Posts
    2

    Default SERIN and PWM on 12f615

    Hi,
    I'm new to PicBasicPro but it works great for the simple stuff I want to do.
    I have a lot of PIC12f615's left over from an old LED project and want to re-use them.
    My intention it so create a load of LED RGB nodes, that can attach to a main communication bus, and be indivdually controlled from one source.

    I have got SERIN2 working successfully, well, I dont really understand all the arguments yet. But I can send serial from another device and turn and LED on and off when I want.

    I have also got PWM to work well, I can fade an LED up and down, so now, i need to combine the two!

    The main problem I have is that the PWM command goes, PIN; DUTY; CYCLE and the CYCLE seems to be the length that the PWM is on for. What I want is for the PWM to be constantly on and IF data is sucessfully recived through SERIN2 and it is a number, set the PWM to that value, there for I could control the PWM via another device. But ... in my experiements.

    Tnis is how I thought it would work but it does not.

    ----------------

    DEFINE OSC 4
    output 4

    ANSEL = 0 ' disable A/D converter

    Command var byte ' variable to receive data into
    pwmval var WORD

    InputData var byte
    PulseWidth var byte

    loop:

    serin2 2,41356,0, nodata, [inputData]

    pulseWidth = inputData

    nodata:

    pwm 4,pulseWidth,1

    goto loop

    end

    --------------------

    the reason for this is, as far as I have read, the routine in nodata: will get executed when there is nothing coming in, and ideally I want that to execture a PWM and go back to listening for serial, so the CYCLE is 1. and also the 3 argument in SERIN2 is the wait ? length ? so really I dont want it to wait at all.
    If anyone could help me that would be great, all I want to do is change the PWM of and LED though SERIN21

    thanks - j

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: SERIN and PWM on 12f615

    You will have to use hardware pwm. I suggest you read the chip datasheet and set up the registers manually. I'm not a fan of PBPs HPWM.
    Charles Linquist

  3. #3
    Join Date
    Nov 2011
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: SERIN and PWM on 12f615

    so the command PWM is 'software PWM' ?
    as far as I can tell a bug limitation of the command is that it is only on for CYCLE.

    can HPWM be set to go in the background whilst other loops are executed ?

    it's a shame as soft PWM works pretty well for LEDs

  4. #4
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: SERIN and PWM on 12f615

    The "PWM" command is bit banged.

    And of course HPWM will run in the background. PBPs HPWM command will probably be perfect for running LEDs.
    Charles Linquist

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