![]() |
Forum Index : Microcontroller and PC projects : Duinomite gracefull shutdown
Author | Message | ||||
bobo2 Newbie ![]() Joined: 26/10/2012 Location: SwedenPosts: 36 |
I have built a small controller using duinomite and MMBasic with CAN. When I start it up the controller does its thing and then when the power is cut the process is interrupted. This is fine. I would now like to add some logging to an SD card, and I would like to write to it as seldom as possible to avoid damaging it. So I am thinking of adding a bigger capacitors or a battery to the duinomite to prevent immediate shutdown and give it some time to finish off logging. I plan to open a file on startup of my program and then start writing to the file... and if the duinomite senses that power is cut it will close the log file and shut down. Now to the questions - what would be the best way to sense that power is cut? - if I use LiPo battery then maybe I can sense difference in supply voltage (the normal supply is 12V, while the battery would be around 3.5V) via one of the analog pins? - what if I use capacitors in parallel with the 12V supply - would that same idea work too? Or maybe I should dimension the capacitors to assure that the duinomite runs for one more write to the SD card? - if I use capacitors the duinomite will shut down soon enough, but what if I use battery - is there a "shut down" command that would turn off the duinomite until the next time 12V power is applied? Maybe some device with latching relays? Is there any other way to handle logging to the SD card, when power is not guaranteed? It is important for me that I get all the info at the end of the operation - I don't want to miss the final 1 minute of the log. Thanks in advance for any ideas, suggestions! |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10209 |
How about just putting a diode in the supply and the capacitor (1 Farad 5V should be enough) the processor side of the diode. That way you can measure the voltage on the supply side of the diode using a potential divider into one of the analogue pins and as soon as you see it drop do the logging and close the file |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3282 |
You need to watch out with supercaps (eg, 1F 5V) because they have a large internal resistance and may not be able to supply the current required by the Duinomite. Geoff Graham - http://geoffg.net |
||||
bobo2 Newbie ![]() Joined: 26/10/2012 Location: SwedenPosts: 36 |
Thanks for reply matherp. I am confused - how is this capacitor and two diodes supposed to work? What is the theory of operation? Or maybe you can make a quick schema? My "normal" power supply to the duinomite is between 9V and 15V - how is a 5V diode going to work with this? Maybe you meant zener diode? |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10209 |
It is just one ordinary diode in-line with the positive supply to isolate the supply from the capacitor. The capacitor will then maintain the voltage to the processor for as long as the charge lasts (but check the capacitor spec as per Geoff's note). The voltage divider comes directly from the supply before the diode. This way you can check that the supply has failed but still have some time to close gracefully - |
||||
Greg Fordyce Senior Member ![]() Joined: 16/09/2011 Location: United KingdomPosts: 153 |
I've been working on a project using a CMM (colour MM) in a vehicle and had a similar problem, how to shutdown cleanly when the ignition is switched off. My solution was to power the CMM through a relay from the battery, that the CMM controls, and have the CMM monitor the ignition feed. When the ignition is on the CMM keeps the relay on, when the ignition is switched off the CMM then goes to a shutdown routine, does it's logging to SD card and then switches off the relay thereby shutting itself down. The start position, through a diode, bypasses the relay and initially powers the CMM until it turns on its power relay. I use a ULN2003 as a relay driver. Hope that helps and maybe gives you some ideas. |
||||
Sir_M Newbie ![]() Joined: 14/01/2013 Location: SwedenPosts: 15 |
Hi Since you use CAN i guess that it is a Duiomite Mega. There is a charger for battery on that and it will automaticly switch between power sources. If you measure the supply voltage you will have plenty of time to close SD-card. You could even set a time (minutes/hours pending of load) before it shut down. Hmm, kul. Såg först efter jag svarat att du också var från Sverige :) // Jörgen |
||||
bobo2 Newbie ![]() Joined: 26/10/2012 Location: SwedenPosts: 36 |
Thanks guys! Tack Jörgen! Yes - it is a Duinomite Mega. I found following in the manual: Very interesting - so I don't need any extra hardware to measure if the board is powered by battery or external power supply. How can I put the board in "low power" mode (or switch it off completely) if it is powered by battery? |
||||
bobo2 Newbie ![]() Joined: 26/10/2012 Location: SwedenPosts: 36 |
It looks like the sleep function is not supported in MMBasic on the Duinomite Mega- http://www.thebackshed.com/Forum/forum_posts.asp?TID=5559 Edit: I also found these: Pololu Pushbutton Power Switch SV and toggle power switch |
||||
bobo2 Newbie ![]() Joined: 26/10/2012 Location: SwedenPosts: 36 |
Hi Greg, Is there any chance I can see a schematic for your circuit with the relay? |
||||
bobo2 Newbie ![]() Joined: 26/10/2012 Location: SwedenPosts: 36 |
Sorry to bring this thread to life again. I am trying something different and can not seem to find a way to read the state of RG7 (USB-FAULT) of Duinomite Mega with MMBasic v4.5 with CAN. I found this http://www.dontronics.com/Duino/files/Hardware/Dontronics/Olimex/Documents/Duinomite%20descriptions.pdf But can not seem to figure out how to read it. I would appreciate any advice! |
||||
bobo2 Newbie ![]() Joined: 26/10/2012 Location: SwedenPosts: 36 |
Here are some videos showing some of the things I am doing with the duinomite: https://www.youtube.com/watch?v=tblLVtNNdvs https://www.youtube.com/watch?v=f_bFMviSBu8 The source code is at www.evmonitor.info |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |