Shop OBEX P1 Docs P2 Docs Learn Events
Prop's sleep mode — Parallax Forums

Prop's sleep mode

PhilldapillPhilldapill Posts: 1,283
edited 2013-09-09 20:20 in Propeller 1
How do you make the prop enter sleep mode? I am building a battery logger, and need to sample the battery voltage about once a minute, or longer. Once I take a sample, I will write it to an SD Card and then shutdown any peripheral power consumption. I need the power consumption to be as low as I can get it in between samples. How should I do this?

Comments

  • J. A. StreichJ. A. Streich Posts: 158
    edited 2008-06-23 18:51
    Propeller has no sleep mode. Few cores=less power, few pins=less power, slower clock=less power. Mike Green had a good post about this... *looking*
  • LeonLeon Posts: 7,620
    edited 2008-06-23 18:57
    Doesn't one simply slow the clock right down?

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
  • J. A. StreichJ. A. Streich Posts: 158
    edited 2008-06-23 18:59
    http://forums.parallax.com/forums/default.aspx?f=25&m=273804

    Yes, that is one very effective way of conserving power, but it also helps to stop the other cogs, and do nothing but waitpne or waitpeq.
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-06-23 19:01
    How do I change the clock speed on the fly? I suppose I would take a sample, slow the clock to the internal slow, wait X time, then switch back to 80mHz, sample, and repeat? What code do you use to slow/speed up?
  • J. A. StreichJ. A. Streich Posts: 158
    edited 2008-06-23 19:04
    From the link: "RCFAST and RCSLOW. RCFAST runs at roughly 12MHz although the range is 8MHz to 20MHz. RCSLOW runs at roughly 20KHz with a range of 13KHz to 33KHz ... CLKSET statement to set either RCFAST mode or RCSLOW mode"
  • Mike GreenMike Green Posts: 23,101
    edited 2008-06-23 19:06
    General rules:
    1) Shut down all unnecessary cogs. This can be done by stopping them or having them wait for something using WAITCNT, WAITPNE, or WAITPEQ.

    2) Turn off all unnecessary peripherals

    3) Switch to using the RCSLOW internal clock

    4) Make the remaining (main) cog wait using WAITCNT. This will make your timekeeping inaccurate because RCSLOW is inaccurate, but it may be good enough.

    5) When it's time to log something, switch back to the crystal clock, power up the peripherals, and do the logging.
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-06-23 19:12
    I've turned all my extra cogs off, but I need to cut the power for the remaining cog. Mike, you said to have the last one wait for something... if I use a simple WAITCNT, and let it wait for clkfreq*30, does this mean it is cutting power dramatically? I thought the clock was still ticking away as this is how it counts the time to wake up...

    As for slowing the clock down, I've looked in the manual and don't have any luck getting it... example code anyone?
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-06-23 19:14
    If RCSLOW uses the least power, I'd like to do that. Could anyone show me how to switch from 5mHz external crystal, to RCSLOW, and back?
  • pgbpsupgbpsu Posts: 460
    edited 2008-06-23 19:19
    Philldapill-

    I've been investigating this same problem and concluded, as Mike and others suggest that the best thing to do is to shutdown all possible cogs and leave a single cog in a WAITPNE/PEQ state. However, when I tried the following code, attempting to get the LOWEST possible power consumption by basically shutting down the entire chip, I still get >27milliAmps. Interestingly, current consumption doesn't change when the chip stops toggling pin 16 and shuts down. A FAR, FAR cry from what the datasheet suggest one should get. I ran this test on the Proto board with my DMM wired in as an Ammeter. Since I don't see a change in current consumption between the active part of the code and the stopped part, I assume that drop is hidden behind the nearly 30mA I'm measuring. Is this simply parasitic consumption of the protoboard? The wall-wort? Are the regulators on the proto board that bad? Has anyone else actually measured the "low power" state of a proto board? If so, what did you find, and how did you get there?

    pgbpsu

    {{Do Nothing.
    
    This object stops the current cog.  Used for setting EEPROM to known state.}}
    CON
      _CLKMODE = RCSLOW
      PIN = 16
        
    VAR
      byte Cog
    PUB Main
      dira[noparse][[/noparse]PIN]~~
      repeat 1000
        !outa[noparse][[/noparse]PIN]
    
      cog := cogid
      cogstop(cog)
      
    
    
  • Mike GreenMike Green Posts: 23,101
    edited 2008-06-23 19:58
    pgbpsu,
    1) You don't have to do the COGSTOP. When Main exits, the Spin interpreter will automatically do a COGSTOP.

    2) Where are you measuring the current? Remember that the Protoboard has a power LED (maybe 5mA).

    Post Edited (Mike Green) : 6/23/2008 8:06:13 PM GMT
  • pgbpsupgbpsu Posts: 460
    edited 2008-06-23 20:10
    Hi Mike-

    Thanks for your response.

    I didn't realize that reaching the end of Main, would automatically perform a cogstop. I was just trying to do everything I could to get consumption down.

    I put my DMM in the power supply line to the board (before the board). So I am seeing the current draw from the LED and the regulators and anything else that needs power on the board. However I'm still surprised that consumption sits around 27mA.

    Thanks,
    p
  • AribaAriba Posts: 2,690
    edited 2008-06-23 20:27
    Philldapill said...
    If RCSLOW uses the least power, I'd like to do that. Could anyone show me how to switch from 5mHz external crystal, to RCSLOW, and back?

    Untestet! :
    ' switch to RC-Slow
      clkset %000_00_001, 20_000
    
    ' switch to PLLx16
      clkset %011_10_001, 20_000        'PLL and XTAL1 on
      waitcnt clkfreq/100+cnt           'wait 10ms for stabilize
      clkset %011_10_111, 80_000_000    'switch system clock to PLL
    
    



    Andy
  • Mike GreenMike Green Posts: 23,101
    edited 2008-06-23 20:29
    Why are you surprised? The board was not designed specifically for low power consumption. 30mA is very reasonable given that USB will supply 100mA ... no questions asked. 9V radio batteries are regularly used to supply 30mA or so. A rechargable AA NiMH battery pack will provide 30mA for a couple of days straight.
  • pgbpsupgbpsu Posts: 460
    edited 2008-06-23 21:06
    Mike-

    I know the proto board is not sold as a low power design. I was just hoping it would be low enough power. That hope was rooted in the small parts count on the board and overall simplicity of the board, not in anything expressed or implied. It would have been great luck to have a chip capable of "sleeping" so quietly on a board that allowed for one-off low-power systems that were quick to build (and change).

    I'm thinking of low sample rate stuff (1/hr or day). It would be nice to put the prop to sleep, wake up, record, go back to sleep and to build that system right onto a proto board. Here I'm thinking of quick and cheap systems that would be more like 1 offs than 10,000. I guess that's one of the trade offs between simple, cheap, and low power.

    Thanks for re-assuring me that the prop itself can be low power.

    Regards,
    p
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2008-06-23 21:18
    There must be a chip that can do the off-timing and use less power than a waiting prop. Why not use it to wake up the prop? And then have the prop reset the timer and turn itself off until the next wake up.

    The question would be then: is the boot sequence more power hungry than just waiting?
  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-06-23 21:45
    pgbpsu said...
    ·I was just hoping it would be low enough power.

    Regards,
    p
    This is a subjective term, impossible to quantify something which everyone has a different conception of. If you are going for an ultralow consumption you will have to create your own board, no led and using switching regulators. Nearly all of that power consumtion you are seeing is due to the regulators. SEPIC converters are ideal for battery powered applications, the input voltage can be either above or below the output voltages (most other topologies require it to be on only one side (boost Vin < Vout, buck Vin > Vout). So you can use a single cell lithium ion battery to supply a Prop with 3.3 V even though the voltage output by the lithium can drop below 3.3V in it's discharge cycle. It also has a dramatic increase in efficiency over linear regulators.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.

    Post Edited (Paul Baker (Parallax)) : 6/23/2008 9:52:28 PM GMT
  • pgbpsupgbpsu Posts: 460
    edited 2008-06-24 01:22
    Hi Paul-

    Thanks for your post. I agree that the concept of "low power" varies from one customer/application to another. Unfortunately, a design that drains a 9V battery, even when the prop is in sleep mode, over the course of a few days isn't "low enough" power for our current application. My attempts at getting low current draw from the proto board in sleep/stop mode were efforts to prove that a sleeping prop is indeed low enough power. It seems from the datasheet, from what Mike has written, and from what you've said that it will be if we design a board to go with it. My attempts with the proto board only reveal that the proto board won't meet our needs, but it seems like a custom board, with switching regulators and no LED, will.

    I hope I didn't sound like I was complaining. I love my proto and demo boards. And they are the right price. But I'm cheap enough to want it all from them. Add to that I'm not a hardware guys and it all makes sense....

    Thank you for the suggestions.
    Regards,
    Peter
  • kenmackenmac Posts: 96
    edited 2008-06-24 02:29
    Hi folks,
    I recently built a project which used the main Cog running as an RTC, plus 6 Cogs doing various things externally .
    Of course it required a battery backup to retain the Time accuracy when not powered from the Mains.
    To implement this with the smallest battery (the power outages are a maximum of 2 days) it was necessary to shutdown all Cogs other than the Main one.
    I found that running on 1 Cog with no external load, at 5mHz (Xtal) the current drawn by the Prop was <1mA.
    Of course, this was on a purpose built board, not a Protoboard.
    The Prop's Specification on current drawn says : 0.5mA per MIPS (MIPS = Freq in MHz / 4 * Number of Active Cogs)

    kenmac

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Perth, Western Australia
    Time Zone = GMT + 8
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-06-24 04:25
    Yes, that is what I found too. If you measure the current from the regulators to the prop, you'll get a tiny reading. I guess, like Paul said, the key is finding reliable, low power regulation parts to cut down on current draw. Thanks everybody for the help!
  • Mag748Mag748 Posts: 266
    edited 2013-09-09 14:51
    Would this Cause the Prop to remain in the lowest possible state until a reset is asserted?

    Assume the following:
    -PIN_MIC841_Output is the output of a voltage comparator that monitors the voltage of a battery
    -When PIN_MIC841_Output is low, the batt is too low to operate
    -When power is applied to the battery for charging, the prop is automatically reset.
    -readStatus is a method that reads a tri-state input
    PUB Main | voltMon
      voltMon := readStatus(PIN_MIC841_Output)
      if voltMon == 0
        return
    
    ...
    

    Thanks,
    Marcus
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-09-09 15:25
    Mag748 wrote: »
    Would this Cause the Prop to remain in the lowest possible state until a reset is asserted?

    Assume the following:
    -PIN_MIC841_Output is the output of a voltage comparator that monitors the voltage of a battery
    -When PIN_MIC841_Output is low, the batt is too low to operate
    -When power is applied to the battery for charging, the prop is automatically reset.
    -readStatus is a method that reads a tri-state input
    PUB Main | voltMon
      voltMon := readStatus(PIN_MIC841_Output)
      if voltMon == 0
        return
    
    ...
    

    Thanks,
    Marcus

    How often does the voltage need to be monitored?

    If you could wait a few minutes between checks, you'd save a lot of power by using "waitcnt(cnt)" or some other wait amount. The longer the cog can be waiting, the less power it will use.

    You need some sort of loop in your code. Does some other method call "Main"?
  • Mag748Mag748 Posts: 266
    edited 2013-09-09 20:00
    Ok, I forgot to mention that there is another loop happening further down in the main loop that is checking this same variable, and when it detects that it is low (that the batt is too low to function) it will call a "reboot". This will then cause the prop to reboot, and fall into the trap at the top of the Main method, which will cause it to "return" to nothing and just shut down. That is what I would like it to do in theory anyway.

    Thanks,
    Marcus
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2013-09-09 20:20
    Mag748 wrote: »
    Ok, I forgot to mention that there is another loop happening further down in the main loop that is checking this same variable, and when it detects that it is low (that the batt is too low to function) it will call a "reboot". This will then cause the prop to reboot, and fall into the trap at the top of the Main method, which will cause it to "return" to nothing and just shut down. That is what I would like it to do in theory anyway.

    Thanks,
    Marcus
    Marcus, I'm surprised you received a response considering you are not following forum etiquette. Please do not hijack a thread, and a very old one at that, just start a new thread and make sure you don't hold back with information either as it is frustrating trying to answer vague and/or incomplete questions.
Sign In or Register to comment.