CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Making buttons more responsive.....

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Oct 30, 2009 3:52 pm     Reply with quote

The cheap, quick way to do it would be to replace your 750ms delays
with something like this:
Code:

// Delay for 750 ms.  Poll the buttons during that time.
  for(i = 0; i < 75; i++)
     {
      if(button(Inc_Btn, 0, 50, 10, SW1, 1))   
         SetPoint++;

      if(button(Dec_Btn, 0, 50, 10, SW2, 1))   
         SetPoint--;
   
       delay_ms(10);
     }

Just drop that in and replace the two delay_ms(750) lines.
You could make it into a routine and call it, if you wanted to.

Since you're constantly doing conversions, you could delete the existing
code that polls the pushbuttons, and just use the code above.
Guest








PostPosted: Tue Nov 03, 2009 8:22 pm     Reply with quote

Hi PCM,

Yes, that works like a champ! I made a subroutine for the delay function, and all is well!

I'm kicking myself that I didn't see this myself. I guess it should have been obvious that since the 3/4 second delays were the bulk of the problem, that is where I should have focused my attention. Thanks for the great tip!

Joe
DEsterline



Joined: 25 Aug 2009
Posts: 6

View user's profile Send private message

PostPosted: Fri Nov 06, 2009 2:40 pm     Reply with quote

There's one other change I would recommend.

your code has it in a loop, but effectively your code:

Start conversion on 1
wait
read 1
start conversion in 2
wait
read 2

Since your sensors are on different pins, you can do this:

start conversion on 1
start conversion on 2
wait
read 1
read 2

That way you only have one wait period. Since you're using parasite powered sensors, this only works if they are on different pins.
Guest








PostPosted: Fri Nov 06, 2009 3:05 pm     Reply with quote

DEsterline,

Ah, that is a great suggestion as well! I will implement that idea this weekend! This will allow me to get temperature updates twice as often!

Thanks!

Joe
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Fri Nov 06, 2009 4:54 pm     Reply with quote

Ok, well is seems kinda silly to have bus based sensors on different pins. They could be on the same pins with a proper strong pullup during conversions... (make sure enough current is available).

My first project in PIC C (about 1997) used 4 sensors on 1 bus. For current usage, I did a conversion at a time... saved pins.

Ahhh, the options with today's fun Micro's.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
DEsterline



Joined: 25 Aug 2009
Posts: 6

View user's profile Send private message

PostPosted: Fri Nov 06, 2009 7:31 pm     Reply with quote

There's a lot of valid reasons to have a bus based sensor on multiple busses. My current design has 5 separate DS1822 on separate IO lines. Busses are great, but the discovery process is quite complicated. Not only the one-wire address arbitration process, but having the software figure the physical location of the different sensors can present significant problems.
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Fri Nov 06, 2009 9:01 pm     Reply with quote

That's True...

I suppose one could say that's what user configuration is for. but for something more turnkey -- I'd go with that.
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group