0

Reading and writing to flash memory via USB

Posted by Chris on Saturday, October 31, 2009
Re-reading the AT45DB041D Flash memory datasheet, using the chip like an oversized eeprom looks like it could cause us a few problems, namely because of the architecture of the memory. On page 4 of the datasheet, we can see that data needs to be written in 256-byte blocks, or pages as they are called.

Data is stored in an internal buffer before being transferred to/from main storage.
Although this might be useful for us in future, at the minute we're using Flash memory like a mini hard-drive: just somewhere to dump data to be read back at a later date. The use of buffers just adds an extra layer of complexity, so we'd prefer to skip these. Luckily, it is possible to do just this:

A main memory page read allows the user to read data directly from any one of the 2,048 pages in the main memory, bypassing both of the data buffers and leaving the contents of the buffers unchanged.

By sending the appropriate opcode (command to you and me) and a 3-byte memory address, it's possible to set the page number for reading/writing data. Data can be read/written serially from the start of each page. Should more than 256 bytes be written at a time, the chip simply crosses the boundary without delay or error. However, because we now have a bit more RAM to play with on the PIC chip, we're going to try to use our own buffering system in the PIC and transfer entire "pages" of 256-bytes to the Flash memory at a time.

0

Test writing to SPI 4Mbit Flash memory

Posted by Chris on Saturday, October 31, 2009
After making up a board for our ScoreSure game score keeping device, and while waiting for the new QVGA LCD screens from Xing at NuElectronics we put together some code to try reading/writing to the new AT45DB041D 4Mbit flash memory.
As this will be a major part of the ScoreSure v2.0 device, we had to put a bit of thought into it.

The Flash memory organises data into sectors, blocks and pages and supports FAT file systems. It was very tempting to use this - to store bitmap images as JPEGs so that data can be easily dropped onto the device - but decoding images on the PIC so that they can be displayed one pixel at at time would take up a large part of the program space in the mcu. We decided in the end to use a relatively simple storage format, and use a header byte to tell the PIC which method to use to decode the image data.

For example, data could be stored in a palletised sort-of-gif format (albeit slightly different as GIF images need to be licenced!).An alternative method might be RLE (run length encoded) image formats - ideas for images with large blocks of colour. We may yet discover another (simple) way of compressing image data (JPEG is far too complicated to achieve decoding on a PIC) so the first byte of any image "file" stored in Flash memory will be a marker to tell the PIC how to decode it. This should give us plenty of flexibility to use different image storage methods.

The fastest way to get data in and out of the flash memory is serially - set a memory location, then clock the data in one byte after another. The PIC will be running at 20Mhz, and the Flash memory supports clocking data as this speed, so getting images out of RAM should be almost instantaneous.

Our first test will be to retrieve data for a bitmap 320x240 pixels wide.
We will do something simple like flash an LED on at the start of data retrieval, then off once all data has been dragged out. This should give us an idea about how long it would take to retrieve the image data for a full screen, full colour image.

Because we expect our images to be less than 320x240 and to use some form of compression for storing them, this test will give us absolute worst-case scenario values to work from....

2

ScoreSure v2.0

Posted by Chris on Saturday, October 31, 2009
We've been pretty busy here at Nerd Towers these last few days.
After receiving some information about the soon-to-be ScoreSure photo-frame-based-pocket-devices, we've been looking into creating and building a whole new PCB to put inside each one. The new device will be built around the PIC 18LF4550 and use a massive 4Mb Flash memory SPI eeprom (that runs at 20Mhz, not the pathetic 400khz used in the earlier device).



Some of the chips - the flash memory and, although not on the schematic there's a battery charge chip too - which are tiny little SMT (surface mount) chips. The flash memory was mounted onto a custom board quite easily (since our collective soldering skills seem to have improved in recent weeks) but the battery charge IC was a nightmare. We started out with about ten of them, but pretty soon were down to four: ping! "where's that one gone?" sh*te! Dropped one on the floor. These things are seriously tiny!




Look at the size of this tiny little tiddler. About the size of a speck of dust!


The flash chip was relatively easy to solder, after spending 45 minutes getting
the battery charge chip onto the PCB. As the eagle-eyed amongst you might have spotted, we've numbered the pins "upside-down"!

