PDA

View Full Version : interfacing sd card and 2x16 lcd to teensy 2.0



erabegins
01-03-2013, 09:21 PM
I'm a student, not technically sound with electronics components and connections and working on a project.
I wanted to know the way or steps to connect LCD display & sd card to a Teensy 2.0
Since flash size of teensy is less i want to add storage space to put heavy programs onto it. And want to present the status on the display.
Kindly help me out with the connections and let me know if its even possible to add these 2 on one teensy.

PaulStoffregen
01-04-2013, 02:58 AM
I'm a student, not technically sound with electronics components and connections and working on a project.
I wanted to know the way or steps to connect LCD display & sd card to a Teensy 2.0


There are many possible ways, but usually the easiest way for a SD card is using this adaptor:

http://www.pjrc.com/store/sd_adaptor.html

For displays, you have many choices. The most common is a character-mode display which needs 6 signals. This page has details:

http://www.pjrc.com/teensy/td_libs_LiquidCrystal.html



Since flash size of teensy is less i want to add storage space to put heavy programs onto it.


On Teensy 2.0, the SD card can only be used for data, not program code. It's a hardware limitation, because the chip can only execute program instructions from its flash memory, which is separate from RAM (that can receive data from the SD card).

If you need to write a large program that won't fit into the 31.5K of available flash, you'll need the Teensy++ 2.0 or Teensy 3.0.

Teensy 3.0 can execute code from RAM. However, compiling code to run from RAM, loaded dynamically from the SD card, it a fairly advanced project. I would not recommend attempting it until you're much more familiar with the compiler. You'll need to use special compiling settings which aren't supported by Arduino. It is technically possible, but also pretty far off the well-worn path of normal flash-based development, so you'll have a number of technical challenges to overcome before it works.

