Q. Power and storage consumption #4641
Replies: 1 comment
-
Posted at 2015-04-22 by DrAzzy You'd need to give a lot of thought to periodically save();-ing... I'm not sure that's a great idea. The Espruino sleeps while the interpreter is idle, but you can also setDeepSleep() to make it sleep more aggressively - see the reference page. If it's that small an amount of information that it would fit in ram, you could save it on an EEPROM (like AT24 ) - see http://www.espruino.com/EEPROMs What's the issue with using a (micro)SD card? Posted at 2015-04-22 by JackBennett No issue other than I thought avoiding it might be easier. I'm probably wrong. Posted at 2015-04-22 by DrAzzy With v77 of Espruino firmware, it should be as simple as wiring up a uSD breakout board, and making one extra function call before doing the filesystem calls (v76 for pico wasn't built with the support enabled - this omission is fixed). Using sd card on Espruino is simple, and you get oodles of space for cheap, and it's super easy to transfer to computer. It's great for datalogging. It's less ideal if you're storing data and then later using it on the Espruino - you can do it, but it's more awkward than an EEPROM. Neither EEPROM or SD card is hard to interface with on Espruino. Posted at 2015-04-22 by @allObjects
Answer from @gfwilliams: plug-and-play for USB is not an option (yet)... may be it has changed. I had similar ideas when Pico was in the making and in scope definition. Because the USB infrastructure is already there, why not use it, for example also to drive any of the available communication dongles - Bluetooth, Wifi,... Posted at 2015-04-22 by @allObjects On a different note that USB connection and storage: What kind of GPS board/provider are you thinking about? Posted at 2015-04-22 by @gfwilliams There's no support for USB host (I think it requires extra hardware anyway), so you'd have to do something else. As others have said, SD card is probably easiest (in the next released version of the firmware), but then there are also several other types of EEPROM that will work and could potentially be a bit smaller/draw less power. Using a Typed Array and saving would work, but If you're confident in the battery then I guess you may not need to worry about saving at all - just let it run and pick up the data afterwards. Using For peak power, I can't remember the measurements but it should never go above 40mA. Potentially the SD card could add a lot of power draw though - honestly the best bet is probably just to measure it when you've got it all set up :) Posted at 2015-04-22 by JackBennett So I went and read setDeepSleep and I'm thinking the following; I need 2 things;
If I log coords every 2 seconds that will let the pico sleep the most and keep a lot of tracking. Obviously up at 30 logs per second I can just cache the GPS coords and have them change as the board can send me location updates. I don't need that to exactly correlate. I assume the GPS will have a large inaccuracy anyway. Since time was an issue I've just bought the GPS unit in the docs so the Ublox NEO6MV2[pdf] I was assume worse case 250mA as that's is what the pico transformer says it maxes out. As you can imagine sizing a battery was getting concerting. 40mA is good to hear I know peripherals will add to that. Can the pico sleep and leave the GPS unit logging away as it is clearly not going to wake up and get a signal in the time I'm talking about. Will I need to wire power to that directly to keep it on or best just to forget about sleeping the pico? I'll trade you all your help for a blog post on how this goes. Posted at 2015-04-22 by @gfwilliams Ahh - Yes, with setDeepSleep the Pico won't be able to receive data from the Serial port - which could make life a bit more tricky. I think in normal mode the GPS sends data once a second, so the easiest option might be something like:
If you could speed up the baud rate output by the GPS then you'd also be able to limit the amount of time the Pico has to stay awake for.
If you mean peripherals inside the chip, I think you're fine - 40mA should include basically all of those. Looks like the GPS itself could draw ~70mA at startup though - but that's still low enough it can be run off the Pico's 3.3v regulator, so choosing a battery should be pretty easy. As far as logging every so often, I wonder whether you can put the GPS into a low power mode via the USART, or whether you'd have to physically switch off the power to it if you wanted to save power when idle. Looks like finding a battery will be easy though. It looks like without any power saving you'd be looking at under 50mA power draw total, so a single 3000mAh 18650 lithium battery would do 60 hours - which is quite close to what you need anyway. Use two of them in parallel and you should have plenty in hand. Posted at 2015-04-22 by JackBennett I thought the data event from the GPS would wake up the pico if it was over 1.5 seconds. From what you've said I'll need to make sure the pico is awake on time. In that case and considering what you've said about power I might leave using sleep for a v2 of this. I'm not seeing how I can use a I would be worried about rounding errors in the timers, what's the resolution to the clock? I know IE was famous for only going down to 15.6ms Posted at 2015-04-22 by @gfwilliams The issue is that when the Pico is properly 'deep' asleep, the high speed oscillator is off (which means there's no clock going to the Serial port either, so it can't receive any data). It's why You can do setWatch on the serial signal, but by the time the Pico has woken up you'll have missed the first character or so of the data - hence why the code above...
It's 1/32768 of a sec when asleep, or when running it's nearer 1/1,000,000 sec - so probably not an issue :) What could be a problem is more the time it takes the JS to execute. So yes, it might be better to leave the real power saving for a while - I've just tested and without setDeepSleep the Pico is still only using 10mA normally, so for what you want that'll be fine. The F401 chip in the Pico also has much better clock control - the CPU can slow itself down from 84Mhz, saving a lot of power. That's something I plan on adding soon too - and when that happens you should be able to reduce power consumption a lot without even having to use Posted at 2015-04-22 by IanWatkins Probably not much help, but I have run the main Espruino board, single I2C board for pressure, temp and humidity and NEO6 GPS all logging every second to microSD card for 24 hours (so little sleep) from a 1000mAh 3.7v LiPo with power to spare, though not much. So assuming you can power down external kit while sleeping, battery requirements won't be huge I would have thought. Posted at 2015-04-23 by JackBennett At the risk of sounding dim, The gps npm module is giving my compile error s so it can't mean to pull that one can it? Posted at 2015-04-23 by DrAzzy Are you entering that on the right side of the IDE? If you enter it on the left side, it won't be able to load the module. When you send code from the right, the IDE goes to the Espruino website, downloads the GPS module, and sends it to the Espruino, in addition to the code you're sending. Posted at 2015-04-23 by JackBennett Ok I'm using the right side. Maybe my serial console is set up wrong, the gps is flashing merrily away but my If I just test Serial2 I can a pin can't RX but that's because it's not hooked up. Serial1 doesn't leave any errors. Just no output.
outut
Oh and I've waited a while and the GPS flashes green every second. Posted at 2015-04-24 by @allObjects You don't need this extra Posted at 2015-04-24 by @allObjects For more details - and foremost extending the line handler - consult these conversations:
Posted at 2015-04-24 by @allObjects This would be your get going sequence:
It takes some time for the module to actually provide a line that the line handler can process... Before useful data shows through the default handler, the gps (hardware) module receives already lines and sends them to the (js) module, but they are not yet the lines the default handler looks for. That's why I added an enhanced handler that gives more information back then the default handler built into the Espruino module. When I built it, I was not familiar with the module build/update process... but now I could make a pull request and have other's benefit automatically from the get going. Posted at 2015-04-24 by @gfwilliams The other gotcha is that GPS TX should be connected to Espruino RX, rather than TX to TX. Also it's possible that the Baud rate is wrong, as it looks like the same GPS can use different baud rates depending on how certain pins on the chip are connected. Posted at 2015-04-24 by JackBennett Gordon yes I read that too I did try the 3 different baud rates but no change in output. I was staring at those RX/TX pins and thinking what you just said. I bet it's that. Thanks for the handler help I'll read everything today and try these changes when home from work. Posted at 2015-04-24 by @gfwilliams Ok, the other option is to simply do:
Hopefully that'll dump out a bunch of times (assuming the signal is getting through to the pin). If you take the shortest time you see appearing relatively often and then do Posted at 2015-04-24 by @allObjects
How slower can it be clocked? ...down to static? (like some CMOS uCs that were/are sent to space? ...down to single steppinh the clock? (Of course, that would disable wake ups, etc.). It is for sure an interesting feature...
How fast is the thing moving that you track? ...and what is the resolution you expect? This may together with sending GPS to standby/sleep may give you various types of relieves:
Posted at 2015-04-24 by JackBennett Where is the gps module source code by the way? Or even the complete api reference for it I can't find a page. If there isn't I'll help write one. I've got this giving me data now. Yes I have the RX/RX pins matching not crossing silly me. Just getting lat,lon,fix,satellites and altitude now and I see the chip could give me a lot more. It did indeed take ages to receive a signal. There's a nice green LED on the GPS module that flashed when it ticks and has a signal fix. Posted at 2015-04-24 by @allObjects For Espruino module, that is what you get: a The module is at http://www.espruino.com/modules/GPS.js . I list it in this thrad for discussion purpose. This source is what I cloned and enhanced for my purposes. You can to that easily for yourself as well. This are the steps:
Now to the module code:
When you say Unfortunately the way the module is built and without changing it/that, it does you not give access to change this handler with something of your's that would be more powerful. The only thing accessible to you in the object reteurned from .connect() is an object with one property, and that is the data recieved but not processed yet by the handler. When the moudule is changed so that the module's integrated handler is put into thet returned gps object as a "handler:" property (in line 31) and then referenced in line 38, you could put just any other linehandler in there right afert connect. You have serveral options of remedy: First option:
Second (preferred option) {
For the (anonymously) provided handle function(line,callback) you can do something like that:
Make sure your line handler as well as your applicaiton callback processing happens within the timeframe the next data come... Posted at 2015-04-24 by DrAzzy Re: 9 - there's now an option for offline minification in the IDE! Posted at 2015-04-26 by JackBennett Hope fully this SD breakout will arrive in time and I can wire it up to the Pico. I put my meter on the USB from my PC to the espruin and it's pulling a steady 110mA while blipping the LED and logging to the serial. I think I'll order a 3000mAh battery I've seen for a couple of quid more than the 1300mAH one that would have nicely fit in the case. Just for some peace of mind. With some work on power management I bet this could get really efficient. Posted at 2015-04-27 by @gfwilliams Is that 110mA with the GPS connected as well? Seems like a lot for just the Espruino! Looking at the datasheet, I think the power draw will fall quite a lot when the GPS has satellites it's 'happy' with. Posted at 2015-04-27 by @gfwilliams Just to add - I think the SD breakout will work, but you don't actually need one with level shifters (as the Espruino IO is already 3.3v volts) Posted at 2015-04-27 by JackBennett Thanks Gordon, Yes that's the GPS attached too. I had it on for about 10 minutes and it isn't dropping. But last time I watched it it's quite happy to find more and more satellites. I don't actually have a problem with it trying to get more accurate location data. The datasheet does say it has some 40mA or lower after about 12 minutes of tracking. I will test this tonight. Something I couldn't work out about the SD adapters (I didn't look for long) is some have about 15 pins and others 7. Do some boards give a nice SPI interface and others break out the the pin such that I'd have to address everything myself/a fs driver. As I understand it SD and is surface mount type is just a very basic chip that lets you address the flash directly, unlike fully driven pen drives or SSDs. Posted at 2015-04-27 by JackBennett GPS Disconnected my pico sits at 30mA, that code setups up a serial port and has a print function attached to the data. Posted at 2015-04-28 by @gfwilliams Ok, great - that's a lot better. For basic SD cards (in MMC mode), all you should actually need (and all Espruino needs) is: GND, 3.3v, CLK, DI, DO, CS For higher speeds (in proper SDIO mode) you can use two extra pins for data I believe (although Espruino doesn't do that right now), but I have no idea why others would have 15! Posted at 2015-04-28 by DrAzzy There are a lot of SD modules for arduino/etc like that, with a 2x8 row of pins; most of the pins are grounded. No idea why they did that. Posted at 2015-04-28 by JackBennett I've got a 4AA battery pack, with the 2100mAH NiMH 1.2V cells that's 4.8v. Is that too much for the JST connector on the back? I'm thinking with it being less than a USB port voltage(5v) it should be ok. Otherwise I'll make a 3 battery pack for 3.6v. Posted at 2015-04-28 by DrAzzy Do the 4 That power input good to BAT_IN, per Pico page, the Pico can take up to 16 that way (less if drawing heavy current from the 3.3v on the Pico, of course) Posted at 2015-04-28 by JackBennett Yeh my bad, I've been skipping around the references pages so much. it's in the pico bullet pionts
The regulator being one of these http://html.alldatasheet.com/html-pdf/74620/MICREL/MIC5205/181/1/MIC5205.html as noted on the larger board power diagram. I'm a bit paranoid with power. I've quite a few memories of plugging stuff in and it never working again. Same feeling you get when flashing firmware. Posted at 2015-04-28 by DrAzzy Hmm, I've only fried a processor once (An attiny84 on my BFFL*), when I put 30v on an input after a flubbed repair job when I burned the ground trace by powering it while it sat on a conductive surface. Other adc channels still worked. Dcdc converters, I smoked like 3 of them within a couple of months last summer on same project. *big fucking flash light -150W Posted at 2015-04-28 by JackBennett I'm a bit shocked how easy that was. So testament to Gordon there excellent work. Took a bit of figuring which pins my board meant by DO,DI and CLK but not hard. I can't seem to write a line to the card once per second (2 seconds is fine) so I'm going to try appending a list in memory and flushing the list every few seconds. Hopefully it will sequentially write quick enough once it's started. As this is a power thread
Sits at 29.6mA and blips to ~32mA to write. Posted at 2015-04-29 by JackBennett Or it did work, after plugging in the GPS too now I'm constantly getting Posted at 2015-04-29 by DrAzzy Did you lose the call to initialize the filesystem? Have you tried disconnecting it from all power, waiting a few minutes, and plugging it back in? I routinely encounter situations where a piece of hardware gets unhappy, and brief power cycles don't work (presumably because of the caps on the board?) Posted at 2015-04-29 by DrAzzy And - just realized that I missed something. You want the power on BAT_IN, not VBAT. With battery on VBAT, it isn't protected from the USB trying to charge the batteries (you're always protected from the batteries trying to power USB) Posted at 2015-04-29 by @gfwilliams @Jackbennett maybe you could try putting a decent capacitor across GND and 3.3v? While the regulator can supply the power it's possible that the power draw from GPS and the SD card makes the power line a bit unstable. Posted at 2015-04-29 by JackBennett No I'm still stuck with Here's my wiring
Here's how it executes;
I know the GPS is unplugged there by the way. I had it logging the GPS. I had it writing a like to a file. Now together I can't write to the SD and this first SD test isn't running. I reflashed the pico too. same thing. Posted at 2015-04-29 by @gfwilliams just a thought - what about connecting vcc on espruino to 5v on the sd card, and maybe disconnecting the 3.3v. The level converter may need power too Posted at 2015-04-29 by @gfwilliams you probably did this,but i'd push the pico down further into the breadboard. I'd be surprised if it makes contact like that Posted at 2015-04-29 by DrAzzy Does the SD card still read from your computer? Always good to check that with SD cards. They are incredibly unreliable. I've had 2-3 of them fail on me during use within the past few years. In one case I wasn't moving, and the song I was listening to on my cellphone stopped. In another, it was doing pretty much what you're doing. Posted at 2015-04-29 by JackBennett I'll try another SD card as this one is out my very old phone. And I'll push everything down into the board more. The pins are quite long though. I can read/write to the SD card in my PC and it's formatted with the SD formatter tool. Posted at 2015-04-29 by DrAzzy Well, then I doubt a different SD card would fix it... hmm. Posted at 2015-04-30 by JackBennett I put in a new SD card low and behold it worked again. So I got quite excited soldered it up and tested it again and it was still working great. Thought right nows the time for the battery. Disconnected from the PC I put in the 4x1.2v 1800mAH AA pack and the leds came on for things. Stopped it and went back on the PC connection without battery and now I'm back to Very perplexing. I can't read/write to it at all now, tried formatting it and reflashing the espruino. PC read and writes fine. Posted at 2015-04-30 by JackBennett I have a new SD reader now too so can't have been that. Posted at 2015-05-01 by JackBennett Alas my deadline has come. I suspect it's some grounding problem when I'm not on my laptop on charge. I don't know enough electronics yet. I've yet to look at the SD source code to try and find a more helpful error message. Thanks for your help guys. I'll keep working on it and try to have it ready for another time. Posted at 2015-05-01 by @gfwilliams Shame... The |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2015-04-22 by JackBennett
Hi, I'm trying to knock out a project with my new pico for May. I need to log GPS co-ordinates for about 9 hours for 3 days. I can charge between that. Then offload all this data to a pc.
I've been reading some docs and I think I'll have to write this to an SD card. Would another option be to use a typed array in RAM and use save() every now and then so I don't have to panic about losing power and all the data?
I see the sleep current draw advertised but what's the peak power so I can make a worst case estimate to size the battery I'm buying (factoring in the GPS unit naturally). I assume the pico will sleep as best it can for me? I'm used to the arduino and I'd have to program in the sleep calls.
Is there any way to put a female USB-A on a pendrive and get the pico to write to that? Just trying to get out of doing the SD card bit of I can.
Beta Was this translation helpful? Give feedback.
All reactions