0

Three button menu interface

Posted by Chris on Monday, October 26, 2009






Here's an example of how a micro-joystick could be replaced with a three-button interface (click the buttons to try it for yourself).

The left- and right- most buttons are used to control the menu highlight bar (up/down) and the centre button is "select".

The "edit players" option makes use of mobile-phone style "soft-buttons". The increase/decrease letter buttons have not been coded, but it should demonstrate how player details would be edited. Although functional, we might change this and use a sort-of hybrid "soft-menu" approach: place a menu along the bottom of the screen and highlight the menu options (soft buttons) using left/right (similar to the way the menu option 5 screen works). So instead of pressing one of three buttons to perform an action, the user would highlight the action to perform, then act on it by pressing the middle select button.

This not only means a consistent interface (the red highlight being present in all screens, not just those with menus) but also it would be possible to have more than three "soft" buttons if necessary.

A (flash) demo will be posted here to demonstrate as soon as it's built!

0

You thought you'd finished didn't you?

Posted by Chris on Monday, October 26, 2009
It's the killer question, loaded with malice and intent. What do you mean "you thought you'd finished?". Just because the question has been asked, you know it's not finished.

The ScoreSure range of devices are almost ready to pop into an enclosure and put onto the shelves, just in time for Xmas. (in fact, they probably wouldn't be anywhere near ready for putting onto shelves, but making them in small batches and shipping them out for mail order might be a possibility). All that's left to do is to put all those delicate bits of electronic trickery into a nice plastic box and we're done.

After a bit of emailing around, it seems that the most cost effective way to achieve this is to use an existing enclosure. i.e. find something that uses a Nokia display, battery, eeprom and microcontroller already, and replace the gubbins with the ScoreSure contents. Easy.

The thing is, once we'd found something like this (a cheap LCD keychain for example) the end product is in danger of looking like an, erm, well... a cheap LCD keychain. And given that the cost of producing each ScoreSure device is much, much more than the retail cost of an LCD keychain, it would be difficult to convince customers to part with their hard-earned for something that looked like a, erm, cheap and nasty LCD keychain! So just at the final hurdle, we've hit hit upon (yet) another problem.
How to make something at a reasonable cost, but make it look like a top-end product.

Enter, our old friend Xing from NuElectronics. Luckily, he's interested in helping us out, not just in finding an enclosure, but in sourcing and assembling the ScoreSure device and he's found some lovely pocket-sized digital photo albums, complete with luxury leather-effect wallets!



So now all we need to do is find out what type/model screen it uses (apparently, it's a nice big QVGA 320x240 full-colour jobbie) and replace it's guts with our own MCU, eeprom and battery charge circuit and we're done.

Oh yeah, and re-write the code to work with this new, bigger display.
And since we've a nice big screen, it'd be a shame not to use it, so perhaps rewrite the font bitmaps so they're not so little and fiddly.
And if we can work out how to use a bigger eeprom, it'd be nice to get full-colour graphics instead of the monochrome ones we're using now.

So in short, once we've started all over again from scratch, spent a few weeks learning how to use the new hardware, then re-written all the microcontroller code to use a three-button interface instead of a micro joystick, we shouldn't be too far off having a working prototype.......

0

ScoreSure Petanque Pro Video

Posted by Chris on Wednesday, October 21, 2009
That's right!
We've taken the time to put together a YouTube video of the ScoreSure Petanque Pro device. It includes "quick" and "pro" game modes. Don't know what that means? Watch the video to find out!


0

ScoreSure download software

Posted by Chris on Wednesday, October 21, 2009
With the first ScoreSure device finally complete and ready to put into an enclosure, work has begun on the software used to transfer data to and from the onboard eeprom.
This custom VB app sends byte streams over USB to the device, and can
  • edit/update player details on the device
  • retrieve any new players added to the device
  • download scores from the device
  • upload scores to the scoreresults.co.uk website


At the minute, the software is just a bunch of VB forms, but screenshots will be posted here shortly!

whos.amung.us

Copyright © 2009 .Nerd Club All rights reserved. Theme by Laptop Geek. | Bloggerized by FalconHive Supported by Blogger Templates.