Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Potentiometer to PWM

Status
Not open for further replies.

691175002

New Member
Hi, I would like to have a small circuit to essentially drive an RGB led using PWM based on the positions of three potentiometers. I figure that the best way to do this would be using a simple microcontroller, but my experience is limited to the arduino and basic stamp which I assume are major overkill for this.

What would you recommend as a cheap and easy microcontroller that could do this? Ideally I would need very high PWM frequency because I don't want flickering or persistence of vision effects if it is moving. Learning a new programming language won't be a problem.

Thanks
 
Hi, I would like to have a small circuit to essentially drive an RGB led using PWM based on the positions of three potentiometers. I figure that the best way to do this would be using a simple microcontroller, but my experience is limited to the arduino and basic stamp which I assume are major overkill for this.

What would you recommend as a cheap and easy microcontroller that could do this? Ideally I would need very high PWM frequency because I don't want flickering or persistence of vision effects if it is moving. Learning a new programming language won't be a problem.

Thanks

I'd use a PIC12F683. It's an 8-pin microcontroller that has all you need: 3 analog channels and 1 PWM output. Check the datasheet. Free basic compilers are available for this PIC or you could use assembly. Lots of examples on the net.
 
Hi, I would like to have a small circuit to essentially drive an RGB led using PWM based on the positions of three potentiometers. I figure that the best way to do this would be using a simple microcontroller, but my experience is limited to the arduino and basic stamp which I assume are major overkill for this.

What would you recommend as a cheap and easy microcontroller that could do this? Ideally I would need very high PWM frequency because I don't want flickering or persistence of vision effects if it is moving. Learning a new programming language won't be a problem.

Thanks

Welcome to the forums !

The simplest way would be to use a micro with analog inputs, and you shouldn't require too much program space or ram. A PIC12F683 as Eng1 stated above (who posted while I was writing this,) or a PIC 16F88 should be fine. The arduino and stamp are, perhaps, easier to use than a plain PIC, but you pay extra for this convenience.

The term high is a relative one. :D I think you DO want 'persistence of vision' here, though, as you don't want people to see it flash. It doesn't take much for vision, IIRC at thirty frames per second you won't see flicker, but someone may correct this. :D

I would check out Nigel's tutorials first; they are a great way to understand how the PIC works, and are in assembly, which you can learn without laying out cash for a development tool chain.

WinPicProg Page

If I recall, he has tutorials which should point you in the direction you want to go. When you run into difficulty, then ask questions here.
 
Last edited:
Thanks for the advice, I know that with the arduino if you send PWM to an led and move it around in a dark room you can see a trail of dots like what is produced by those pov displays. I believe that the arduino outputs pwm at along the lines of 500Hz though.

Is a single PWM output enough? I would like to control all three channels (RGB) separately.
 
ops :eek: you need three outputs of course. You can do PWM in software on three outputs. The PIC12F683 is not suitable then. One pin is input only and is not an analog input, unfortunately.
A PIC16F88 is another common uC with A/D channels and more pins.
 
Thanks for the advice, I know that with the arduino if you send PWM to an led and move it around in a dark room you can see a trail of dots like what is produced by those pov displays. I believe that the arduino outputs pwm at along the lines of 500Hz though.

Is a single PWM output enough? I would like to control all three channels (RGB) separately.

500 Hz isn't really 'high frequency.' :) You should be able to do three seperate PWM outputs in software.

ops :eek: you need three outputs of course. You can do PWM in software on three outputs. The PIC12F683 is not suitable then. One pin is input only and is not an analog input, unfortunately.
A PIC16F88 is another common uC with A/D channels and more pins.

Oops too! :eek: :eek: :eek: I forgot, the16F628 doesn't have analog, just a comparator! The 16F88 would be a much better choice.
 
Actually the 12f683 could/might work. The trick is to carefully manipulate the MCLR pin in software. Better to use a 16f684 and not having to worry about shorting the pin out.
 
Hi guys,

please think of the fact that the OP might neither be familiar with programming a PIC, nor might he have a programmer.

A simple way doing three channel PWM is using a dual and a single timer IC (NE556 respectively NE555).

As a matter of fact I consider using a three input analog µC wasted engineering for such a device. :D (lots of unused I/Os)

Boncuk
 
Well the actual usage of this will be in an RGB laser pointer. I want to be able to drive three separate laser diodes via PWM and have the intensity of each controlled by sliders. The problem is that the beam might be moving very quickly at its end (especially if it is used with a Spirograph or similar). I believe that most commercial solutions run at along the lines of 100kHz. I fear that low frequency PWM will end up looking like a dashed line.

I figured that a microcontroller would save a bit on space and let me do cool things like preprogram colors and such. I don't have any experience with PICs at the moment but it seems like a nice time to start.

EDIT: I did some testing and determined that I need PWM at around 5000Hz for it to be smooth. Can a microcontroller do that across three channels?
 
Last edited:
The term high is a relative one. :D I think you DO want 'persistence of vision' here, though, as you don't want people to see it flash. It doesn't take much for vision, IIRC at thirty frames per second you won't see flicker, but someone may correct this. :D

OK, I'll bite. :) 30 fps is fine as a frame rate for making successive frames of a film or video appear as smooth motion (film is usually closer to 24 fps), but the eye can respond to flicker at over double that rate. Ever used a CRT with a refresh rate of 60Hz? Ouch.

Essentially what I'm saying is that flicker is a separate phenomenon from jumpy video. Frame rates can be much lower than refresh rates and still appear OK.


Regards,

Torben

P.S. - Yeah, I just pointed that out to be a PITA. ;)
 
Last edited:
Thanks Torben,
I was asking for it. :p and I don't consider you a pain in the...

Yes, and even more annoying, than the low refresh monitors are some fluorescent lights...

If

OK, I'll bite. :) 30 fps is fine as a frame rate for making successive frames of a film or video appear as smooth motion (film is usually closer to 24 fps), but the eye can respond to flicker at over double that rate. Ever used a CRT with a refresh rate of 60Hz? Ouch.

Essentially what I'm saying is that flicker is a separate phenomenon from jumpy video. Frame rates can be much lower than refresh rates and still appear OK.


Regards,

Torben

P.S. - Yeah, I just pointed that out to be a PITA. ;)


Well the actual usage of this will be in an RGB laser pointer. I want to be able to drive three separate laser diodes via PWM and have the intensity of each controlled by sliders. The problem is that the beam might be moving very quickly at its end (especially if it is used with a Spirograph or similar). I believe that most commercial solutions run at along the lines of 100kHz. I fear that low frequency PWM will end up looking like a dashed line.

I figured that a microcontroller would save a bit on space and let me do cool things like preprogram colors and such. I don't have any experience with PICs at the moment but it seems like a nice time to start.

EDIT: I did some testing and determined that I need PWM at around 5000Hz for it to be smooth. Can a microcontroller do that across three channels?

Actually, you should be able to get close to the 10kHz that the commercial units do...
 
Status
Not open for further replies.

Latest threads

Back
Top