Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

solution to a project

nikouz

Junior Member level 2
Junior Member level 2
Joined
Feb 5, 2021
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
175
Hi to every one.
I am building a project which monitoring the enviroment polution. The project except the sensors includes an RTC and an SD card to write the values 3 or 4 times in 24h period. The project works but the issue i have is how to determine these 3 or 4 times to write in the card. First i thought to use timer with a call back function, then i thought to polling the RTC square wave of 1Hz and last i thought to just compare the RTC time array with my preferable sampling times. I am thinking that all these ways looks primitive and i wonder if someone has done something similar or there is another solution.

best regards
 
Solution
Hi,

in the very most of my microcontroller applications I use a timer to generate a regular interrupt.
And I have a timeFlag register (volatile, flags SET in the ISR, cleared in MAIN())

Usually something in the 20ms period. --> I set a 20ms tick flag
So after 50 ticks I have a second --> I set the 1s flag
After 60 seconds I have a minute --> I set the 1minute flag
After 60 minutes I have an hour --> I set the 1h flag
you can use set your own flag every 6h ...

And I check the flag register in main() ... and process the according tasks.
It´s all rather basic.

***
I still don´t know what you expect ...and ... what difficulties you see ...
And the 15 minutes measurement interval is a new information ... don´t know what to do with this...
Hi,

unclear ...
I even don´t understand what the phrase "3 or 4 times" here means.

If it is 4 times in 24 hours ... why not call it "once every 6 hours"
with 3 :: "once every 8 hours".

Why "or" ? Shouldn´t it be either the one or the other?

Why "in 24 hours" ... can it be unequal distance? like: 7h + 8h + 9h = 24h

What´s the problem with your solution?
Please give clear informations: What did exactly you expect? .. and what did not work as expected?
If it did work ... why do you ask for other solutions?

***
Did I something similar? I did write to SD card several times within 100ms ... I did write to SD card an log once a year.
I mean .. every application that writes any data to an SD card .. does "something similar" .. but what is your "key function" that makes it similar or not?

Klaus
 
You putting processor to sleep to save power ?

If you need time of day accuracy RTC certainly good approach. Use it to wake processor
at desired sample time of day.


Regards, Dana.
 
Hi,

unclear ...
I even don´t understand what the phrase "3 or 4 times" here means.

If it is 4 times in 24 hours ... why not call it "once every 6 hours"
with 3 :: "once every 8 hours".

Why "or" ? Shouldn´t it be either the one or the other?

Why "in 24 hours" ... can it be unequal distance? like: 7h + 8h + 9h = 24h

What´s the problem with your solution?
Please give clear informations: What did exactly you expect? .. and what did not work as expected?
If it did work ... why do you ask for other solutions?

***
Did I something similar? I did write to SD card several times within 100ms ... I did write to SD card an log once a year.
I mean .. every application that writes any data to an SD card .. does "something similar" .. but what is your "key function" that makes it similar or not?

Klaus
Hi
I think i didn't explain myself in clear and there has been misunderstanding. Ok i will give details. First of all is not something wrong i just need advice in the following:
The project as i said messuring every 15min the temperature,humiditity,co2,co,dust etc. The clock is just an addition for good looking and only tells the time and date. Addition to this is an sd card which 4 times a date takes all these data and saves in. That means in 24h period i have save date, time and all the messurements 4 times.
The advice i need is how to have these 4 intervals(one every 6 hours). I made some thoughts for that as i describe in my original nessage and i need an advice if these thoughts are right or there is some other way to do it. Take a note that the pic is not going in sleep at all.
thanks
--- Updated ---

You putting processor to sleep to save power ?

If you need time of day accuracy RTC certainly good approach. Use it to wake processor
at desired sample time of day.


Regards, Dana.
yes i can use this external interrupt. There is 2 alarms that can recall and then i can load for each one different time to ring again so i can have 4 alarms in 24 hours. I think is good aproach because with this way i can put the pic in sleep mode i think if i am using batteries.
 
Hi,

in the very most of my microcontroller applications I use a timer to generate a regular interrupt.
And I have a timeFlag register (volatile, flags SET in the ISR, cleared in MAIN())

Usually something in the 20ms period. --> I set a 20ms tick flag
So after 50 ticks I have a second --> I set the 1s flag
After 60 seconds I have a minute --> I set the 1minute flag
After 60 minutes I have an hour --> I set the 1h flag
you can use set your own flag every 6h ...

And I check the flag register in main() ... and process the according tasks.
It´s all rather basic.

***
I still don´t know what you expect ...and ... what difficulties you see ...
And the 15 minutes measurement interval is a new information ... don´t know what to do with this information.
For sure ... I´d use an according 15 minutes flag...

*** now it seems you have an "visible clock" for showing the time. So you already have the time information.
If so, it should no brainer rocket science to compare the "clock_time" with "0:00", "6:00", "12:00" and "18:00" or any other values. (on a 24 h system)
(I still don´t know whether you want it to be 6h interval relative time ... or 4 absolute fixed time per day - as above)

The given informations still are not clear ... a lot of my worries/questions are still unanswered. I still don´t know what exact infromation you are after.
***

polling an external RTC ...
* I usually avoid this ... especially with slow busses like I2C
* I indeed usually avoid using an external RTC ... I use the software RTC ... unless I need absolute time on an application with power outages.
Since I usually use accurate XTAL for microcontroller system clock ... the software RTC is accurate enough ... and when interrupt driven it takes way less than 1% processing power.

Klaus
 
Solution
*** now it seems you have an "visible clock" for showing the time. So you already have the time information.
If so, it should no brainer rocket science to compare the "clock_time" with "0:00", "6:00", "12:00" and "18:00" or any other values. (on a 24 h system)
This is what i am asking for if this way of compare you propose is the best solution idea. I think it is and i will follow it. Thank you for your time on this. I will also try the software RTC i never have mess with that.
 
if this way of compare you propose is the best solution idea
best?
How can we know what YOU call the best?

What is the best dish? the best shoe? the best present? the best vehicle? The best color?
It always depends on what you focus on. We don´t know what is important for you.

I asked for informations.. did not get them.
I´ll better leave.

Good luck

Klaus
 
Just as an aside some processors have SD card support as well as RTC all onchip. In case
your design getting "partsy"

Regards, Dana.
Thanks for that maybe you can propose one like you describe.
--- Updated ---

Just as an aside some processors have SD card support as well as RTC all onchip. In case
your design getting "partsy"

Regards, Dana.
Thanks for that maybe you can propose one like you describe.
 
PSOC 5LP Family.

The following resources are onchip, multiples in many cases. Each drag and drop, and wire up internally and out
to pins, all done with wizard. Each resource (PSOC calls them components) has a rich set of APIs user invokes in code,
so user writing at high level, rare one has to write a driver.

IDE (PSOC Creator) and compiler free. CY8CKIT-059 excellent ~ $15 board to use (unless you need tons of I/O).

Primary PSOC Components 1.jpg



User community has also contributed other components, like 74HC type logic elements, DDS, CPLD, Cordic one can add to
the standard component library in the IDE. User can create his own components thru schematic capture and/or
Verilog.

Cypress originator of PSOC, now owned by Infineon.


Regards, Dana.
 

LaTeX Commands Quick-Menu:

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top