Monday, December 29, 2008

Up and running on the TouchShield Stealth and Slide in 1 minute

It's been a long past few days for me and Matt, but I think we've finally figured it out (special thanks to Omar, Mark, T, and the guys at AVR for all the help). As it turns out, the avr gcc version packaged with the Arduino IDE actually isn't patched up to date, so it generates the wrong binary/hex file on the Mac and Vista when it tries to compile programs for the TouchShield Slide (that's because the Slide has a bigger processor than the Stealth, so it uses different AVR compile-time settings). The funny thing is that it went completely undetected for the past few weeks because Matt and I wrote most of the programs on Windows, but last week I got a new Macbook, and Matt put Vista on his laptop, and we discovered the problem almost at the same time.

I've wrapped up all of the code into one place - a patched version of the Arduino IDE (based on the most recent version), that compiles code properly on Macs and newer Windows machines. Thanks to Omar, who helped me wrap everything into an actual installer for Mac and Windows, since there are so many different gcc files it has to manage.

So that means that from now on, no one should ever have to use the up and running in 5 minutes post any more, because I've already included all of the cores and files into the installer (I'm going to keep the post up, but Matt's going to put a comment up that it's out of date).

In the meantime, Mark has volunteered to take over the SubProcessing library on the Stealth and the Slide, and is cleaning up all of the graphics functions. He's an insanely good programmer, and has coded 10,000's of lines of C and assembly in previous projects! We met the other day in New Haven, and he literally blew me away with some of the code he's written for the TouchShield Slide (when he sends it over, I'll throw it up on the App Store).

From now on, just grab the installer package to use the
TouchShield Stealth and Slide on Mac and Windows.

Make sure you remove any other copies of the Arduino IDE on your system just in case.




Coding:
Launch the Arduino from the Applications folder (OS X) or the Start Menu (Windows).

Selecting the Slide:
Select Tools -> Boards -> TouchShield Slide

Write some code:

Then touch the programming button on Slide before uploading code to it.

Click Upload in Arduino.

Programming Arduino,
Select Tools -> Boards -> Arduino Diecimila

Write some code:

Click Upload in Arduino.

Chris

48 comments:

Matt said...

Ha ha ha. Ok, so did you intentionally do this just so you could claim the speed award. I write a 5 minute version, and you have to come along and write it up as a 1 minute version. Ha. ... get ready for the up and running in 30 seconds guide :)

Justin said...

Hell yeah!

I'll be trying this package out on my mac this afternoon. (woo! For a working line function and a refresh rate that works).

And since I'm one of your more "persistent" customers here is the rest of my list of demands/ideas (muahahaha):
-Post dimensions L x W in the "shop" of the tsshield slide. People like to plan enclosures and stuff before buying.
-Tsshield slide sold by itself.
-Fix the descriptions on the stealth. Right now it looks like it will only hold and display 128 x 128 bmps. Is this true?
-Is there an image uploader that will upload larger bmps to the slide?
-A harness that allows remote mounting of the touchshiled off the arduino, and allows you to reuse the 5v and Gnd connections for other things.

Matt said...

Hey Justin, how's it going? Good call about the dimensions... as soon as I get home I'll measure it with a ruler and throw it up.

I've been fantasizing about building some sort of case out of Ponoko parts... what do you think? I even built some files in illustrator, but couldn't get them to upload...

The stealth will hold and display about 60 bitmaps that are 128x128 pixels, yep. Chris and I are building the slide's image uploader as we speak, which is really the only reason it's not "officially" launched yet (because I'd really like to sell it when everything works on it, you know?). Anyway, I got a lot of emails about it and seems like some guys didn't care about images yet (like Mark), so I just added it as a widescreen option on the shop. But if anyone else wants one that doesn't have images working yet, just let me know... inthebitz at gmail :)

Justin said...

Oh, so it will hold <60 320 X 240 bitmaps? Something like 15 maybe?

Would it also be possible to upload 200 x 200 bitmaps or some other size?

combatdave said...

Great news! I'll give this a go in the next couple of days. Now all you need is a way to upload images to the touchshield from OSX which doesn't involve this "ruby" magic! ;)

