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

Question for problem solvers #2

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



Joined: 18 Nov 2008
Posts: 278
Location: Athens, Greece.

View user's profile Send private message

Question for problem solvers #2
PostPosted: Thu Dec 19, 2019 12:59 am     Reply with quote

Hi all.
I know this is not the right place to ask.. but please bare with me.

I am building a device that sprays perfume during the day in predefined intervals and hours.

For example:

Prog1: 08:00 - 14:00
Prog2: 17:00 - 20:00
Prog3: 21:00 - 22:00

I convert all starting and ending times to seconds (Hour*3600+Minute*60) so the above is:

Prog1: 28800 - 50400
Prog2: 61200- 72000
Prog3: 75600- 79200

Now the problem is that I have to make a sanity check if the programs overlap (common spray times). For example:

Prog1: 08:00 - 14:00
Prog2: 09:00 - 20:00

or

Prog1: 08:00 - 14:00
Prog2: 07:00 - 15:00

I have totally burned my mind trying to figure this out...so any help appreciated Rolling Eyes
_________________
George.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Dec 19, 2019 3:33 am     Reply with quote

Use Google to search for this:
Quote:
site:stackexchange.com how to tell if two time ranges overlap

Use that site for all non-CCS code related questions.
The answer will likely be in their archives.
georpo



Joined: 18 Nov 2008
Posts: 278
Location: Athens, Greece.

View user's profile Send private message

PostPosted: Thu Dec 19, 2019 4:33 am     Reply with quote

Shocked
Thanks for the stackexchange tip.
_________________
George.
temtronic



Joined: 01 Jul 2010
Posts: 9161
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Dec 19, 2019 6:12 am     Reply with quote

Just a comment on the 'times controller' ...

Converting times into seconds will need 32 bit variables and maths ( 86400 seconds in a day).

If you can afford to use '1/4 hour times' (8:00,8:15,8:30,9:00 ) then on/off times can be stored in a byte, actually 7 bits. The 8th bit can be used as a 'flag' to control an operation, like 'pulse the perfume valve'.

I've used this method for 30+ years for remote control HVAC systems. Back then we didn't have PICs,memory was costly and really no need for 'second by second' control.

If the project is a 'one-off' or 'home use' you can afford a bigger PIC, but if it's a commercial product where the smallest (cheapest) PIC has to be used, then using my method greatly reduces memory requirements AND speeds up the main() program loop.


Jay
allenhuffman



Joined: 17 Jun 2019
Posts: 537
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PostPosted: Fri Dec 20, 2019 8:33 am     Reply with quote

PCM programmer wrote:
Use that site for all non-CCS code related questions.
The answer will likely be in their archives.


I registered this site specifically because of Stack Exchange "helpers":

http://whywouldyouwanttodothat.com/

;-)
_________________
Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?
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