BasicMicro - Forums

www.basicmicro.com
It is currently Mon May 21, 2012 8:00 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: HPWM with wait to avoid glitch
PostPosted: Fri Jul 08, 2011 6:30 am 
Offline
Guru

Joined: Sun Dec 20, 2009 10:52 pm
Posts: 76
Hi Everyone,

I would like to use HPWM with wait. I tried
Code:
hpwm P10,period,duty,true

It did'nt accept it
I tried
Code:
hpwm P10,period,dutyc,1

It accepted it but the HPWM is not working

If I only uses
Code:
hpwm P10,period,dutyc

It's working

Thanks for your help

Chris


Top
 Profile  
 
 Post subject: Re: HPWM with wait to avoid glitch
PostPosted: Fri Jul 08, 2011 10:40 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
You first must start HPWM using HPWM pin,period,duty without the wait. Then you can use the wait. If the HPWM isn't running then wait will sit forever waiiting for an end of pulse that will never happen.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: HPWM with wait to avoid glitch
PostPosted: Mon Jul 11, 2011 9:49 pm 
Offline
Guru

Joined: Sun Dec 20, 2009 10:52 pm
Posts: 76
Hi Nathan,

What do you mean exactly, should I do like the code below :

Code:
period=795
dutyc=period/2
hpwm P10,period,dutyc
pause 1
hpwm P10,period,dutyc,1


Should I use "1" or "true" to set the wait?

Thanks


Chris


Top
 Profile  
 
 Post subject: Re: HPWM with wait to avoid glitch
PostPosted: Thu Jul 14, 2011 11:17 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
Your code is correct. "true" and "false" are not defined in the compiler. You could create defines for them. A TRUE values is any non-zero value. A FALSE value is 0.

I would do it like this though:

Code:
init
   period=795
   hpwm P10,period,0

   ;do other init stuff

   dutyc=period/2
main
   hpwm P10,period,dutyc,1
 
   ;do other main stuff.

   goto main


Starting the HPWM with a 0 duty sends no pulses. It just inits the pin and the period. THen in your main loop hpwm will wait for the previous period to finish before setting the new duty and you will get no glitches.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: HPWM with wait to avoid glitch
PostPosted: Thu Jul 14, 2011 11:33 pm 
Offline
Guru

Joined: Sun Dec 20, 2009 10:52 pm
Posts: 76
Thanks a lot Nathan


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO