PDA

View Full Version : 0-10v dc



naga
- 15th October 2008, 10:11
Hi All,
I need a 0-10v Dc control voltage for control an electronic ballast.
using an Op Amp and a PIC PWM output, (16f77,4mhz)
i need to control 0-10v in 10steps with UP and Down Buttons..

Please help..
Thanks.

aratti
- 15th October 2008, 15:50
Try the attached schematic. Apply pwm to Vin. With trail and error adjust pwm to output the disired voltage. Then enter these values in your code.

Al.

skimask
- 15th October 2008, 16:42
Then enter these values in your code.
Al.
What code? :D I think the O/P wants the code written for them...
With that schematic, a digital pot, a voltage divider, an A/D input, and a bit of trickery, a person should be able to hook up a PIC to auto-track/correct the output voltage...
That's a handy little idea to have around...

naga
- 16th October 2008, 06:46
Deleted.. Sorry.

naga
- 16th October 2008, 06:51
What code? :D I think the O/P wants the code written for them...
With that schematic, a digital pot, a voltage divider, an A/D input, and a bit of trickery, a person should be able to hook up a PIC to auto-track/correct the output voltage...
That's a handy little idea to have around...

Dude! I agree that you are a genius, but i am Just a learner.. support ppl who wants some help but dont try to stop who willing to help..

skimask
- 16th October 2008, 11:44
Dude! I agree that you are a genius, but i am Just a learner.. support ppl who wants some help but dont try to stop who willing to help..
Ok, fact #1 - I'm no genius...
fact #2 - good luck getting your code to compile and work in MeLabs PicBasicPro (any version)
And...that code you posted...why would it stop for you? There's nothing in there to make it stop!

naga
- 16th October 2008, 14:55
Ok, fact #1 - I'm no genius...
fact #2 - good luck getting your code to compile and work in MeLabs PicBasicPro (any version)
And...that code you posted...why would it stop for you? There's nothing in there to make it stop!
Thank you very Much, actually i was trying that code in proton,by mistake i pasted.will delete now.
Since you are a senior member of this forum, and you also understood what code i am searching for, Could you pls help me out. i need to adjust the voltage 0-10 with 2 buttons..
Help would be appritiated..
Warm Regards..

skimask
- 16th October 2008, 15:08
Thank you very Much, actually i was trying that code in proton,by mistake i pasted.will delete now.
Since you are a senior member of this forum, and you also understood what code i am searching for, Could you pls help me out. i need to adjust the voltage 0-10 with 2 buttons..
Help would be appritiated..
Warm Regards..
Again...not a senior member of anything, and I don't use Proton.
That code you copied was close...so, change it to fit PBP.

Ioannis
- 16th October 2008, 19:57
OK, the 555 is good trick, but if you use an LMC66x series op-amp and a single +12 volt supply, you have a 0-10 voltage amplifier with 3 parts! May be 2 more to filter PWM from PIC...

Ioannis

Melanie
- 16th October 2008, 20:22
naga

If you use a PIC with Hardware PWM (eg 16F628) then varying the Duty in steps of 10% from 0 to 100% (see HPWM command) will give you your ten steps. A simple filter on the output will then give you ten voltage steps from 0v (0%) to 5v (100%).

I recall posting a circuit for an Op-Amp Voltage Doubler some time back. Do a forum SEARCH, stick that on the end of your filter and presto - you got ten steps of 0-10v.

skimask
- 17th October 2008, 00:11
I recall posting a circuit for an Op-Amp Voltage Doubler some time back. Do a forum SEARCH, stick that on the end of your filter and presto - you got ten steps of 0-10v.
http://www.picbasic.co.uk/forum/showthread.php?t=245&highlight=doubler

Is that it? I've got it on my 'hot' list of handy items to keep around...

rmteo
- 17th October 2008, 00:21
Or you could use one of these (without the need for a separate high voltage supply):
http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010581