Chris said...

Justin,

Yup, Matt had some good suggestions about the clipping large images cleanly, so it doesn't matter what size bitmap maps are drawn on the screen.

Also a nice feature that I was just testing is if the bitmap isn't found in flash, then it will display an image placeholder, kind of like some web browsers do.

Anyways, thanks for the suggestions... now back to coding!

Chris

Justin said...

Thanks for all the replies.

I tried the new package and I'm still getting the weird line transposition error. Is the line function fixed?

When compiling/uploading I get the following:

Connecting to programmer: .
Found programmer: Id = "AVRBOOT"; type = S
Software Version = 0.7; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=256 bytes.

Programmer supports the following devices:
Device code: 0x74


Is that version 0.7 correct.

BTW as always I am running OS X 10.4x on an intel macbook.

Justin said...

Sorry/Correction:

line() with stroke() works, but lcd_line() still does funny things.

Mike Gionfriddo said...

This is great Chris! It works on my windows vista machine. It took me 3 minutes though :o)

Jim Lamiell said...

Hello,

Just bought a TouchShield Stealth and noticed problems with the Mac OSX and the Up and Running in 5 minutes tutorial. Saw that you now have an installer available for those of us who use Macs, but unfortunately I just tried to use the Stealth with a Diecimila and for some reason it still doesn't work in Arduino (v12). I get an error when I try to upload that says:

avrdude: stk500_getsync(): not in sync: resp=0xbf
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0xdf

Not familiar with this stuff... Any help with this would be appreciated.

Chris said...

Jim,

Make sure you remove any other copies of the Arduino IDE on your system.

Launch the Arduino from the Applications folder (OS X) or Start Menu (Windows).

Programming Stealth,
Select Tools -> Boards -> TouchShield Stealth

Then hit the programming button on Stealth before uploading code to it.

Click Upload.

Programming Arduino,
Select Tools -> Boards -> Arduino Diecimila

Click Upload.

Hope that helps!

Chris

combatdave said...

I'm using gettouch() on the touchshield stealth, which gets me the x/y position fine, but is there any way to check if there is something touching the screen? I was hoping gettouch() would return true/false, but it doesn't...

Also, attempting to use Serial.available() on the touchshield gives this error:

