Вы находитесь на странице: 1из 11

The Emotional Stock Market

Documentation for Printing Tweets


By Max Dovey

Receipt printers
All shares in an emotional enterprise are sold by printing
tweets as receipts to the customer. I have to work out how
to print tweet search results.

I need to get 3 cheap thermal receipt printers.


Checklist
 An old receipt printer - I have a Citizen CBM-231

from ebay

 An Arduino board, bread board and jump wires

(from Cool Components)

 An Arduino Ethernet shield (also from Cool

Components)

 A MAX233 Chip and serial plug (from Maplins)


The serial output of the Arduino board isn't natively
compatible with the printer - you need to run the signal
through the MAX233 chip to transform the output to the
correct voltage.

http://tomtaylor.co.uk/projects/microprinter

Luckily I wasn’t the first person to want to do this….


Product Identifiers
Brand Citizen
Model CBM-1000
MPN CBM1000IIUF120S-CW, cbm1000iiuf120cw

Key Features
Printer Type Label
Family Line Citizen CBM
Output Type Monochrome Printer
Black print speed up to 150 mm/sec
Platform PC

Technical Features
Extend Printer Technology Thermal Inkjet
Interface Cable, Parallel (IEEE1284), RJ-45 Network Adapter, Serial
RS-232C, USB
Form Factor Desktop, Point Of Sale

Media
Media Type Roll Paper
Max Media Size Roll (8 cm)
Media Capacity 1 Roll(s)

Networking
Networking Type 10/100BaseT
Data Link Protocol Ethernet, Fast Ethernet, IEEE 1284 ECP/EPP

I have bought 8 CBM 1000 printers.

Guide to getting the CBM1000 up and running.

http://microprinter.pbworks.com/w/page/21489360/CBM-
1000

Once my eight receipt printers arrived I checked they all


turned on. 5 out of the 8 worked on there test print
function.

Getting the printer printing digital text


The Input on the printer is a serial female 25pin. The
computer signal has to be changed to talk to this analogue
input. So a bit of electrics and circuits has to happen.
Luckily I found this circuit diagram for my cbm1000. ( a
neater version of what is above)
The Max232 chip converts the voltage from the computer
to the printer. I learnt a lot about jump cables, capacitors
and fiddled for a great deal of time.
Once the circuit was made we had to test it. We found
some code by roo Reynolds on github –
https://github.com/rooreynolds/microprinter/that is a driver
for processing to send digital signals to receipt printer via
arduino.
TEST PRINT WORKED

With Roo Reynolds arduino sketch we were able to enter


text to print in processing via arduino then converted into a
25 pin serial signal.

PROBLEMS
The arduino circuit was very messy and I was concerned
that it would be vulnerable during the installation.

I did not know how to get the printer to print tweets from
twitter in real time.

Python
According to other examples of other social microprinting
devices it was easier to send online posts to a receipt
printer with the programming language Python. Ben O’
Steen had created a sketch using roo Reynolds code for
processing to print onto receipts.
https://github.com/benosteen/microprinter

The Python option was more appealing because it cut out


all the wires, at the expense of having to work in a much
more complex programming language. I also found a very
simple example from a german hackerhouse that
appeared to be so simple –
import serial import time import tweepy # Twitter credentials auth =
tweepy.OAuthHandler("<InsertConsumerKeyHere>", "<InsertConsumerSecretHere>")
auth.set_access_token("<InsertAccessTokenHere>", "<InsertAccessTokenSecretHere>") api =
tweepy.API(auth) # receipt printer is connected via serial-to-usb converter printer =
serial.Serial("/dev/ttyUSB0", 19200) while True: # read savepoint file = open("id", "r")
savepoint = file.read() file.close() timeline = api.friends_timeline()
timeline.reverse() for status in timeline: # assuming that
Twitter assigns IDs in ascending order message =
"(%(created)s) %(screenname)s: %(statusmessage)s\n\n" % \
{"created" : status.created_at, "screenname" :
status.user.screen_name, "statusmessage" :
status.text.encode('cp437', 'replace')} printer.write(message)
# write savepoint file = open("id", "w")
file.write(str(status.id)) file.close() # Twitter API allows
350 requests per hour (every ~11 sec should be ok ;) time.sleep(11)

