08M2, RTC, MOSFET to delay 11-V switch

parto

Member
Hi folks, I have a project which uses the 08M2. I am reading the manual but am finding that I don't have some of the background for that, so I thought I'd try asking here to see whether I could speed up the project a bit.

I am trying to time-delay the start of a system that takes time-lapse photos in a very remote location. The system uses 11 volts. I would like to have the system wait for 2 months in a low power state with the 11 V power conserved, and then turn on the 11 V power. The question here is only about starting the system; not controlling the camera. Startup precision needed is just to the day.

I got help earlier that steered me to an 08M2, a real-time clock board, and a MOSFET. I have put the starter kit together on the Proto Board. I have a Grove DS1307 RTC and a Grove MOSFET.

The RTC has connections labeled GND, VCC, SDA, and SCL. I see that GND is Ground and ACC is 5 V so they go to the G and V holes on the proto board. Looking up SCL and SDA, I find that they are the clock and data pins, respectively. Maybe these are Serial In, and Serial Out (pins 2 and 7), so that the 08M can get clock info in and can program out to the clock?

As for the MOSFET, it has GND, VCC, NC, and SIG. NC I think means Normally Closed, and SIG I think means Signal. Not sure what that means for the pins on the 08M.

I do have some BASIC programming experience, so if I can get this wired I may be able to do the rest, but any help on the wiring would be greatly appreciated!

Thanks!
 

hippy

Ex-Staff (retired)
The RTC has connections labeled GND, VCC, SDA, and SCL. I see that GND is Ground and ACC is 5 V so they go to the G and V holes on the proto board. Looking up SCL and SDA, I find that they are the clock and data pins, respectively. Maybe these are Serial In, and Serial Out (pins 2 and 7), so that the 08M can get clock info in and can program out to the clock?
Welcome to the PICAXE forum.

The 08M2 has an SDA pin ( leg 5 ) and an SCL pin ( leg 6 ) which would connect to the RTC. You may need pull-up resistors or they may already be provided on the RTC board.

Serial In ( leg 2 ) and Serial Out ( leg 7 ) make up the download interface for getting programs into the PICAXE.
 

lbenson

Senior Member
In this context I think NC means "Not Connected".

Pin C.4 (leg 3) would be suitable for controlling the mosfet. Pin C.0 (leg 7) would also be if you were sure you didn't want to be able to monitor what is happening with sertxd (for testing, for instance). Pin C.3 (leg 4) is input only in normal circumstances.
 

parto

Member
In this context I think NC means "Not Connected".

Pin C.4 (leg 3) would be suitable for controlling the mosfet. Pin C.0 (leg 7) would also be if you were sure you didn't want to be able to monitor what is happening with sertxd (for testing, for instance). Pin C.3 (leg 4) is input only in normal circumstances.

Perfect; I was just to that point, wondering what to do with the NC wire, and I had just soldered the SIG wire to the Pin C.4 hole. Thanks!
 

parto

Member
Thanks for your help, folks. I have the clock set and running, and the mosfet is installed on Pin C.4. I have used programs in the manual to set the time and display the data in the debug window.

I have been reading up on the sleep function, but am not sure which is the best was to accomplish the objectives--for example, how to balance the variation in sleep timing due to temperature, versus power savings. The installations will be outdoors, with temperature varying between about 37 and 70 degrees F (3-21 C).

What I am aiming for is a 2-month delay in turning on 11-V power with the mosfet. I have 3 alkaline AAs powering the 08M2, and a disk battery for the DS1307. The precision for activating the mosfet needs to be just to a day.

I am thinking I need to have the 08M2 sleep for maybe half a day, then wake up and check the month and date, and then go back to sleep unless the month is (for example) 6 (June) and the date is 5 (5 June). If the month and date is 6 and 5, then close the circuit on the mosfet. Ideally, I would then have the mosfet open the circuit on another date four months later.

The most important thing is to have the system actually work rather than be precise--there will be a lot invested in setting up the devices in a remote location that can't be visited after installation, until five months in the future.

I have spent a bunch of time on this (installing drivers, dealing with COM port conflicts, learning about ic2, ds1307, and BCD) and am running out. Any help with suggestions on the best functions to use, and any help with programming would be appreciated!
 

hippy