erabegins
01-04-2013, 11:42 AM
I ordered 3 teensy for the project, the other 2 in case 1 gets damaged.
I have spent a lot of money and I dont think pjrc allows replacement or refund.
In that case I need a work around so as to continue using the same and complete the project by the end of month.
Kindly guide me if there is some way to expand the flash memory of teensy 2.0 or any other possible way to run code written in Java and C using arduino installer. Size of the code written has gone above 2MB as it contains coding for interface and uses other java libraries for different functions.
I wanted teensy just for "plug and play" capability and i thought program can be loaded by intefacing teensy with large size sd cards. :( :(

erabegins
01-04-2013, 11:59 AM
I ordered 3 teensy for the project, the other 2 in case 1 gets damaged.
I have spent a lot of money and I dont think pjrc allows replacement or refund.
In that case I need a work around so as to continue using the same and complete the project by the end of month.
Kindly guide me if there is some way to expand the flash memory of teensy 2.0 or any other possible way to run code written in Java and C using arduino installer. Size of the code written has gone above 2MB as it contains coding for interface and uses other java libraries for different functions.
I wanted teensy just for "plug and play" capability and i thought program can be loaded by intefacing teensy with large size sd cards.








There are many possible ways, but usually the easiest way for a SD card is using this adaptor:

http://www.pjrc.com/store/sd_adaptor.html

For displays, you have many choices. The most common is a character-mode display which needs 6 signals. This page has details:

http://www.pjrc.com/teensy/td_libs_LiquidCrystal.html



On Teensy 2.0, the SD card can only be used for data, not program code. It's a hardware limitation, because the chip can only execute program instructions from its flash memory, which is separate from RAM (that can receive data from the SD card).

If you need to write a large program that won't fit into the 31.5K of available flash, you'll need the Teensy++ 2.0 or Teensy 3.0.

Teensy 3.0 can execute code from RAM. However, compiling code to run from RAM, loaded dynamically from the SD card, it a fairly advanced project. I would not recommend attempting it until you're much more familiar with the compiler. You'll need to use special compiling settings which aren't supported by Arduino. It is technically possible, but also pretty far off the well-worn path of normal flash-based development, so you'll have a number of technical challenges to overcome before it works.

ploveday
01-04-2013, 12:22 PM
If you're dealing with code sizes of 2MB, and trying to run Java, I think you're going to need a different hardware solution.

What is your application? Have you considered something like a Raspberry Pi?

- Peter

PaulStoffregen
01-04-2013, 12:26 PM
Size of the code written has gone above 2MB as it contains coding for interface and uses other java libraries for different functions.

I want to help you, but so far I know virtually nothing about what you're doing, or trying to accomplish?

Are you using the latest "beta 10" version?

http://forum.pjrc.com/threads/14535-Teensy-3-0-Beta10-Software

Are you running the Arduino IDE, or using the makefile to compile your code? Are you running it on Windows, Mac or Linux?

PaulStoffregen
01-04-2013, 12:34 PM
Reading this again, I'm guessing (really, just a guess) you're writing software on a PC or Mac with some development tool that produces code intended to run on that platform. Maybe you're expecting to copy the binary code to a SD card and have Teensy somehow use it?

The only practical way to produce code that runs on Teensy is using the beta 10 software (or earlier versions). If you're pursuing some other approach, now is the time to get onto a path that actually will work and let you meet your approaching January deadline.

erabegins
01-04-2013, 08:14 PM
See i'll try explaining my idea.
What i want to do is, write a code making use of java and c and combine it using arduino ide and transfer the same on the teensy 2.0.
This code will be done to run the application on both window and linux intelligently and perform given tasks.
Now since the teensy flash memory is less, is there a way such that flashed teensy performs the function and take the large code from sd card mounted on it ???
and display the same progress(like start/in progress/ stop/done) through the lcd interfaced ???
Teensy 2.0 has limited number of pins and I want to mount sd card and interface lcd too.
Please Please Please help me because what ever things i have given in my report, I cannot change them now. Anyhow i'll have to go with the same and complete it by the end of the month.






Reading this again, I'm guessing (really, just a guess) you're writing software on a PC or Mac with some development tool that produces code intended to run on that platform. Maybe you're expecting to copy the binary code to a SD card and have Teensy somehow use it?

The only practical way to produce code that runs on Teensy is using the beta 10 software (or earlier versions). If you're pursuing some other approach, now is the time to get onto a path that actually will work and let you meet your approaching January deadline.

erabegins
01-04-2013, 08:23 PM
what you have guessed is somehow somewhat exactly correct :P
Please anyhow help me in reaching mu goals. I cannot change anything now and carry on with the same.

Reading this again, I'm guessing (really, just a guess) you're writing software on a PC or Mac with some development tool that produces code intended to run on that platform. Maybe you're expecting to copy the binary code to a SD card and have Teensy somehow use it?

erabegins
01-04-2013, 08:25 PM
I have posted what i'm trying to achieve. Please don't ask me to change any hardware or do anything. I beg you.
I have limited TIME/RESOURCES/ MONEY which i have already spent. :(


If you're dealing with code sizes of 2MB, and trying to run Java, I think you're going to need a different hardware solution.

What is your application? Have you considered something like a Raspberry Pi?

- Peter

Pete
01-04-2013, 08:36 PM
A program complied to run on your PC is not going to run on the Teensy. You're likely going to need at least 2 different programs, the teensy program that communicates with the PC & output to the LCD screen, and the other application for the PC software. Depending on the context, I would imagine you're probably going to need two separate applications for the Windows and Linux PC versions.

PaulStoffregen
01-04-2013, 10:27 PM
Pete is correct, code compiled to run on your PC is not going to work on Teensy.

You must install the Arduino software and the Teensyduino add-on. Download Arduino 1.0.2 from www.arduino.cc. Extract the file, and remember the location on your computer.

The Teensyduino installer does not yet support 1.0.3, so please download 1.0.2. Then download the Teensyduino installer, from this page:

http://www.pjrc.com/teensy/td_download.html

When you run the installer, you'll need to select the location where you extracted the Arduino software. The installer will add the Teensy-specific files to Arduino.

Then run Arduino, select Teensy 2.0 from the Tools > Boards menu. To do an initial test, from the File > Examples > 01.Basics > Blink menu, open the blink example. Edit the code for the correct pin number (as described in the comments), and then click the "Upload" button. The code should compile and the Teensy Loader window should appear. Plug in your Teensy and press the pushbutton. It should change to the new blink program. You can change the delays and upload again to see your code is running properly.

This tutorial page shows the steps:

http://www.pjrc.com/teensy/tutorial.html

Please, with your deadline so close, do not waste another day programming in the wrong environment. You must install the correct software and begin writing code that will actually run on Teensy.

When you have Arduino up and running, the LCD stuff should make more sense.

erabegins
01-05-2013, 02:03 AM
Maybe i haven't made my point clear. I'll give one more try in explaining.
I need to run a Java program on a computer through teensy.
My initial approach was to store java file in teensy memory or say flash memory and run it on the machine it is connected to via arduino code.
The size of tha java file is exceeding. Hence i need either expansion of flash memory of teensy or sd card mounted should act as a RAM.
Java program will contain code for window as well as linux and when it will run through teensy as soon it is plugged, it will determine the OS and do the other functions.
So can you guide me how to go about this.
Thank you for the patience and support.





Pete is correct, code compiled to run on your PC is not going to work on Teensy.

You must install the Arduino software and the Teensyduino add-on. Download Arduino 1.0.2 from www.arduino.cc. Extract the file, and remember the location on your computer.

The Teensyduino installer does not yet support 1.0.3, so please download 1.0.2. Then download the Teensyduino installer, from this page:

http://www.pjrc.com/teensy/td_download.html

When you run the installer, you'll need to select the location where you extracted the Arduino software. The installer will add the Teensy-specific files to Arduino.

Then run Arduino, select Teensy 2.0 from the Tools > Boards menu. To do an initial test, from the File > Examples > 01.Basics > Blink menu, open the blink example. Edit the code for the correct pin number (as described in the comments), and then click the "Upload" button. The code should compile and the Teensy Loader window should appear. Plug in your Teensy and press the pushbutton. It should change to the new blink program. You can change the delays and upload again to see your code is running properly.

This tutorial page shows the steps:

http://www.pjrc.com/teensy/tutorial.html

Please, with your deadline so close, do not waste another day programming in the wrong environment. You must install the correct software and begin writing code that will actually run on Teensy.

When you have Arduino up and running, the LCD stuff should make more sense.

PaulStoffregen
01-05-2013, 02:22 AM
I can try to help. The meaning of "run a Java program on a computer through teensy" is not clear to me. Please explain in more detail.

Regardless, you *MUST* install the Arduino software and Teensyduino add-on. Have you done that, and at least managed to load the LED blink example?

CheapB
01-05-2013, 04:21 AM
Is there a prize for guessing what OP is trying to do? :-)
This is my guess: He wants Teensy to act as a flashdrive + when the Teensy is inserted it will detect the host operating system and execute the appropriate executable (win or linux) hosted on the SD card..

PaulStoffregen
01-05-2013, 05:02 AM
LOL, yup, student projects are usually like this. If he wants useful help, he's going to have to give us more useful explanation and info.

erabegins
01-05-2013, 08:59 AM
Yes i have installed arduino n teensyduino add-on. Tried changing slow and fast bink codes. Tried keyboard emulation program with the same.
Till here i kno since the code size is less.
Now my coding that includes java, I'm trying to attach same with the keyboard emulation+ led blink program and a few more like displaying progress of the whole code on LCD written in arduino installed. This all is written and tranferred to Teensy like we did in emulation and blink setup.
But the size of this code has gone above 32KB.
SO what i want is, Mount SD card so that teensy runs code from sd card and uses it as storage at the same time.SD card can be used as storage of my code and teensy uses same code while execution.
All this progress, start of process till the end of process is diplayed on LCD like ( welcome/hello/start/in progress/stop/thanx/bye ) just to make it presentable.

Algorithm:
1) Plug-in the teensy(already burned with the code)mounted with sd card, into the target machine.
2) Teensy executes in a way that it determines OS automatically (this is the part of my coding that i have already done) so need not worry about this.
All i am looking for is-expanding flash memory size of teensy so that the written code fits and teensy runs it normally when it is plugged in.
3) Process is carried out and main breakpoints are displayed on LCD interfaced.