The TCM828/829 are CMOS "charge-pump" voltage converters in ultra-small 5-Pin SOT-23A packages. They invert and/or double an input voltage which can range from +1.5V to +5.5V. Conversion efficiency is typically >95%. Switching frequency is 12kHz for the TCM828 and 35kHz for the TCM829. External component requirement is only two capacitors (3.3µF nominal) for standard voltage inverter applications. With a few additional components a positive doubler can also be built. All other circuitry, including control, oscillator, power MOSFETs are integrated on-chip. Supply current is 50µA (TCM828) and 115µA (TCM829). The TCM828 and TCM829 are available in a 5-Pin SOT-23A surface mount package.

naga
- 17th October 2008, 13:14
naga

If you use a PIC with Hardware PWM (eg 16F628) then varying the Duty in steps of 10% from 0 to 100% (see HPWM command) will give you your ten steps. A simple filter on the output will then give you ten voltage steps from 0v (0%) to 5v (100%).

I recall posting a circuit for an Op-Amp Voltage Doubler some time back. Do a forum SEARCH, stick that on the end of your filter and presto - you got ten steps of 0-10v.

Hi, Could you please guide me If a 4MHz oscillator and 16f877a are used. want to control with UP and Down Buttons(10 steps)

Example: (Porta.0)

PWM PORTA.0,127,10 ?

Thank you.

aratti
- 17th October 2008, 16:06
Use Portc.1 or Portc.2 and HPWM (see page 73 of the manual)




B0 var Byte
Vduty var Byte

Vduty=0
B0=1

Main:

if UpButton =0 then
If Vduty<255 Then Vduty=Vduty+B0
Gosub HpwmSet
endif

if DownButton =0 then
If Vduty>0 then Vduty=Vduty+B0
Gosub HpwmSet
endif

goto Main


HpwmSet:
HPWM Channel, Vduty,Frequency
Return

with B0 = 1 you have 255 steps , if you want 10 steps set B0 = 25

UpButton and DownButton are two input ports with a 10K resistor pullup, the switch is normally open.

Al.

aratti
- 17th October 2008, 16:08
Sorry should be:
if DownButton =0 then
If Vduty>0 then Vduty=Vduty-B0
Gosub HpwmSet
endif

skimask
- 17th October 2008, 16:13
Sorry should be:
if DownButton =0 then
If Vduty>0 then Vduty=Vduty-B0
Gosub HpwmSet
endif
You know you can EDIT your own posts right? :)
Look down by the QUOTE button after you've submitted your post.

naga
- 18th October 2008, 09:59
Sorry should be:
if DownButton =0 then
If Vduty>0 then Vduty=Vduty-B0
Gosub HpwmSet
endif

Hi all, no luck, Please gothru my code...Thanks.

Include "MODEDEFS.BAS" ' Include Shiftin/out modes

@ device PIC16F877A , xt_osc, wdt_on, pwrt_on, protect_on ,lvp_off
Define Osc 4 ' using a 4 MHz oscillator


; 76543210
TRISA = %00000000 ' ALL OUTPUTS
TRISB = %11111111 ' ALL INPUTS- KEYBRD
TRISC = %11110001 '
OPTION_REG.7=0 'Enable internal pull-ups
OPTION_REG = %11111000 ' Assign prescaller to WDT

TRISA = 0 ' Set PORTA as output
T1CON.1 = 0 ' Set TIMER1 clock source to internal clock
INTCON = %01000000 ' Enable peripheral interrupts
PIE1 = %00000001 ' Enable TMR1 overflow interrupt
CCP1CON=%00001100 ' PWM MODE


UpButton Var PORTB.0
DownButton var PORTB.1
PWMOut Var PORTC.1 ' PWM Output


DEFINE CCP1_REG PORTC 'Hpwm 1 pin port
DEFINE CCP1_BIT 2 'Hpwm 1 pin bit

DEFINE HPWM2_TIMER 1 'Hpwm 2 timer select