Ex-Staff (retired)
I am thinking I need to have the 08M2 sleep for maybe half a day, then wake up and check the month and date, and then go back to sleep unless the month is (for example) 6 (June) and the date is 5 (5 June). If the month and date is 6 and 5, then close the circuit on the mosfet. Ideally, I would then have the mosfet open the circuit on another date four months later.
I was wrong in thinking the DS1307 has an in-built alarm capability so what you propose is probably best.

You can have the sleep time based on how far the turn-on time is from current time so can sleep longer periods and reduce those as the turn-on time approaches. Likewise for turn-off.
 

parto

Member
OK, so start with say, three weeks of sleep, wake up, check the date, go to sleep for a week plus a day if the date is a day less than expected (or go to sleep for a week minus a day if the date is a day more than expected), then sleep for 4 days and do the same thing, then a day at a time. To maximize sleep time and minimize error. I think I get it; thanks.
 

parto

Member
I've got the program set up and working, using minutes and seconds for testing instead of months and days. I am having trouble finding what is the expected power consumption, in the sleep mode and out of it. I think I am mainly looking at the consumption of the 08M2 itself, since I am not powering the clock (or maybe the clock doesn't use the disk battery unless the power coming from the 08M2 is lost?), and I am activating the mosfet only once (although I suppose there is some power drain there). I can play with extending the sleep time, and it looks like I can use disablebod and maybe setfreq, but some ballpark figures would be useful, if someone has experience with using the 08M2 long-term with a battery. Thanks!
 

lbenson

Senior Member
It uses an 08M instead of an 08M2, but this has been running for 8+ years on 3 AAs.

http://www.picaxeforum.co.uk/showthread.php?8353-Low-Power-Battery-Backup-Reference-Design&highlight=battery+backup

It does not sleep at all, just runs at 32kHz, continually testing to see if mains power comes back on (which it never will) and blinking an LED every 7 seconds. Your project might use a little more power, but I would not think much more. If you want a little more leeway, you could use a 4x-AA battery holder and a diode (or two--test with expected load) to drop the voltage down to picaxe levels. Posters have indicated that an 08M2 in sleep mode should be more efficient than an 08M at 32kHz, but I don't know that rigorous tests have been made.

The battery backup on typical RTC modules is quoted as lasting 10 years. I believe you should be powering it from your main battery, though--I don't think it does anything but keep the time when using only the backup battery.

For how long does your mosfet remain on? If it's an issue, perhaps a latching relay would be better.
 

parto

Member
Thanks very much for the information on power consumption. I hadn't known about the latching relay; I'll look at those and try to figure out the power drain of the mosfet in my application. The mosfet stays open for 2 months and closed for 4 months.
 
Last edited:

parto

Member
I have been using my multimeter to look for power consumption of the various components. I don't know whether it's reliable to measure small currents this way--I just put the meter in line with the battery cable. It measured 11.5 mA with just the 08M2 board without the clock, 12.5 with the clock, 12.5 again with the clock and with the mosfet circuit open, and 16 mA with it closed. I changed the program to just put the 08M2 to sleep, and still got the 11.5 mA without other components. Given the results from your link, I am guessing that I'm just not accurately measuring the current--at 12 mA the 08M2 would last just 2 weeks.

Presently I am thinking you're right about the latching relay. The Grove model of latching relay needs 4.7 V minimum and 5.5 maximum, so I am looking for one that will work at a lower voltage, so it will work with the AAs. Otherwise, it looks like another option is to stack 2 button batteries and use a diode to drop the voltage. More of a project than I imagined at the start!
 

hippy

Ex-Staff (retired)
Presently I am thinking you're right about the latching relay. The Grove model of latching relay needs 4.7 V minimum and 5.5 maximum, so I am looking for one that will work at a lower voltage, so it will work with the AAs. Otherwise, it looks like another option is to stack 2 button batteries and use a diode to drop the voltage.
It appears you have an 11V supply from your first post; can you not use that to power the relay and perhaps even use it to derive power for the PICAXE ?

One thing to be aware of is that the DS1307 will not respond on the I2C bus unless its external power supply is 1.25 times its battery voltage, which generally means 3.75V and can be higher if the battery is above its nominal 3V voltage. The DS1307 has a nominal operating voltage of 4.5V to 5.5V.

