GGHC: The Story Box’s Programming Code

May 4, 2011 by · Leave a Comment 

After few week of work, we have finalize the software for the storybox. The code can be found on the github page. The whole post is describe the code in the repository at https://github.com/sweemeng/storybox

The whole project have 2 main software component, one is on the Arduino, the other is a uploading program on the desktop.

Arduino Software

The Arduino software consists of a set of library and the main program.

The libraries consist of 2 part, one is the storage class, and the word generation class. They can be found at https://github.com/sweemeng/storybox/tree/master/libraries/storyboard

The original implementation of the storage class, WordStorage is using the Arduino internal EEPROM. This is while we are waiting for the Jordan finalize the I2C to external EEPROM, and waiting for the EEPROM to arrive. So this help us to create a standard interface that we use for retrieving word from storage. And we can start work early without waiting. What we learn here is there is a slight delay needed for writing into the EEPROM. Because of this, it is incorporated into the class, just so that it make things easy.

The word generation class, WordGenerator, is the main engine behind selecting words from the EEPROM. From early on we decided on using the delimiter ‘:’. During testing, our member Mats have discovered that reading a large amount of words from EEPROM can take a lot of time. This prompt us to create a simple lookup table on the beginning of the eeprom, based on the idea by Adam. The idea behind the lookup table is.

bit 0bit 1bit 2bit 3
1st0051
2nd0076
3rd0101
:roc

We allocated a amount of N * 4 byte in the beginning of the EEPROM. Each stores the beginning position and ending position of a group of word along with their delimiter which is ‘:’. In the Arduino code, we use 7. We should have around 28 bit allocated for the header. Each with the beginning position and ending position of the word group we stored into the EEPROM. And this is generated by the uploading program, not on the Arduino.

The word group is selected randomly, so instead of select a random word one by one. Then another random select on the word group is done to select a word, within the segment of EEPROM selected. . By randomly select a char within the group, and find the next delimiter, and that consider as the first character, and the next delimiter from it is the last character. We store the beginning position and ending position.

The main program then on a press of a button, call word selection, and from the beginning character, to the ending, read the character one by one from EEPROM, and send it to the LCD.

https://github.com/sweemeng/storybox/blob/master/storybox/storybox.pde

The function to write to eeprom, will just read from serial and write to EEPROM, without preprocessing, as the preprocessing is already done on the uploading program

The PC program

The GUI version of the program to upload the words to the arduino shield is not complete. But a test program that runs on python shell is completed. The reason we use python is because the time it take to write a program is shorter. It will preprocess the word group, and size. and from it, send the processed data over serial to Arduino.

https://github.com/sweemeng/storybox/blob/master/test_code.py

Lessons Learned

What we’ve learned:

  • Use serial, serial connection remain the most reliable way to send debugging information to the Arduino, it would be the equivalent to print in other programming languages.
  • One of the biggest gotcha that we found is a slight delay is needed for writing to external EEPROM.
  • Have access to hardware to test the code on is important. This help us to find and capture all issues early
  • And have abstract out some component is helpful to get us started early too.
For the software team, it is some adventure, while most of us still new in programming Arduino, though we have written web application and/or desktop application. The experience is really different from what we use. For once we only have 16k or memory! For some of us that uses high level language like Python, we appreciate how much that language have done for us.

Share this article

BOM list for StoryBox

May 4, 2011 by · Leave a Comment 

Here’s the BOM list for StoryBox. For this challenge, all of the participating hackerspaces were provided USD900 by the organizer (thanks element14!). To be frank, we didn’t used up all of the money. In fact, we don’t need to use it as we have most of the components available at our space. However, we did spent some amount buying an LCD (yo element14, your LCDs are really expensive, we got a few from Jalan Pasar for less than RM20!) and a few EEPROMs.