4) I'm done( help me now please) Cant explain enough.
Just help me now. ;)









I can try to help. The meaning of "run a Java program on a computer through teensy" is not clear to me. Please explain in more detail.

Regardless, you *MUST* install the Arduino software and Teensyduino add-on. Have you done that, and at least managed to load the LED blink example?

erabegins
01-05-2013, 09:07 AM
Exactly. u guessed it right.

Prize will be my appreciation and blessings to everyone who had helped me here. and very well in advance-""Thank you for all the help you have given me with my re-search work""
Will make my project open source so that other can build the same.





Is there a prize for guessing what OP is trying to do? :-)
This is my guess: He wants Teensy to act as a flashdrive + when the Teensy is inserted it will detect the host operating system and execute the appropriate executable (win or linux) hosted on the SD card..

ploveday
01-05-2013, 09:51 AM
If this is the case, how are you planning to run them on the host OS? Firstly, I suppose the host OS will need JRE installed to run the java code, but even then... in general operating systems are somewhat resistant to running random code from USB devices nowadays. Even windows' autorun stuff has been scaled back / removed in later versions.

So in a sense, you have two parts to this; firstly some means of behaving like a flash drive with some OS-detecting autorun system, and the second being something which said software interfaces to in order to display messages on an LCD?

There are lots of people here who can help, but if you could tell us some more details about what you're doing, beyond running code from SD, it would make this a lot easier. What is the application?

