PDA

View Full Version : Advice on Input circuitry for 0-10v or Pot



bcd
- 10th April 2008, 13:06
SO I was in the pub with a friend the other night and he was telling me about the led dimmers he had seen at work that took a 0-10v signal OR a 10K pot to set the brightness.

Thats dead easy I said - I could do that with an 8 pin pic with build in PWM and a MOSFET.

So he says 'OK then. Build me one for the kitchen. $20 says you can't..'

So I can get a voltage input to drive it no issue by feeding it through a non-inverting LM358 with a gain of x0.5 to get a 0-5v output into the AtoD on a 12F683.

What I can't work out is how to get a 10K pot and a 0-10v input (obviously only one is used at a time) I was thinking a pot between Gnd and the input that could use a soft 'pull up' that forms the top end giving a variable voltage that could drive the op-amp.

Analog is not really my thing - I am a definately digital guy and have tried googling under various things, but cannot find out how a front end like those functions. Might have to get one and try to reverse engineer the circuit.

Anyone got any hints ? Attached is what I was thinking of.

bill.

mackrackit
- 10th April 2008, 13:28
This should get you started with the ADC part. No LM358 required.
http://www.rentron.com/PIC12C67XAD.htm

Then once you have the ADC reading the pot, take the number generated by the ADC and use that with the PWM output.

If you are using 8 bit the ADC will go from 0 - 255. Use a multiple of that number as the pulse.

bcd
- 10th April 2008, 13:40
That bits no issue for me. Its the front end analog bit I am haviing the issue with.
Hoped some analog hero would pop in with the solution !
bill

mackrackit
- 10th April 2008, 13:52
Maybe I am misunderstanding.

Analog front end.

The pot is connected between the ground and 5+ with the wiper going to the ADC input.
The PWM output goes to the mosfet gate.

The pot is not connected to the 10 volt. Use the same power supply as the PIC. The 10 V will only connect to the drain or source of the mosfet. NPN or PNP, what ever you use.

mister_e
- 10th April 2008, 16:29
you can still use your opamp directly.. the problem here is that your gain will never be 0.5 but 1.5.

This bring at least few solutions. Forget the opamp, and use a simple voltage divider with 2 resistors + small capacitor (let's say 0.1uF) to smooth the signal noise...

OR a more fancy op-amp circuit + low pass filter. the whole thing must have a gain of 0.5.

Advantage to use an opamp in between... at least a higher input impedance... so you don't alter the signal.

Which voltage sources you have on hand? Is there any negative rails?

malc-c
- 10th April 2008, 20:45
I would follow mister-e's suggestion and use a divider (2 x 10k resistors) to halve the voltage to give you the 5 volts and then feed this into the PIC.

You could use the POT command to give you a value which is then used as the delay for the pulse train on the output, something like (I've not tried this but it should give you the idea)



scale = 10
Pot GPIO*,scale,D
pwm GPIO.**,D,1

mister_e
- 10th April 2008, 21:00
Nah, sorry, not POT for me to measure an external voltage source. ADCIN (or home made ADC conversion routine) would be my suggestion.

Maybe POT/RCTIME would be a last resort when your PIC don't have any spare ADCs and you need to measure a POT, maybe some LDRs... MAYBE.

bcd
- 11th April 2008, 02:49
0-10v with a resistive 2:1 dividor would work for the 0-10v input to the ADC input. How about the pot input?

The commercial units use a 10K between the ground and the input terminal (which can be either 10K pot or 0-10v), but i cannot figure out how they do it.

Could it be a current rather than a voltage thing ??

See - this is why I like digital stuff -its on or off.

bill.

malc-c
- 11th April 2008, 10:00
Nah, sorry, not POT for me to measure an external voltage source. ADCIN (or home made ADC conversion routine) would be my suggestion.


True, but I have very limited experience of ADCIN :) :)

