PDA

View Full Version : generating square wave



boscox
- 17th April 2012, 06:34
i am a beginner in this world of programming i want to switch the transistor in dc dc converter. for my knowledge the transistor can be switched by square wave, i need the sample code here on how to switch this transistor. anyone to help me please

andywpg
- 17th April 2012, 23:09
i am a beginner in this world of programming i want to switch the transistor in dc dc converter. for my knowledge the transistor can be switched by square wave, i need the sample code here on how to switch this transistor. anyone to help me please

A square wave is simply turning it on and off. It goes from low to high and repeats.

For example:



DO
PORTA.0 = 1 'TURN ON PORTA.0
PAUSE 50 'PAUSE 50mSEC
PORTA.0 = 0 'TURN OFF PORTA.0
PAUSE 50
LOOP


This endless loop will turn the pin on and off with a 50msec delay. You could also use the TOGGLE command.

Hope this helps!

boscox
- 18th April 2012, 01:06
A square wave is simply turning it on and off. It goes from low to high and repeats.

For example:



DO
PORTA.0 = 1 'TURN ON PORTA.0
PAUSE 50 'PAUSE 50mSEC
PORTA.0 = 0 'TURN OFF PORTA.0
PAUSE 50
LOOP


This endless loop will turn the pin on and off with a 50msec delay. You could also use the TOGGLE command.

Hope this helps!


thanx for your suggestions but let me to make this clear,
i want to vary the time of switching on and off of the transitor ( to vary the duty cycle ),

mark_s
- 18th April 2012, 15:41
Search the picbasic manual and the forum for "PWM" and "HPWM"

boscox
- 20th April 2012, 15:54
Search the picbasic manual and the forum for "PWM" and "HPWM"

i read those manual you mentioned to me but i didn't seen any way to do with that so as to come up with the code

Demon
- 20th April 2012, 18:30
Top right of the page, Advanced Search, type in HPWM and Enter.

I get 6 pages of threads about HPWM. I find it hard to believe there isn't one good example in all that.

And yes, that is how many of us find examples on how to do stuff. I know it takes a long time, it's tedious, but sorry, that's life.

You also get to pick up interesting tidbits about HPWM on the way through.

Robert


EDIT: If you do encounter problems getting some of the code to work, feel free to post it here along with your question and people will be happy to help you figure it out.

But people will not do all the work for you without you first putting in some effort.

boscox
- 24th April 2012, 07:29
i got you demon and thanx for your help, i will come back to you if i feel any difficulties