View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Oct 30, 2009 3:52 pm |
|
|
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
|
|
Posted: Tue Nov 03, 2009 8:22 pm |
|
|
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
|
|
Posted: Fri Nov 06, 2009 2:40 pm |
|
|
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
|
|
Posted: Fri Nov 06, 2009 3:05 pm |
|
|
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: 1615 Location: Central Illinois, USA
|
|
Posted: Fri Nov 06, 2009 4:54 pm |
|
|
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
|
|
Posted: Fri Nov 06, 2009 7:31 pm |
|
|
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: 1615 Location: Central Illinois, USA
|
|
Posted: Fri Nov 06, 2009 9:01 pm |
|
|
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 |
|
 |
|