- Peter

PaulStoffregen
01-05-2013, 12:38 PM
Most likely you'll set Tools > USB Type to Disk(SD Card) + Keyboard. That makes the SD card available to the PC as a USB mass storage device. You'll probably use Keyboard.print() to send commands to the computer to cause it to use files stored on the SD card.

Teensyduino also has a USB Type called Disk(internal) + Keyboard. It works the same way, but uses the tiny amount of extra flash memory as the disk media. On Teensy 2.0, the flash is read-only. Teensyduino pre-loads the flash with your files. If you haven't provided any files, the disk is initialized with a readme file that gives you specific instructions. The readme is generated with pathnames specific to your PC, so please read that file for help.

Like any large project, the best approach is to break it into many smaller, easily manageable projects. You've already made the LED blink, so you're on the right path. This may be obvious, but to move forward, try making progress on these individual items.

1: Use the Keyboard.print() to send a command to your PC
2: Populate the internal disk with a tiny file.
3: Find a command that can access the disk.
4: Connect a LCD and use lcd.print() to make it display text
5: Connect the SD adaptor and use Disk(SD Card) instead of Disk(internal)

On item #1, you might take a look at Irongeek's website. http://www.irongeek.com/ He's published lots of examples of keyboard commands to do stuff. I believe he even wrote an Arduino library to automate some of the work. I haven't personally used it, so the best help I can give is directing you to his site.

Then again, you might find simply using Keyboard.print() is effective enough. Usually for student projects, the deadline is absolute, but partial success with a good explanation of how you might achieve the rest often passes. So I'd try doing those steps ASAP, so if time runs out, you'll at least have some stuff working that you can present.

erabegins
01-05-2013, 02:00 PM
How do you answer....I mean that was a really very nice explanation to everything. After a long something went into each other's head. :)
I'll make sure I try To connect with 'WHAT AN ANSWER!' :P
Thank You so much SIR.

This was a guidance on the software related query.
And now what i would like you to help me out with is the hardware part. I am not sound with electronics component and connections. Can you please tell me what to connect and how ?
SD Card Adapter that is given in the pjrc link http://www.pjrc.com/store/sd_adaptor.html I have seen.
Shipping will take some time in reaching here so I'll try to make it on my own.

