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 - potentiometer (ADC in) - bright led (PWM out)

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

potentiometer (ADC in) - bright led (PWM out) (by Alex)
hello, i know this is been answered before, but iīve been having problems doing a simple control brightness led with a 1K potentiometer, could some one give an example for PIC , since arduino canīt use ADC inputs as digital when using at least one as an ADC read
Tue Jun 19 2018, 17:16:47
(no subject) (by Alex)
for 20 mhz please
Tue Jun 19 2018, 17:17:25
(no subject) (by MGP)
First, post you schematic because the program is so easy to make that I think you made a hardware error.

..To Ihor thanks for the update.
Wed Jun 20 2018, 05:06:51
(no subject) (by Alex)
here is the schematic i did on my pic plataform, i still reading about pwm but it is a little hard for me to understand, i would like the applicaction ladder i described at the top of this post to understand much better and use it in my future applications, thanks
Wed Jun 20 2018, 09:23:00, download attachment schematic_adc(in)_pwmbrightness(out).jpg
(no subject) (by MGP)
Here your program, made with V4402

Some remarks:

The 2 capacitors on the crystal must be 22pF
You must connect a >10K resistor from the MCRL pin to the Vcc.

Switch the outer connections of the potentiometer if the led works in revers.

I simulated it, if you have problems I make it on a breadbord.
Wed Jun 20 2018, 10:48:51, download attachment Alex_adc.ld
(no subject) (by Alex)
thanks a lot MGP i compiled ladder with 4402 and got error message
Wed Jun 20 2018, 11:16:56, download attachment adc_ldmicro error.png
(no subject) (by Alex)
this is the pic plataform schematic in real life
Wed Jun 20 2018, 11:24:32, download attachment 35796785_10160557947975344_5801371124533035008_n.jpg
(no subject) (by MGP)
Change the PWM frequency to 10kHz, that's it.
Wed Jun 20 2018, 12:31:41
(no subject) (by MGP)
Your new program, 10kHz pwm.
Wed Jun 20 2018, 12:33:37, download attachment Alex_adc_V2.ld
(no subject) (by Alex)
thanks a lo MGP, it works

https://www.youtube.com/watch?v=XJl5gF0svQY


it flikers a little (no due to cell cam), is it because pot is not adjusted
Wed Jun 20 2018, 14:34:05
(no subject) (by Alex)
it was not cell cam after all, why led flickers at 0% potentiometer level? or how could i make led totally off, like in arduino samples around internet, led doesnīt flickers.


https://www.youtube.com/watch?v=B3z5MhXULzE&feature=youtu.be
Wed Jul 25 2018, 21:59:53
(no subject) (by Alex)
i think using a linear potentiometer is not that accuarte when dealig with pwm:


https://www.youtube.com/watch?v=xiI_f3PmDJQ&feature=youtu.be


with software works better:

https://www.youtube.com/watch?v=xW4KnsYFHQI&feature=youtu.be

but in those cases we need manually set pwm we could use a rotary encoder, how can i use it with ldmicro?
Wed Jul 25 2018, 23:48:51, download attachment rotary encoder.jpg
(no subject) (by MGP)
The reason your LED flickers is because your power supply is not stable enough.
A LED is like a zenerdiode, sometimes it helps to place a resistor parallel to the LED (1k / 5V)

For your rotaty encoder you can use the 'stepper-encoder' program in Samples.zip you can find in this link.

http://www.cq.cx/ladder-forum.pl?action=viewthread&parent=2133
Thu Jul 26 2018, 00:43:55
(no subject) (by Alex)
you were right, i change my power supply, now iīm using a more stable one, led doesnīt flickers anymore :) , thanks for your help.

https://www.youtube.com/watch?v=Fv5vOVgta9c&feature=youtu.be
Thu Jul 26 2018, 11:19:43
Incremental QUADRATURE ENCODER controls the brightness of the LED (PWM out) (by Ihor Nehrutsa)
Fri Jul 27 2018, 09:06:42
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):