Home
Prox / RFID
Verichips
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Photographs
Miscellany
Resume / Consulting
Contact Me

LDmicro Forum - problem managing intensity of LED with potentiometer

(you are viewing a thread; or go back to list of threads)

problem managing intensity of LED with potentiometer (by potentiometer and led )
Hello,

I would need help to control the brightness of my LED with the B10K potentiometer.



the light of the led does not vary

Duty_cyclique:

ratio = duty
frequency = 490
resolution = 0-100% (6.7 bits)

Thank you for your help
Sat Feb 22 2020, 05:52:54, download attachment led-pot.ld
(no subject) (by MGP)
490Hz is too low, you get an error when compling.

Also, analog input is 10 bits, your duty is 0-100% (6.7bits) so divide 0-1023 by 10 then you get 0-102 and that works.
Sat Feb 22 2020, 07:43:04, download attachment led-potV2.ld
(no subject) (by potentiometer and led )

thank you very much ! it works ! BUT I had to set REFS ADC to 1 to make it work.
Sat Feb 22 2020, 07:55:28, download attachment Capture.PNG
(no subject) (by MGP)
I work with pic's and I never have changed the REFS, I don't even know what it does ;)
Sat Feb 22 2020, 08:04:40
(no subject) (by potentiometer and led )
in any case everything works! thank you for your responsiveness, you do a great job; I love this software!
Sat Feb 22 2020, 08:19:37
by potentiometer and led (by Paulino)
Adjunto su programa modificado ya que veo que lo divide entre 10 y 1023/10 =102, como ya savemos que LDmicro no tenemos decimales. por ello deveremos restar 2 o Usar MOV para arastrar el 100 % y de esta manera no dara ningun error, ya que en el momento que detecta que esta por encima de 100 mueve 100 a Duty.

I enclose your modified program since I see that it divides it between 10 and 1023/10 = 102, as we already save that LDmicro does not have decimals. Therefore we must subtract 2 or Use MOV to drag 100% and in this way it will not give any error, since at the moment it detects that it is above 100 it moves 100 to Duty.
Sat Feb 22 2020, 10:55:55, download attachment led-potV2_M.ld
(no subject) (by MGP)
@Paulino, look at your program again, something is wrong ;)

But he can always choose the 10bit PWM then he does not have to divide by 10.
Sat Feb 22 2020, 11:36:24
(por MGP) (by Paulino)
Hola no entiendo tu comentario, yo solo me dirijo que el 102 % no funciona en hechos, cuando se graba el microprocesador ya que al pasar el 100% y tener 102% al pasarse del 100% no funciona como se espera, por eso he proporcionado una linea mas para que cuando sea mayor de cien se mueva a 100 ya que como sabes no hay decimales en LDMicro, yo tengo miles de programas echos en LDMicro y todos funcionan y intento ayudar con mi experiencia en el sistema de programación en Escalera (PLCs).
y como vi el LDMicro de prueba en este foro e intentado ayudar a que pasa si se supera el 100% que no funciona como se espera.
y hay muchas forma de programar yo hice MOV pero también se puede hacer que Reste por ejemplo.

Hello I do not understand your comment, I only address that 102% does not work in fact, when the microprocessor is recorded since when passing 100% and having 102% after 100% does not work as expected, that is why I have provided one more line so that when I am over one hundred it moves to 100 since as you know there are no decimals in LDMicro, I have thousands of programs made in LDMicro and they all work and I try to help with my experience in the Escalera programming system (PLCs ).
and as I saw the LDMicro test in this forum and tried to help what happens if it exceeds 100% that does not work as expected.
and there are many ways to program I did MOV but you can also make Subtract for example.
Sat Feb 22 2020, 13:25:42
(no subject) (by MGP)
It will not work because in the program LED-potV2_M.ld rung 4 is on the wrong place, it will never have an effect on the dutycycle.

Rung 3 and 4 must be switched to take effect ;)
Sat Feb 22 2020, 14:12:38
Para MPG (by Paulino)
Si esto no funciona no se porque has hecho este ejemplo, yo solo añadí una linea para mover al 100% El duty.
y ami me funciona haciendo en el simulador de programa LDMicro,

If this does not work, I don't know why you have done this example, I just added a line to move 100% The duty.
and it works for me by doing in the program simulator LDMicro,
Sun Feb 23 2020, 06:47:55
(no subject) (by MGP)
This is because you compare the dutycycle when the dutycycle is already set to 102.

Ain = 1023
1023/10 = 102
set PWM dutycycle to 102 <-----
compare dutycycle >102
mov dutycycle 100 ---> this is too late, the d.c. is already 102
goto start

You must compare BEFORE you set the PWM dutycycle!
Sun Feb 23 2020, 10:24:21
Post a reply to this comment:
Your Name:
Your Email:
Subject:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):