Second is the LCD which I'm confused with. There are many options available on pjrc site but help me which one will be cheaper and best for my basic displaying purpose.

And if you can help me with the connections. Please tell me how to do it because number of pins on Teensy 2.0 is limited.
5 pins will be utilized by sd card adapter only...Then how and where should i connect LCD.












Most likely you'll set Tools > USB Type to Disk(SD Card) + Keyboard. That makes the SD card available to the PC as a USB mass storage device. You'll probably use Keyboard.print() to send commands to the computer to cause it to use files stored on the SD card.

Teensyduino also has a USB Type called Disk(internal) + Keyboard. It works the same way, but uses the tiny amount of extra flash memory as the disk media. On Teensy 2.0, the flash is read-only. Teensyduino pre-loads the flash with your files. If you haven't provided any files, the disk is initialized with a readme file that gives you specific instructions. The readme is generated with pathnames specific to your PC, so please read that file for help.

Like any large project, the best approach is to break it into many smaller, easily manageable projects. You've already made the LED blink, so you're on the right path. This may be obvious, but to move forward, try making progress on these individual items.

1: Use the Keyboard.print() to send a command to your PC
2: Populate the internal disk with a tiny file.
3: Find a command that can access the disk.
4: Connect a LCD and use lcd.print() to make it display text
5: Connect the SD adaptor and use Disk(SD Card) instead of Disk(internal)

On item #1, you might take a look at Irongeek's website. http://www.irongeek.com/ He's published lots of examples of keyboard commands to do stuff. I believe he even wrote an Arduino library to automate some of the work. I haven't personally used it, so the best help I can give is directing you to his site.

Then again, you might find simply using Keyboard.print() is effective enough. Usually for student projects, the deadline is absolute, but partial success with a good explanation of how you might achieve the rest often passes. So I'd try doing those steps ASAP, so if time runs out, you'll at least have some stuff working that you can present.

Magnethead494
01-05-2013, 10:51 PM
I use the PCD Nokia 8500 display but there are some from Adafruit much cheaper.

You should have used a teensy++, if you didn't. The extra pins make it easier to drive an LCD if you're going to have a very involved I/O stream. But that's just me.

erabegins
01-06-2013, 12:42 AM
can u please come up with connection schematic of the same. I mean SD Card and LCD interfaced on teensy 2.0
I cannot buy teensy++ due to bugdet and same is the case with high priced LCDs.
SO please suggest me which one to use and the way to interface.
Reply to this would be highly appreciated.



I use the PCD Nokia 8500 display but there are some from Adafruit much cheaper.

You should have used a teensy++, if you didn't. The extra pins make it easier to drive an LCD if you're going to have a very involved I/O stream. But that's just me.

PaulStoffregen
01-06-2013, 11:15 AM
Get this LCD. It requires only 6 signals, which can be any 6 digital pins.

https://www.adafruit.com/products/181

The SD card requires 4 specific digital pins. Teensy 2.0 has 25 digital pins, so plenty of pins are left unused if you need to connect more devices.

PaulStoffregen
01-06-2013, 01:50 PM
SD Card Adapter that is given in the pjrc link http://www.pjrc.com/store/sd_adaptor.html I have seen.
Shipping will take some time in reaching here so I'll try to make it on my own.


Be careful to properly convert 5 to 3.3 volts. The PJRC adaptor does this for you, using a MCP1700-3.3 voltage regulator and 74LCX125 buffer chip. The schematic is published here:

http://www.pjrc.com/teensy/sd_adaptor.html

If you apply 5 volts directly to a SD card, you'll almost certainly damage the card. SD cards run on 3.3 volts.

erabegins
01-06-2013, 03:06 PM
Sir i took help from a friend of mine, who i believed was good in electronics,for this LCD connection...But he said I wont be able to interface both SD card and this LCD together on teensy 2.0.
This is because LCD will be using 9 pins and SD card will use 5 pins..Is that true??
Can you please tell me which pin to connect where?
I'm sorry I'm sounding very demanding here...But you people are the only ones who i can ask help for that will work.
All 20 pins on teensy are not for input connections i suppose..
This is a full confusing thing for me as I'm not a electronics student.
So please let me know which pin to connect where on the teensy 2.0






