Page 1 of 1

Backlight pwm control

Posted: November 15th, 2008, 4:28 pm
by lucas_siglo21
does lcdsmartie support backlight brightness control using pwm in pin 17 of lpt port?

Posted: November 15th, 2008, 7:04 pm
by caesar
no, not pwm, just on/off.

Posted: November 15th, 2008, 7:22 pm
by lucas_siglo21
ok
i've made some tests and it is technicaly possible if you achieve stable timings, it would be a good feature for a next version of lcdsmatrie, i think

Posted: November 15th, 2008, 10:18 pm
by caesar
How did you do it without hanging the display dll?

Of course it is possible but how to bitbang the pin and also release control?
BTW, that pin is used for E2 on 4x40 displays.

Posted: November 15th, 2008, 10:36 pm
by lucas_siglo21
i didn't do it with lcdsmartie, i wrote a program to test the concept

i think it is not possible to do if you don't touch the code of the program, maybe with the display dll but i'm not sure

Posted: November 16th, 2008, 11:29 am
by caesar
It should be possible to implement in the dll, if there is some special need, I can try to put it in the new Smartie release.

What compiler do you use? So we can see what is to be done.

Posted: November 16th, 2008, 2:14 pm
by lucas_siglo21
compiler?, what do you mean?, i use visual basic .net 2008 and its compiler

Posted: November 16th, 2008, 8:31 pm
by caesar
the display dll's are written in delphi, but can be done in vb too.

I mean that now the display dll is just a interface to the hardware, it just sends data and immediately releases control.

I don't think that PWM can be used with the current method, and it's a pretty good method to just change it to allow parallel port backlight pwm.

It's easier and looks a lot better to make a PIC or Atmel backpack!

Posted: November 16th, 2008, 9:06 pm
by lucas_siglo21
yes, of course you can make a backpack, but with this method the hardware remains simple and you only need to update the software to have the new feature. anyway, is it possible to implement in a new version of lcdsmartie?.

Posted: November 16th, 2008, 11:49 pm
by caesar
As I see it now:
- it's either removing the display driver feature - won't happen
- or finding a way to keep control over the display when smartie doesn't send data to the display driver - but how?

A complicated idea: a smartie display plugin that relays data to a small executable that manages the display directly... but be prepared for high CPU usage just for the PWM setting!

Try doing a small executable that outputs PWM to the parallel port and see for yourself. Make sure to code the ability to set PWM in 256 steps.

Posted: November 17th, 2008, 1:53 am
by lucas_siglo21
well, i tried to control it while lcdsmartie were enabled, it works, but it is a bit unstable, when smartie gets the control of the backlight, it goes to the smartie's state and the rest of the time my program sets the brightness pretty well, but the pwm via software is a bit unstable, timing depends of a lot of things and the program colapses while it is executing the doevents instruction(it tells to the operative system that must pay attention to the rest of the programs, if i don't use it the program just freezes the pc)

here is my code:

Code: Select all

    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
        Do
            Application.DoEvents()
            OUT(&H248A, 3)
            Sleep(TrackBar1.Value / 20)
            OUT(&H248A, 11)
            Sleep((255 - TrackBar1.Value) / 20)
        Loop
    End Sub
of course it uses a lot of resources and is not very necessary(you can do it with a potentiometer, i am complicating something easy), i think i will not continue with this, at least via software