If your setup is drawing 10mA, that is 240mA per day, so 2400mA AA batteries would last for just over a week. It should be possible to get consumption lower but it does require careful design.

I am not sure what batteries are in the "low power reference" setup or exactly how long that's been running for now, but assuming 2400mA and 5 years; that's the equivalent of an average of about 0.050mA draw, 50uA.
 

lbenson

Senior Member
Re "low power reference", in the original post: "According to my DVM, this setup on batteries takes 31 microamps, blipping up briefly when the LED flashes to between 50 and 155 microamps". hippy's 50uA calculation is certainly in the ball park. LED duty cycle is on for approximately 128 ms every 7 seconds (visible only when well shaded). DVM was in no way calibrated.

I don't have the box that the circuit is in on hand. The batteries were standard AA--I think EveryReady. They were not fresh when I put them in--had I the slightest idea that I might have been talking about them 8 1/4 years later I'd have made sure they were fresh.

By the way, what is your 11V supply?
 

hippy

Ex-Staff (retired)
Re "low power reference", in the original post: "According to my DVM, this setup on batteries takes 31 microamps...
Many thanks; that was the figure I was trying to guesstimate, a ballpark as to what minimum consumption should be reducible to.

The other way to look at it is, if one had 2400mAh batteries and wanted them to last four months; consumption would need to be on average below 800uA, and in practice probably lower than that.

As well as details on the 11V supply, it might be worth providing an overview of exactly how everything is wired, what's powering what, and what power budget and consumption is required or likely to be faced. Even low currents over a long period can add up to needing big batteries.
 

parto

Member
Thanks for the replies. The 11.1 V power supply is for a time-lapse camera system. There are two 10-amp-hour li-pos. I need all of that supply to power the camera system, and so have been trying to keep the rest on an independent supply.

All I need the rest to do is delay the start of the camera system by about two months: I install the camera system in the remote location and two months later the 11.1 V power switches on. Ideally, it would then turn off after 4 more months, but that's not essential. So minimally, I just need something that will turn on an 11-V, low-current power supply after two months, accurate to with a day or two.