undefined reference to `HardwareSerial::available()'

Which is a problem, because if I attempt to just do a Serial.read(), the program hangs waiting for some serial data... Any advice?

Cheers

Filmo said...

I'm having some problems getting TouchSheild Slide to work. I've downloaded the latest IDE for Mac OSX today.

When switching to Touchshield Slide, I get a compile error with EEPROM. (which I'm ignoring ??)

I attempted to use the IDE to upload this basic code to the Slide shield to test it out:

void setup()
{
background(0,0,0); //this paints the whole background black
stroke(0,0,255); //the outline of the next shape I draw will be blue
fill(0,0,255); //the inside fill of the next shape I draw will be blue
}

void loop()
{
gettouch(); //find out where a finger is touching
ellipse(mouseX, mouseY, 3, 3); // draw an ellipse(x, y, width, height)
}

It compiles fine, but when I attempt to upload it to the Slide, I get the following error:

Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding

and a referral to the Arduino site for possible solutions


I can upload sketches to the Arduino just fine and run them. No love with the Slide.

Chris said...

Filmo,

Make sure you're pressing the program button, located near the USB on the Slide. You do this before clicking upload.

In case it helps others, I just updated this post with a short description of the coding steps.

Chris

bs_one said...

Hi!

I got my TouchShield Slide some Days ago and already uploaded some code succsessfully onto it. Everything worked fine until I tried to interact with the Arduino. When I compile my code I get an error saying I should declare "Serial" from: "Serial.begin(9600);" but in every programm I saw using the TouchShield I couldnt find the answer. So I´m asking you for help I really have no idea why its not working...
Here´s my code that should run on the ToushShield(I know it doesnt do much, but I just wanted to test it out):

void setup(void){
Serial.begin(9600); //the error producing line
Serial.print(1);
}
void loop(void){
}

And heres the error I get:

In function 'void setup()':
error: 'Serial' was not declared in this scope

I also tried compiling it with the TouchShield Stealth board and I didnt get this error there, so I´m asking myself: Is there already a way to connect to the Arduino with a TouchShield Slide?
Ohh and yeah: My OS is Windows XP SP 2 and I´m using Arduino 12

I´m sorry for my bad english but it isnt my first language.

bs_one

Chris said...

bs_one,

You're right! Actually on the Slide, the serial commands are named differently because of an old gcc compiler bug that mislocated c++ class sections.

Matt and I are going to update them to the more familiar Serial.begin(), Serial.print() in the next release.

In the mean time, you can still use the different naming...

beginSerial(9600);

and

uint8_t data = 'U';
serialWrite(data);

and

if (serialAvailable())
{
data = serialRead();
}


Chris

bs_one said...

thanks for your quick answer but now I got a different Problem. When I try to use the code on the Arduino it just doesnt work.
I´m a total noob with the TouchShield so I´m asking you for help again ^^
the code on running on the Arduino is:
#include &ltAFSoftSerial.h&gt

#define RXPIN 3
#define TXPIN 2

AFSoftSerial mySerial = AFSoftSerial(RXPIN,TXPIN);

int ledPin = 8;
char status = 0; //I also tried it with int

void setup(){
mySerial.begin(9600);
pinMode(ledPin,OUTPUT);
}

void loop(){
status = myserial.read();
if(status == 'g'){
digitalWrite(ledPin,HIGH);
}
}

and on the TouchShield is running this code:

uint8_t status = 'g';

void setup(void){
beginSerial(9600);
}

void loop(void){
serialWrite(status);
}

so this is my problem right now and I really hope you could help me again :)
Thanks in advance :)

bs_one

Chris said...

bs_one,

You've got it really close.

Try updating your Arduino loop to use the mySerial.available() like this,

void loop(){

if (mySerial.available())
{
status = myserial.read();
}

if(status == 'g'){
digitalWrite(ledPin,HIGH);
}
}

If that doesn't work, you can also use the Arduino's Hardware serial to print out the incoming bytes to the PC.

Chris

Matt said...

Geez come on... I was just typing up a respones to and I came here and you already typed one up... slow down so i can get "first post" occasionally, or something like that.

Hey bs_one - I was going to suggest trying to get just a simple serial send working first, like the one in Chris's code snippet.... I sometimes just send over a 'U' from the Arduino and make sure I can read it in on the TouchShield first. The U is a good character because it's binary 01010101, so you can rule out any hardware serial problems with the Arduino device (unlikely, but just in case, you know?)

Bill said...

Thanks to all for these excellent Touchshields and the supporting software!
You guys need to post an organizational chart so I can give accolades to the correct people.

I am not a hardware or software guy; all of this is new to me however I am beginning to develop a UI for my Quadriplegic Wife.

Below is a link to a crappy cell phone pic of my TS Stealth running a modified version of BitDJ along with a quick and dirty XBee PCB I whipped up. I need to design and etch another that rotates the Xbee radio 90 degrees clockwise.

http://www.billblose.com/images/touch_1.jpg

Thanks again,
-Bill

mikem said...

Hi Matt,
I got a TouchShield Stealth. Ive installed the Windows installer on my XP SP2. But when I start the arduino prog, nothing happens for about 10 minutes before the Arduino window appears. When it does appear, it all seems to work OK: I can type in the edit area, and the menus all work until I click on the Tools menu, when it hangs again for 10 minutes. Anyone else seen that? Any ideas?

I can paste code in and (after much waiting select the Tools->Board and Tools->Serial Port and get code compiled and downloaded, but it just keeps hanging for 10 mins at a time.

Fortunately, Ive been able to copy the cores etc from Windows to my Linux system, and build happily there.

bs_one said...

I havent got the chance to thank you till now( school and so on). But I really thank you very much for the help!!!
Everything works fine now and I got it working alright. So again thanks for your support!

bs_one

Michele Mostarda said...

Dear all,
I bought an TouchShield Slide (shipping date December 11, 2008) and there is no way to put it working...

I tried with the basic program void setup()
{
background(0,0,0);
stroke(0,0,255);
fill(0,0,255);
}

void loop()
{
gettouch();
ellipse(mouseX, mouseY, 3, 3);
}

and other variants of the background and the stroke hoping to see any color on the screen, but nothing! I'm sure to follow the right procedure: I press the programming button on the TouchShield, the red led turns on, then I upload the program, the red led turns off and the programmer prints the following message

Binary sketch size: 24380 bytes (of a 258048 byte maximum)

Connecting to programmer: .
Found programmer: Id = "AVRBOOT"; type = S
Software Version = 0.7; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=256 bytes.

Programmer supports the following devices:
Device code: 0x74
but nothing append when I interact with the shield. May be there is a firmware issue? Or shall I think it is an hardware failure?
Thanks
Mic

Michele Mostarda said...

PS: I did several tests both with Mac OSX 10.5.6 and Windows XP.

Matt said...

hi michele, oh no - i can't believe i didn't see this comment until earlier!!! my address is inthebitz at gmail. just drop me a line and i'll see what might be up. chris spent a whole bunch of time figuring out that mac's don't like to compile avr code properly, and so he patched together a version of the avr compiler that works properly and put it over on the app store. but please please email me anyway and i'll figure it out...

Matt said...

@bs_one ... thanks! :) if you build something fun, please send me pictures and i'll put 'em in my little flickr scrap book...

Sasha said...

Are any other Slide owners able to reproduce a 'bug' in the rect drawing function? I saw a mention of rects drawn beyond the screen bounds not filling correctly. I have noticed myself that a rect whose widthxheight exceeds approximately 150x150 will not fill as well. Would any other Slide users try and draw a filled rect with 'rect(20,20,200,200)' and see if mine is anomalous?

Thanks,

S.G.

Mike Gionfriddo said...

Hi Sasha, I just downloaded the new arduino IDE http://antipastohw.blogspot.com/2009/01/up-and-running-on-illuminato-in-5.html and tested the fill and rect... they both work. hmm, do you know what version of the ide you're using?

bs_one said...

HI its me again ^^
I´m now trying to build something like the mini portable arduino laptop you did but without the hardware keybpoard. I´m trying to put it on the TouchShield Slide. But my problem is writing the letters on the touchshield. I tried the "text(char,x,y);" and the "lcd_putc(unsigned char,x,y,foreground,background);" function, but non of both worked...
So I´m asking you again for help. How can I draw letters in my TouchShield Slide?
When I´m done I´l be sure to send you pictures and maybe I´m going to film it ;)

greetings bs_onw

bs_one said...

Forget my other post I found what I was looking for. Just had to search a bit in the core ;)
Thanks anyway. When I´m done I will send you some pictures ;)

greetings bs_one

Radek said...

Not in 1 minute, but few days!

I tried everything, but allways if I switch IDE Tools->Board to TS Slide can see
This nice vogon poetry...
Any ideas?
Thx
Radek

HW/SW: NB Acer Gemstone; Vista Ultimate SP1; Duemilanove+TS Slide; IDE Arduino-0012LW0.8

In file included from EEPROM.cpp:24:
c:/program files/arduino-0012lw/hardware/tools/avr/lib/gcc/../../avr/include/avr
/eeprom.h: In function 'void eeprom_read_block(void*, const void*, size_t)':
c:/program files/arduino-0012lw/hardware/tools/avr/lib/gcc/../../avr/include/avr
/eeprom.h:290: error: ISO C++ forbids incrementing a pointer of type 'void*'
c:/program files/arduino-0012lw/hardware/tools/avr/lib/gcc/../../avr/include/avr
/eeprom.h:290: error: ISO C++ forbids incrementing a pointer of type 'const void
*'
c:/program files/arduino-0012lw/hardware/tools/avr/lib/gcc/../../avr/include/avr
/eeprom.h:290: error: invalid conversion from 'const void*' to 'const uint8_t*'
c:/program files/arduino-0012lw/hardware/tools/avr/lib/gcc/../../avr/include/avr
/eeprom.h:290: error: initializing argument 1 of 'uint8_t eeprom_read_byte(con
st uint8_t*)'
c:/program files/arduino-0012lw/hardware/tools/avr/lib/gcc/../../avr/include/avr
/eeprom.h: In function 'void eeprom_write_block(const void*, void*, size_t)':
c:/program files/arduino-0012lw/hardware/tools/avr/lib/gcc/../../avr/include/avr
/eeprom.h:398: error: ISO C++ forbids incrementing a pointer of type 'void*'
c:/program files/arduino-0012lw/hardware/tools/avr/lib/gcc/../../avr/include/avr
/eeprom.h:398: error: ISO C++ forbids incrementing a pointer of type 'const void
*'
c:/program files/arduino-0012lw/hardware/tools/avr/lib/gcc/../../avr/include/avr
/eeprom.h:398: error: invalid conversion from 'void*' to 'uint8_t*'
c:/program files/arduino-0012lw/hardware/tools/avr/lib/gcc/../../avr/include/avr
/eeprom.h:398: error: initializing argument 1 of 'void eeprom_write_byte(uint8
_t*, uint8_t)'

Nuno Godinho said...

I get the same problem. When I switch the board to Slide in Arduino IDE I get that ugly error. What now?

Radek said...

@Nuno

Just ignore the errors and try upload the script to the TouchShield. If you see "Binary sketch size: xxx bytes", you are won.

Nick said...

Warning: newbie. I have everything up and running and I've even uploaded a few programs I've seen and they are really interesting, but I am wondering this: if you can upload programs to the touchshield stealth (which I have) and to the arduino, when do you choose to have the arduino do a command and when do you choose the touchshield? How do you direct whether the program goes to one or the other?

Nick said...

Nevermind, I found this:
http://antipastohw.blogspot.com/2008/12/three-easy-pieces-3-different-ways-to.html

Matt said...

@nick - i just got settled in to my new apartment, so i'm sorry it took a couple days to reply... ha - that's why chris and i wrote up that blog post :) the basic gist was supposed to be that there are different ways to program it based on how complex or advanced you want to go (red pill vs. blue pill maybe kind of thing...)

ps - i think this is a good example of how badly i need to work on organizing all the posts on the blog... it's probably really hard to find :(

oy said...
This comment has been removed by a blog administrator.
maik said...

I tried uploading a simple sketch to the TouchShield Slice for the first time. I am using Arduino-12LW on Mac OS X 10.5 and an Arduino Diecimila. I have put the shield on the Arduino, connected them via USB to a MacBook Pro and chose TouchShield Slice from the Board menu. The sketch compiles successfully, but when I try to upload it to the board, I get the following message:

Connecting to programmer: .
Found programmer: Id = "‡"; type = ‡
Software Version =

Mike said...

I just got my Slide and am having trouble installing the IDE. I'm running vista with sp2 and every time I try to launch the program I get an error message that the program has stopped working and is trying to recover. I've reinstalled several times, same result. Any suggestions??

Chris said...

@maik

There is an updated IDE package. Here is the download link for Mac OS X:

http://www.liquidware.com/apps/show/49

Justin said...

Chris does this include the hershey fonts?

If not how do I add that capability to the newest touchshield slide core?

Stephen said...

Hey so I just got a TouchSheild Stealth and am sort of stuck on setting up the serial communications channel between the Arduino and the TouchShield. After searching a bit on several different websites, I decided to follow the very thorough tutorial that I found here:

http://www.liquidware.com/apps/show/26

All was well until I reached step 4. I was able to get the TouchShield into canvas mode, but then I ran into problems with the Sub-Processing program. First, the tutorial specifically states that I should select "Arduino" from the Tools->Boards menu, but I don't have this option. I think maybe because: 1) I am running the latest version of Arduino (0015) and the tutorial runs through 0012, and 2) I have a Duemilanove with ATmega168, and the tutorial is for the Diecimilia. I choose the Board I normally use, the Arduino Diecimilia or Duemilanove w/ ATmega168, and I get this error upon compiling:

In file included from C:\Program Files\arduino-0015\hardware\cores\arduino/WProgram.h:13,


C:\Program Files\arduino-0015\hardware\cores\arduino/HardwareSerial.h:25:19: error: Print.h: No such file or directory


In file included from C:\Program Files\arduino-0015\hardware\cores\arduino/WProgram.h:13,

I found a Print.h file and tried adding it to the directory from which it said it was missing, but then I start getting more errors. Please help if you can!!! I am running Windows XP SP3.

Chris said...

@Justin,
Only some Illuminato core updates were made on 5/27/09.

@Stephen,
It's much simpler. Here is the pin mapping:

TouchShield Rx = Arduino pin 2
TouchShield Tx = Arduino pin 3

Use hardware serial (Serial.begin) on the Slide.

Use software serial (AFSoftSerial library) on the Arduino.

If you want a slightly more complicated (reliable) serial *packet* example, then check out the InputShield Slide Forwarder App:
http://www.liquidware.com/apps/show/44

The above app uses a SLIP style packet framing to send messages from the Arduino to the Slide.

Chris said...

@Stephen,

Make sure you're using the Antipasto Arduino IDE. The installer package always contains the latest Arduino/TouchShield core updates.

It's also got a few more time savers and libraries packed into it.

Antipasto Arduino IDE:
http://www.liquidware.com/wikipages/1

steve said...

I've got a illuminato and a Slide. Starting from the "LED button" demo, I managed to get a serial interface working between the two but it was unreliable at 9600 baud. Seemed to work at 4800 baud or 14400 though...

Next I switched to using "SoftSerial" from cores/illuminato instead of SoftwareSerial. I did this to get the available() method so I could avoid blocking on the illuminato. (I briefly tried to get NewSoftSerial working, but pins_illuminato.h seemed to be missing lots of stuff it wanted.

Question 1) what's currently the best serial library to be using on the illuminato?

Question 2) Any thoughts why (just?) 9600 baud would be funky?

I tried to setup things using the beginCanvas() method, but functions like ellipse() etc don't seem to be declared on the Illuminato. I've searched around through the code delivered with the IDE and found where the SubPGrapics commands are being read from the serial on the Slide (in SubPGraphics.cpp) but I don't see where ellipse() would be defined on the illuminato to generate a serial command.

Question 3) Am I missing some header or library code that I need to make the SubPGraphics approach work?

svenofix said...

Hi,

I recently got the Touchshield Slide and Arduino Dueminalove. Following the instructions on how to upload code to the slide, I get stuck when I have to press the programming button on the slide. In other words, nothing happens. The Slide doesn't go into "wait" or "standby" mode, nor do any red lights turn on. I tried uploading code just in case, but get this:

Connecting to programmer: .
Found programmer: Id = "lŒÛl#"; type = â
Software Version = b. ; Hardware Version = <.b
avrdude: error: buffered memory access not supported. Maybe it isn't
a butterfly/AVR109 but a AVR910 device?

So I am wondering, am I doing something wrong or did I miss something? Or could the Slide be defect? I've also tried it with the Diecimila, coming up with the same results.

Thanks,

Sven

modeltrainsfreak said...

it works now but I keep getting errors. Like so

" In function 'void loop()':
error: 'text' was not declared in this scope" and the code in my program is "int background, stroke, fill;
/////////////////////////////////////////
//setup
/////////////////////////////////////////
void setup() {
background = (0,0,0);
stroke = (255,255,255);
fill = (0,0,0);
}

/////////////////////////////////////////
//loop
/////////////////////////////////////////
void loop() {
text((int)321,5,5); //print the integer 321 at pixel location 5,5
text((double)122.345,50,50); //print the double 122.345 at pixel location 50,50
text((long)7654321,100,100); //print the long 7654321 at pixel location 100,100
text((float)4321.456,150,150); //print the float 4321.456 at pixel location 150,150
text("no pony!",200,200); //print the character string “no pony!” at pixel location 200,200
}"

Mike Gionfriddo said...

error: 'text' was not declared in this scope" and the code in my program is "int background, stroke, fill;

I wonder if the Slide is selected in the boards menu? or maybe the ide isn't the most recent...
http://www.illuminatolabs.com/IlluminatoDownloads.htm