NoItemQtyLegendRemarkPrice (RM)
1AT24CXXB-PU1IC1Atmel I2C EEPROM. XX: from 01 to 102412.4
22N39042Q1, Q2NPN transistor0.5
316X2 LCD Module1LCDLCD module, 16X2 Alphanumeric20
4Trimmer – 1k1R6LCD backlit brightness0.5
5Trimmer – 4k71R7LCD contrast0.1
6Resistor 1k3R2, R3, R40.1
7Resistor 220R1R50.1
8Resistor 10k1R10.1
9Ceramic Capacitor 100nF1C1Non polarity capacitor0.1
10Buzzer1SG11
11Tact Switch – N.O1S1Any momentarily Normally Open push button0.1
12Protoshield1Breadboard, veroboard or custom made PCB3
13Battery holder11
14Seeeduino170
Total109

So we spent RM109, roughly USD36.

Share this article

Electronics Friday 22/04/2011: GGHC Build Meetup #6

April 22, 2011 by · Leave a Comment 

We are almost there, hardware and software. We will have some “The Story Box” tonight.

What?

  • Hardware: Etch some PCBs for The Story Box
  • Software: 1. Interface with I2C EEPROM. 2. Test Python based Word List Uploader.
  • Target: We will have some finished “The Story Box” in our hand by tonight.

When?
We are usually open as early as 4pm, with a break for dinner at around 7-8pm. And continue on till 10:30 or 11pm. If you want to come earlier, the best time is usually around 6:30 (before we go off for dinner)

Where?
Hackerspace KL

Who?
Members of Hackerspace KL.

 

Share this article

GGHC Build Meetup #5 (19/04/2011)

April 19, 2011 by · Leave a Comment 

What?

  • Hardware: None.
  • Software: 1. Interface with I2C EEPROM. 2. Write a Python based Word List Uploader.
  • Target: When a button is pressed, the LCD will display a random word (retrieve from I2C EEPROM) for 10 seconds. After that a buzzer will beep to signify the expiry time.

When?
We are usually open as early as 4pm, with a break for dinner at around 7-8pm. And continue on till 10:30 or 11pm. If you want to come earlier, the best time is usually around 6:30 (before we go off for dinner)

Where?
Hackerspace KL

Who?
Members of Hackerspace KL.

 

Share this article

Electronics Friday 15/04/2011: GGHC Build Meetup #4

April 15, 2011 by · Leave a Comment 

Here is a prototype for The Story Board, mounted on a protoshield.

What?

  • Hardware: Draw a PCB layout for The Story Box
  • Software: 1. Interface with I2C EEPROM. 2. Write a Python based Word List Uploader.
  • Target: When a button is pressed, the LCD will display a random word (retrieve from I2C EEPROM) for 10 seconds. After that a buzzer will beep to signify the expiry time.

When?
We are usually open as early as 4pm, with a break for dinner at around 7-8pm. And continue on till 10:30 or 11pm. If you want to come earlier, the best time is usually around 6:30 (before we go off for dinner)

Where?
Hackerspace KL

Who?
Members of Hackerspace KL.

 

Share this article

Electronics Friday 08/04/2011: GGHC Build Meetup #3

April 7, 2011 by · Leave a Comment 

At previous GGHC Build Meetup, we didn’t finish the working prototype as planned. So we will pick up where we left off on this Friday.

What?

  • Hardware: Solder a bare bone prototyping circuit on a protoshield
  • Software: Write a bare bone program + interfacing with I2C EEPROM
  • Target: When a button is pressed, the LCD will display a random word (retrieve from I2C EEPROM) for 10 seconds. After that a buzzer will beep to signify the expiry time.

When?
We are usually open as early as 4pm, with a break for dinner at around 7-8pm. And continue on till 10:30 or 11pm. If you want to come earlier, the best time is usually around 6:30 (before we go off for dinner)

Where?
Hackerspace KL

Who?
Members of Hackerspace KL.

 

Share this article

Electronics Friday 01/04/2011: GGHC Build Meetup #2

March 31, 2011 by · Leave a Comment 

At previous GGHC Build Meetup, we defined the scope and milestone for The Story Box. It’s our target to have a workable prototype by the end of the meetup.