I posted this need in another electronics forum last year and someone recommended the 08M2 Starter Kit, the DS1307 clock, and a mosfet. Since I lack knowledge about assembly of circuit boards, resistors needed, etc. I went with assembled boards for all three. Perhaps the fact that I have the AXE003U Picaxe Starter Pack ( http://www.picaxe.com/Hardware/Starter-Packs/PICAXE-08-Starter-Pack/ ) is the reason that my 08M2 setup on its own (without the clock or the mosfet) consumes 400 times (according to the digital volt meter) the power that the "low power reference" setup uses.

I don't understand the reasons for the difference in power consumption between the two 08M2 setups: 12 milliamps versus 31 microamps. At 12 milliamps my AXE003U board with the 08M2 was in sleep mode, with no other peripherals. That kind of power consumption just won't work for my application. In my experience I need to have everything overbuilt to make it dependable. I was hoping that I just wan't measuring the current correctly.

As for what's powering what in my setup, when it's assembled: 3 AA batteries power the AXE003U. The AXE003U is wired to the DS1307 clock and the Grove mosfet. The clock has its button battery but as I understand it, it the clock also uses power from the AXE003U. The mosfet is of course wired to the 11 V supply as well as the AXE003U, but I don't think it uses any of the 11 V supply. Apparently the mosfet doesn't use much power when the controlled circuit is open, but it uses some when that circuit is closed.

But right now the problem is that the AXE003U apparently uses too much power on its own.

Thanks for the links for the latching relays. I was hoping to find one on a board already, but I could figure out what's needed and assemble it, if I can solve the power consumption issue.

Thanks for your help!
 
Last edited:

hippy

Ex-Staff (retired)
I don't understand the reasons for the difference in power consumption between the two 08M2 setups: 12 milliamps versus 31 microamps. At 12 milliamps my AXE003U board with the 08M2 was in sleep mode, with no other peripherals. That kind of power consumption just won't work for my application.
It could just be that you aren't using all the tricks which reduce current to a minimum; running at 32kHz, pull-downs on all inputs, using DISABLEBOD, disabling ADC. The original "reference design" was for an 08M and the 08M2 may be slightly different but the details and discussions on that are here -

http://www.picaxeforum.co.uk/showthread.php?8353-Low-Power-Battery-Backup-Reference-Design

However, when I add an 08M2 running just a DO-PAUSE-LOOP to my AXE091 experimenters board I don't see any significant increase in consumption, perhaps 1mA at 5V according to my uncalibrated bench supply. That seems in line with expectations so if you are getting 10mA with nothing connected there may be something else going on, something contributing to additional current.

For absolute minimal power use I would probably go for a hardware design which can power up a PICAXE from an RTC alarm signal. Perhaps using an SPI DS3234. The PICAXE itself would then only have to be powered for half a dozen minute or less times during the whole project.
 

parto

Member
[/QUOTE]With a 20Ah power pack available, I'm baffled why you would add complexity (failure points) with a separate Picaxe battery pack.[/QUOTE]

Thanks for the relay info. As for the 11V power packs, I was looking at the reliability the other way: with a separate power supply, if the power consumption of the relay setup used more power than expected and then failed, at least I would still have the power needed to run the cameras. There is a chance I can visit the location after 3 months and if the relays have failed then I can start everything manually. But having to recharge 20 battery packs (I have 10 camera setups) would add complexity to this.

Given that, the controller for the cameras uses 5 V and so there is already a DC converter that brings the 11 V down to 5. If I had a relay setup that I could depend on and if its power consumption were very low, then I could use the 20 Ah power. I like Hippy's idea of using a different type of clock that could power up the PICAXE; I'll look at that if I get time, but I am such a beginner at this that every new idea requires a lot of searching and reading.

Thank you for your help!
 

parto

Member
Oops, I misspoke. The 5 V from the voltage converter wouldn't be available; I'd have it turned off during the two months of waiting time. Otherwise there would be power leaks: the converter uses 1 mA without a load, which for 2 months would be 2 Ah off the top. In addition to that it would use a percentage more for the needed load, for the conversion.

Hippy, I looked a bit at the SPI DS3234. I see that it can be programmed to give an alarm voltage at a chosen date of the month. Is the idea is to somehow use that signal to start-up the PICAXE, and then the PICAXE would check the clock for the month, then then if the month were correct, the relay would be signaled; if not it would shut down and wait for the next signal? I see how to do that if the PICAXE is asleep; is that what we're talking about? It would be like it is with the DS1307, except that because the DS3234 can use its alarm we can be more precise, with fewer wake-ups for the PICAXE. Or are you saying that the PICAXE wouldn't be powered at all between alarms?
 

hippy

Ex-Staff (retired)
The DS2334 has an open collector alarm output so, assuming that can activate when running from its backup battery, that could be used to switch some hardware which provides power to the PICAXE so it would be completely unpowered except during the minute when the alarm activates. I am not sure what that hardware would be.

I was thinking SPI DS2334 rather than I2C DS3232 as it wouldn't require pull-ups which should keep current down and make things simpler.

When the PICAXE powers-up, it reads the time, resets the alarm to the next wake up day, if it happens to be the right dates activates or deactivates the latching relay.
 

parto

Member
Thanks for the info, Hippy. For now I need to look over everything again, since I think I found the problem that caused the wide diversion from my route. When I replaced the 08M2 with my second chip, the power was: 0.62 mA at idle and 0.03 in sleep mode--similar to others' measurements! So I think I can proceed, as long as I can get more of the low-power versions of the chip. Maybe I somehow messed up the one that uses 20 times more power. For now I'll get the latching relay and try the original clock, keeping in mind the second type of clock in case that might work better. Thanks to all!
 

premelec

Senior Member
@parto - I've not fully tracked your application - if there's going to be light during your use small photvoltaic panels could help you a lot! Or various other energy harvesting techniques [even heat differential between sleeping hedgehog and outdoors with Peltier generator...]. Energy harvesting is the rage together with IoT :)
 

lbenson

Senior Member
parto-glad you reached the .03mA usage. That should enable you to do what you want to do. One thing with the latching relays--the ones I have used are right at or above the picaxe pin current rating--around 20-25mA or more needed at 5V for the pulse to set/reset the latch.

The pulse is very brief--10ms has done the trick--and I don't know if that would cause damage in the short term or the long term. It didn't for me, but I didn't test extensively.

If you find a latching relay which does not drive the picaxe at or over the edge, please let us know.
 