B0 var Byte
Vduty var Byte

Vduty=0
B0=1

pause 100

Main:

if UpButton =0 then
If Vduty<255 Then Vduty=Vduty+B0
Gosub HpwmSet
endif

if DownButton =0 then
If Vduty>0 then Vduty=Vduty-B0
Gosub HpwmSet
endif
goto Main


HpwmSet:

HPWM 1,25,1000 '4.00khz
'HPWM 1,25,250 '16.00khz. tried this also.

Return

skimask
- 18th October 2008, 15:34
Do you have a couple of LEDs handy?
I always add a 'heart beat' LED to whatever I'm doing, even if I know the hardware is working... Really helps for troubleshooting...
And if you're using the internal pullups, you're turning on the internal pull-ups, then turning them right back off...

OPTION_REG.7=0 'Enable internal pull-ups
OPTION_REG = %11111000 ' Assign prescaller to WDT

naga
- 19th October 2008, 11:40
Do you have a couple of LEDs handy?
I always add a 'heart beat' LED to whatever I'm doing, even if I know the hardware is working... Really helps for troubleshooting...
And if you're using the internal pullups, you're turning on the internal pull-ups, then turning them right back off...

OPTION_REG.7=0 'Enable internal pull-ups
OPTION_REG = %11111000 ' Assign prescaller to WDT


Hi, Still not working..need help..

Thanks.

Melanie
- 19th October 2008, 12:40
naga

Go back to your post #17

In it you are changing a variable Vduty. This part is good.

You then call a subroutine HpwmSet. Explain to me how in your code Vduty changes the HPWM setting?

Go to the PICBASIC manual, look up HPWM and how it is used, an then install Vduty correctly so it actually changes your PWM setting.

naga
- 19th October 2008, 17:36
naga

Go back to your post #17

In it you are changing a variable Vduty. This part is good.

You then call a subroutine HpwmSet. Explain to me how in your code Vduty changes the HPWM setting?

Go to the PICBASIC manual, look up HPWM and how it is used, an then install Vduty correctly so it actually changes your PWM setting.

@Melanie, Should i change " HPWM 1,25,1000" TO " HPWM 1,127,1000" ? as per the PBPManual. And please let me know if any other value needs to be changed.. Actaully i'll have to finish this project as soon as possible..

Thank you verymuch..

skimask
- 19th October 2008, 18:08
What Melanie meant was to examine this piece of code:


HpwmSet:
HPWM 1,25,1000 '4.00khz
'HPWM 1,25,250 '16.00khz. tried this also.
Return
1 is a constant, 25 is a constant, 1000 is a constant.
If the values in the HPWM statement are all constants, how is a variable in your main loop supposed to change that constant?

If you change
HPWM 1,25,1000
to
HPWM 1,127,1000
all you've done is change the 25 to a 127.

So, WHAT in your code is going to change ANYTHING in your HPWMset subroutine?

aratti
- 19th October 2008, 20:21
Naga the solution is under your eyes. With the present code you can press the switches for all your life but the duty cycle of your pwm out will remain always 25! Why we are making the variable VDuty moving from 0 to 255. Why I told you to change B0 to 25 if you want to scan the whole range with 10 steps ?

Al.

naga
- 21st October 2008, 05:40
Naga the solution is under your eyes. With the present code you can press the switches for all your life but the duty cycle of your pwm out will remain always 25! Why we are making the variable VDuty moving from 0 to 255. Why I told you to change B0 to 25 if you want to scan the whole range with 10 steps ?

Al.

Hi all,So in my post #17, which Part of a statement that is not correct..Help.

Ioannis
- 21st October 2008, 07:37
Come on naga, are kidding us?

Where in the

HPWM 1,25,1000 '4.00khz

are setting the duty?

Put the variable Vduty in the HPWM statement... (instead of number 25) like this:

HPWM 1,Vduty,1000 '4.00khz

Ioannis