With regards to the voltage divider the attached image might work - maybe better with a 10K lin pot ?

mister_e
- 11th April 2008, 10:09
Nope... range of 0-2.5 volts only... because this extra 10K in parallel with your POT.

2x1% 10K in serie, your ADC in the middle... a 0.1uF cap and that's it.

If the source handle this load, and is not that far of the PIC (i doubt because of this ol' 0-10v naming), this shouldn't cause any problem... as usual, software filtering/averaging are your friend.

Acetronics2
- 11th April 2008, 13:47
Looks Darrel had written something (LOL ) on that subject ... nooooooo ????

http://www.pbpgroup.com/modules/wfsection/article.php?articleid=25

....

Boooooooooooooooooooooooooooo

Alain

malc-c
- 11th April 2008, 21:08
Nope... range of 0-2.5 volts only... because this extra 10K in parallel with your POT.

2x1% 10K in serie, your ADC in the middle... a 0.1uF cap and that's it.



So how would he adjust the voltage, would placing the 10K pot across the 10v supply, and then placing the 2 x 10K resistors between the wiper and gnd, and then tapping off in the middle work. My thoughts would be that the tap in the middle of the resistors would therefore be half of what ever voltage is coming out of the wiper ?

mister_e
- 11th April 2008, 22:47
Oh well, there's some voltage divider and ohm law that i'm not going to explain on a friday ;)

But to me, when at all possible, i try to avoid any kind of trim pot, software calibration is interesting... but there's alway extra work to be done... and the PIC Vdd, and voltage source have their own error margin as well. So i stick to the simple 2 resistor voltage divider :D

If you really want to stick with a Trim Pot, i would suggest something like...
<img SRC="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2493&stc=1&d=1207950143">

malc-c
- 12th April 2008, 09:49
If you really want to stick with a Trim Pot, i would suggest something like...

I thought that was what the original poster wanted...



What I can't work out is how to get a 10K pot and a 0-10v input (obviously only one is used at a time) I was thinking a pot between Gnd and the input
bill.

Steve, I'm still confused over this, using your circuit effectivly gives 10K and 11.1K (2k + 9.1K) when the pot is at min (ie wiper diectly touching the 10K resistor) which would give 5.26 v, but at the opposite throw, it would be 12K and 9.1K which would give 4.31v to the PIC. I assume that you would therefore use the 0.95v difference as the range to measure for the ADC ?

mister_e
- 12th April 2008, 09:55
The pot is there for calibration purpose only. inject 10V at the input, then adjust the pot to reach 5v... a bit useless in most case ;)

malc-c
- 12th April 2008, 10:03
So in essance its a straight divider, 5V (+ or - 0.25 ish of a volt).

So how would you then take the 5v output and use this to give a voltage range the ADC can use to intern generate the PWM to dim the LED. I assum that any pot between 5v and gnd will thus be in parallel with the 9.1K, hence your comments regardig Ohms Law :)

EDIT:
Or have I missed something, in that the 0-10v stated in the original post is already a varible voltage between zero and 10v, rather than a fixed 10v supply ? If so then I can see your logic

mister_e
- 12th April 2008, 10:11
i'm not sue if i follow you malc :o ... not sure you follow us too :o no pun intended ;)

You take the output and plug it directly to the PIC... straight, not much. Sugarless, fat-free, not much, zip, zero,nada. Want to use it to dim a LED? easy...

ADCIN 0, ByteVar
HPWM 1,ByteVar,Freq

If i haven't missed anything in the OP request, he have an external source which provide voltage between 0-10V... and want to monitor it (for xyz reason) with a PIC, hence why the voltage divider.

malc-c
- 12th April 2008, 10:14
If i haven't missed anything in the OP request, he have an external source which provide voltage between 0-10V...

That's the part I missed - I was assuming it was a fixed 10v supply

mister_e
- 12th April 2008, 10:47
I don't see why any PIC should be used here anyway :o