hippy

Ex-Staff (retired)
One thing with the latching relays--the ones I have used are right at or above the picaxe pin current rating--around 20-25mA or more needed at 5V for the pulse to set/reset the latch.
Brief over current is probably not that damaging as PICAXE / PICmicro are quite robust in practice.

If worried about that possibility it is possible to parallel two I/O pins and switch them with "LET pinsC=" or "LET dirsC=" which will minimise any time just one I/O will be carrying the load.
 

rossko57

Senior Member
With the aid of simple NPN transistors to buffer the relay coil drive from the Picaxe, you could employ a "12v" latching relay driven from the main power pack. I think that eBay relay-on-a-board 12V version would do, though you would probably have to alter the resistor values for 5V trigger.

Note that doubling up on pins would require 4 for a latching relay.
 

lbenson

Senior Member
The latching relays I have used have been single coil (if I understand that term correctly)--two pins--one high, the other low to set, the reverse to reset, so two picaxe pins and this code to test:
Code:
'08relaylatch.BAS turns on/off relay
#picaxe 08M

symbol setPin = 4
symbol resetPin = 1

start:
  low setPin, resetPin
  pause 2000
  sertxd ("08relaylatch",13,10)

main:
  do
    high setPin
    low resetPin
    pause 10
    low setPin
    sertxd("1")
    pause 3000

    low setPin
    high resetPin
    pause 10
    sertxd("0")
    low resetPin
    pause 3000
  loop
With 100R to one of the coil pins (a substantial, if brief, overload, but no obvious harm in flashing off and on for several minutes).
If pins 1 & 2 on an 08M2 are needed for i2c, then use 0 & 4 for the relay, and no sertxd.
 

parto

Member
Thanks for all the info. Each time I get a reply, I need to read-up on all the terms and topics mentioned, so I am still behind at this point. I can say that I ordered one of the suggested latching relays:

http://www.ebay.co.uk/itm/Bistable-Latching-DPDT-8A-Power-Relay-Module-DC5V-Coil-/151260894847?hash=item2337da167f:g:rmQAAOxy4eJTLokg

There is a datasheet linked there that says, I think, that the trigger occurs at any voltage between 2.5 and 24 V--so that part sounded good. However, I hadn't considered enough the current required to switch the relay. I don't see that listed directly--maybe it's in the resistance data. But since it says that the "Operating current (relay action)" is 120 mA, perhaps this one requires more current than the Picaxe can supply.
 

hippy

Ex-Staff (retired)
It's not clear if that's the current required from the supply to drive the coil or the current required to drive the Darlington ( BC517 with 10K to base ) which switches the coil. I would suspect the former but someone with more expertise in electronics can probably clarify.
 

parto

Member
Thanks. As an aside here I should add that the current for the camera system--the one I am trying to switch on after a 2-month wait--draws (at 11.1 V) just 200 mA maximum (when the camera is on). I was reading up on switches in general and wondered whether because of the low current there is a simpler solution, with transistors or something else (but I still need the power draw at idle to be very low).
 

rossko57

Senior Member
The latching relay draws zero current, this is why others suggested it. You apply brief pulses to flip it this way or that. 100mS or so should be plenty of time. The 140mA quoted for the example is what the relay draws from the supply for the duration of the pulse. The input current to the driver transistor (pulse from the Picaxe pin) should be negligible.
The relay also has the advantage of staying whichever way it was last put, even while the controlling circuit (here the Picaxe) is completely powered off.

This particular relay has separate 'set' and 'reset' coils. As said, some have a single coil requiring reversing current.
 

parto

Member
Sounds good; thanks. Just wanted to be sure I hadn't left out important info. For sure, I like the idea of the relay working without power--seems suited to the application. I will put it all together when the relay arrives and try it out.
 

lbenson

Senior Member
That latching relay module seems to me a bit on the pricey side (except that it can provide 8A), but if it fits your budget, it appears to do exactly what you want, and it may save you a lot of development time. With the two coils and transistors driving the coils with 10K series resistors to the Darlington transistors, there is no danger of over-driving the picaxe.
 
Last edited:

parto

Member
That is great to hear. I am shorter on time than dollars at this point. I am a little short on space in the case--if I knew a lot more I'd probably compact all of this. But I can make it work. Thank you all.
 
Top