I RECALL A THREAD about controlling the LCD brightness

Swordfish has a soft SPI library.. For PWM he will need a library! As he cant install the calculator, internal PWM may be off the table.

I'm not thinking how you or I would do it, That would be simple..
 
I thought Swordfish had all libraries available and easily accessible
I'm not thinking how you or I would do it, That would be simple..
That's a very good point but wouldn't it need the library for the digital pot?

Mike.
 
I thought Swordfish had all libraries available and easily accessible

That's a very good point but wouldn't it need the library for the digital pot?

Mike.
Agreed... Let just let Jon sort it out as usual!
 
will consider the digital pot but at what cost?

The cost of EVERYONE'S sanity.

I explained exactly the steps you need to follow to use PWM, which will require TWO parts at a cost of almost ZERO.

1 – Include the PWM2 module (which I explained where to find).

2 – SetFreq in the PWM2 module. Use the calculator I linked to plug in a realistic value or pull one out of your butt; the PWM2 module will deal.

3 – Set the duty cycle percentage. 0% = 0 volts. 50% = ½ supply voltage, 67% = ⅔ supply voltage. 99% =:supply voltage.

4 – Start PWM.

Geez. It's taken me 10× longer to write this than it would have taken to test it.



A digital pot is not an answer for you. As far as I recall [which believe me, is way too frick'n much], you've never used SPI before. So it's just another layer not to understand.
 
If you only need a single PWM channel then you can use the simpler PWM.bas module, but either one should work.

See https://www.sfcompiler.co.uk/wiki/pmwiki.php?n=SwordfishUser.PWM (for the second time)

It's pretty straight-forward...
Code:
// import PWM module...
Include "PWM.bas"

// local duty cycle as a percent, 0-100...
Dim Duty As Byte

// main program...
SetFreq(5000)
While true
   Duty = 0
   Repeat
      SetDutyPercent(Duty)
      Inc(Duty)
      DelayMS(10)   
   Until Duty > 100
Wend

Single IO pin, no SPI libraries, etc.
 
If you call SetFreq() it'll try and figure out the prescaler and settings.
If the function returns true then it was successful. If it returns false then it couldn't calc a setting to match the given freq.

You can use various calculator programs to figure out the settings and set it up yourself too.
The wiki page shows examples using both methods.
 
going with using the PWM pin on the pic.
Need to experiment with settings etc.
 
Well hopefully this is correct for the CONTRAST pin/PWM
 

Attachments

  • FAST 5.jpg
    416.1 KB · Views: 127

My 10uF 25V is already tiny, no point making it smaller - it's not as big as the BC337 it sits next to
 
well I finally have a picture of the completed sign I made for our town centienial
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…