What?

  • Hardware: Build a bare bone prototyping circuit.
  • Software: Write a bare bone program.
  • Target: When a button is pressed, the LCD will display a random word (retrieve from internal EEPROM).

When?
We are usually open as early as 4pm, with a break for dinner at around 7-8pm. And continue on till 10:30 or 11pm. If you want to come earlier, the best time is usually around 6:30 (before we go off for dinner)

Where?
Hackerspace KL

Who?
Members of Hackerspace KL.

And NO, this is NOT an April Fool joke. However, some April Fool pranks might happen in the space.

Share this article

The Story Box Build Meetup #1

March 29, 2011 by · Leave a Comment 

Tonight’s meetup was a productive one. At the end of the meetup, we were astonished as to how simple the Story Box is. But keeping things simple is not an easy task. Especially at a hackerspace. For the past one year, we’ve been a motley crew of hackers, hobbyist, engineers and coders. We operate in an agile environment, and we do stuff as we see fit, or the way we like it. There’s no time frame, no reports, no documentation – just the freedom to build, tinker, make, hack and code the way we want. But in a competition, we have to have discipline. We got to have a plan, and we have to stick to it. And the most important rule of all: keep it simple, stupid.

Kakeman explaining TWI (Twin Wire Interface)

 

During today’s meeting we manage to list out the features that we want to implement. We’ve set milestone and timelines. We got rid of useless features. We drew some diagram. We even have a picture of how the final product will look like.

 

Mind map of the Story Box component and features

 

 

Due to its simplicity, the Story Box is actually pretty simple to do. All you need is an LCD shield, and an Arduino. Or you can have an LCD and a push button, wire it all up to the Arduino, and start coding. And because of its simplicity, The Story Box will be cheap to build as well. The next thing that we will do is to customized the PCB, and make the form factor smaller – enclosed in an acrylic box.

A sketch of the final product

To track progress and making sure that we follow the plan and not go overboard in terms of design and build, we’ve created a simple milestone chart. At the end of the week, we will have a working prototype built using LCD shield.

LCD Shield

and an Arduino with battery

Seeeduino

That’s all for now. In the next post, we’ll introduce our team. (This post is cross-posted to the element-14 community site)

 

 

Share this article

GGHC Meeting 02 (29/03/2011)

March 25, 2011 by · Leave a Comment 

After a fruitful discussion held on the first meeting, everyone was very excited about the challenge ahead. Now it’s time for execution.

What?

  • Build a prototyping circuit.
  • Write a bare bone program.
  • Write necessary supporting documents.
  • Document the whole process as we go.

When?
We are usually open as early as 4pm, with a break for dinner at around 7-8pm. And continue on till 10:30 or 11pm. If you want to come earlier, the best time is usually around 6:30 (before we go off for dinner)

Where?
Hackerspace KL

Who?
Members of Hackerspace KL.

We can make it into semi final :) San Francisco here we come!

 

Share this article

Electronics Friday 25/03/2011 – Special Edition: GGHC Meeting 01

March 22, 2011 by · Leave a Comment 

Our weekly Electronics Fridays meetup is on from 8:00pm – 11pm, 25th March 2011. However, this will not be an ordinary Electronics Friday as we are going to discuss on our participation in the exciting Great Global Hackerspace Challenge (GGHC).

What?

  • Form a team that will be directly involved in the competition.
  • Brainstorm for idea.
  • Plan for winning :)

When?
We are usually open as early as 4pm, with a break for dinner at around 7-8pm. And continue on till 10:30 or 11pm. If you want to come earlier, the best time is usually around 6:30 (before we go off for dinner)

Where?
Hackerspace KL

Who?
Everyone is welcome! Even if you are not a member and you want to check out what HackerspaceKL is about, feel free to come.

Cost?
Free for members. Non-members however, cannot use any of our equipments (to be fair, they are paid by the members). Non-members can buy the electronics components from us. We have stuff to sell to – QuarterK, and Seeeduino.

See you guys there!

 

Share this article

Next Page »

Performance Optimization WordPress Plugins by W3 EDGE

Switch to our mobile site