http://hickerspace.org/wiki/Microprinting

This code pulled tweets every 11 seconds and printed


them on a receipt printer. It all seemed to be very efficient.
However I did not have the programming knowledge to get
python working. I began requesting assistance.

Advice from geniuses


Efficiency isnt really necessary - just a method that you can get to
work ;)

If you are more familair with python then go with that.

Nick
- Show quoted text –
- be wary of the 9 pin to 25 pin - it might be fine but of the wrong
variety in which case no serial gets through to your printer and
you
don't know which part is faulty.

have you done a Power On Self Test on the printer? normally you
hold
down LF, switch on the power and it'll print out a self test (so you
can confirm that the print head etc is working).

re. python code my github project should point you in the right
direction:
https://github.com/ianozsvald/SocialMicroprinter

i'd say (in order of importance):


* confirm that the printer does a self test and prints ok (without a
serial lead)
* confirm that you can use a serial program (e.g. HyperTerm,
CoolTerm)
to talk to the printer
* test that pySerial (or serial driver for whatever language you
want
to use) works
* add twitter on top

don't jump the stages else you won't know which parts of the
puzzle
are dead. getting the right serial lead combo (and serial settings
e.g. 9600 8N1, 19200 8N1 etc) is key to the whole puzzle.

re. buildbrighton - i'm the only python programmer and i hardly


attend
(and for the next month there's no way - i'm under several big
deadlines with conference talks/tutorials to write! mongo busy!).
i'd
really suggest the London Hackerspace, they're lovely and will be
happy to offer some guidance if you just rock up and ask
I also visited the London Hackerspace on Tuesday 17th
May
The London Hackspace is a non-profit, community-run hacker space in
central London. We provide infrastructure for our members to make and learn
things.
london.hackspace.org.uk/

It was a really great communal space with some great


people, sharing great ideas and awesome tools. However
this was there open evening and it felt more for socialising
then coding. I returned still non the wiser. I decided to go
back to using processing, the language I was a bit more
experienced in.

Gregzek, the Wimbledon college technician helped me to


connect a processing sketch that pulled tweets to arduino.
By sending it down the serial monitor. This was successful
and we had our first tweet printed on receipt. IT was
based on sketches that I had found whilst researching
twitter based processing environments.

Conclusion
Getting the receipt printers working caused the most
concern during the creative process. I have learnt not to
try and connect ancient analogue technology. However it
has also been the most rewarding outcome and will be the
core aspect of the emotional stock market.

Many Thanks to Archie Sinclair, Gregzek, Tinker Nick, Ian


Oszvald, Ben o Steen and the London Hackerpsace for helping me
all out to an incredible degree.
Receipt printer bibliography
Arduino forum
http://www.arduino.cc/

http://arduino.cc/blog/category/hacks/urban-hacks/page/2/
(the twitter typewriter)

http://www.flipbit.co.uk/micro-printer.html (rss microprinter)

Models – CBM-231 (used by Tom)


CBM233
http://little-scale.blogspot.com/2007/11/arduino-printer-
how.html

The core arduino sketch by Roo-


http://rooreynolds.com/2009/02/01/microprinter/

guide by the excellent Ian Oszvald


http://ianozsvald.com/2010/11/06/building-a-social-
microprinter/

Another online guide –


http://adamendicott.com/blog/2009/mar/22/my-
microprinter/

The Wikihow page


http://microprinter.pbworks.com/w/page/20867146/FrontP
age

The German python code


http://hickerspace.org/wiki/Microprinting

Вам также может понравиться