How to write pwm using picbasic pro?


Results 1 to 3 of 3

Threaded View

  1. #3
    Join Date
    Dec 2009
    Location
    Warrenton Mo
    Posts
    7


    Did you find this post helpful? Yes | No

    Default Re: How to write pwm using picbasic pro?

    You didn't mention which type of PWM you wanted, HWPM for continous PWM, or regular. Here is a quickie program that flashes a LED from full bright to dimly lit. It's good for an indication of some kind.
    Install a LED on portb.0

    Code:
    T var byte' set-up the loop variable
    For t=1 to 20' amount of bright/dim  flashes
    portb.0=1:pause 90:portb.0=0' full bright ON time then turn OFF---experiment with the ON time.
    PWM portb.0,20,80' the 20 is LED brightness, the 80 is it's ON time--Again experiment with the numbers, try changing the 20 to 50.
    TRISb=0' Once PWM is used on a pin, then that pin only wants PWM to be used. The TRISb resets the pin back to normal output.
    next t' end of loop
    If you had inputs on portb, like portb.1, and portb.2, then use TRISb=%00000110
    .
    While PWM is operating, nothing else is being done. Same way with SOUND. When using a servo, when PWM stops, the servo no longer gets data causing it to lose it's position if it was under a load. To correct this you would need to use the HWPM.
    Hope this helped.
    Electroken
    Last edited by Demon; - 6th May 2013 at 00:04. Reason: Used CODE tags so :p does not turn into emoticon
    The more I think about it the worse off I am

Similar Threads

  1. conversion from picbasic to picbasic pro
    By winjohan in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st November 2011, 18:00
  2. PICBasic Pro vs Proton PICBasic
    By CosMecc in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 3rd November 2006, 16:11
  3. How would i write this in pic basic pro (Servo controller)
    By Jhdgkss in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th February 2006, 08:21
  4. PicBasic Pro - Is it possible
    By tracking in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 23rd May 2005, 21:14
  5. PicBasic Pro & PicBasic syntax different
    By Billyc in forum General
    Replies: 5
    Last Post: - 16th April 2004, 21:19

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