Get this LCD. It requires only 6 signals, which can be any 6 digital pins.

https://www.adafruit.com/products/181

The SD card requires 4 specific digital pins. Teensy 2.0 has 25 digital pins, so plenty of pins are left unused if you need to connect more devices.

erabegins
01-06-2013, 03:08 PM
yes i'll try to make on m own keeping this conversion in mind. If that doesn't work I'll orer one with pjrc.
any other measures I should keep while building this adapter??? and do you think its easy building up?



Be careful to properly convert 5 to 3.3 volts. The PJRC adaptor does this for you, using a MCP1700-3.3 voltage regulator and 74LCX125 buffer chip. The schematic is published here:

http://www.pjrc.com/teensy/sd_adaptor.html

If you apply 5 volts directly to a SD card, you'll almost certainly damage the card. SD cards run on 3.3 volts.

PaulStoffregen
01-06-2013, 08:44 PM
That display will work. It uses 6 signals, not 9. But even if it used 9, there are still plenty because Teensy 2.0 has 25.

Buy that LCD now, so you have time to use it. Do not make the common student project error of delaying until it's too late!

Read this page for connection info.

http://www.pjrc.com/teensy/td_libs_LiquidCrystal.html

Also, read Adafruit's tutorials regarding that display.

I am willing to help you, but you really must learn to read these tutorials and manage make at least some progress on your own. I can not help at the level of telling you exactly how to do each individual step. I can only answer so many questions without you demonstrating any progress. You're about to reach my limit. You must attempt to make progress.

Please, try to move forward. Rather than asking for help on every minor thing, try to do it yourself and save the asking of questions for when you truly get stuck. Please, when you ask another question, post some photos or details of what you have actually done to move forward. Do not keep asking for hand-holding on every tiny step, without showing you are at least making a good faith effort to do your student project!

erabegins
03-08-2013, 09:16 AM
That display will work. It uses 6 signals, not 9. But even if it used 9, there are still plenty because Teensy 2.0 has 25.

Buy that LCD now, so you have time to use it. Do not make the common student project error of delaying until it's too late!

Read this page for connection info.

http://www.pjrc.com/teensy/td_libs_LiquidCrystal.html

Also, read Adafruit's tutorials regarding that display.

I am willing to help you, but you really must learn to read these tutorials and manage make at least some progress on your own. I can not help at the level of telling you exactly how to do each individual step. I can only answer so many questions without you demonstrating any progress. You're about to reach my limit. You must attempt to make progress.

Please, try to move forward. Rather than asking for help on every minor thing, try to do it yourself and save the asking of questions for when you truly get stuck. Please, when you ask another question, post some photos or details of what you have actually done to move forward. Do not keep asking for hand-holding on every tiny step, without showing you are at least making a good faith effort to do your student project!


Hello Sir...

i am done with the hardware setup.
please help me at this stage now.
i have my main code saved on sd card and want to run it as soon as i plug teensy to my computer.
how do i program using arduino so that it directly picks up the code on sd card and start executing.

PaulStoffregen
03-08-2013, 07:45 PM
please help me at this stage now.
i have my main code saved on sd card and want to run it as soon as i plug teensy to my computer.
how do i program using arduino so that it directly picks up the code on sd card and start executing.

You'll probably use Keyboard.print() or other Keyboard functions to send commands to your computer to cause it to run the program.

Adrian "Irongeek" Crenshaw (edit: typo corrected) has published a couple articles, and even a library, about how to do these sorts of things. Maybe his website (http://www.irongeek.com/) might help?

ZTiK.nl
03-08-2013, 08:24 PM
Adrian (http://www.irongeek.com/i.php?page=about) :)

Better do it right if you mention the man by name :P