New to Teensy, lots of questions please help!

Status
Not open for further replies.

MooSpyker

Member
Hey I've got a pretty large project (still on breadboard) going with the Arduino UNO. My project will be a controller for RC trucks, boats and other vehicles. Mixing servos and motors and such.
I now want to add sound to it and the UNO is not well suited for that so I would like to switch everything over to a Teensy. I plan to make and sell this on my own custom PCB and I have a few questions about doing this:

1. Can I even sell/use the Teensy chip on my own PCB?

2. Can I sell/use the Audio library with the Teensy on my own PCB?


3. I don't want to add USB to my board, how can I load my code onto the board without the USB components on the PCB? (I know you can use a Arduino UNO to program other UNO's using only a reset, rx, & tx pin)

4. I'm a little confused on the pin-out of the Teensy 3.2, I see "TX1" and "RX1" are used on several different pins, should I avoid using those 4 pins with that labeled? (pins 0, 1, 5, 21?)

5. I could not see the MISO / MOSI pins like I'm using on my UNO, are those just under another name?

6. What are all the DOUT / DIN pins used for?

7. What are the touch pins used for?
 
Hey I've got a pretty large project (still on breadboard) going with the Arduino UNO. My project will be a controller for RC trucks, boats and other vehicles. Mixing servos and motors and such.
I now want to add sound to it and the UNO is not well suited for that so I would like to switch everything over to a Teensy. I plan to make and sell this on my own custom PCB and I have a few questions about doing this:

4. I'm a little confused on the pin-out of the Teensy 3.2, I see "TX1" and "RX1" are used on several different pins, should I avoid using those 4 pins with that labeled? (pins 0, 1, 5, 21?)

The default pins are 0 == RX1 and 1 == TX1, but you can switch the Serial1 to use 5 == RX1 and 21/A7 == TX1. You can use the Serial1.SetTX/Serial1.SetRX functions to use the alternate pins: https://forum.pjrc.com/threads/3226...on-the-reference-cards-mean?p=98102#post98102.

5. I could not see the MISO / MOSI pins like I'm using on my UNO, are those just under another name?

6. What are all the DOUT / DIN pins used for?

It is just alternate name for the same thing. MOSI == DOUT, MISO == DIN. Like the Serial ports, there are functions to switch to the alternative pins: https://www.pjrc.com/teensy/td_libs_SPI.html.

7. What are the touch pins used for?
Those are for the touchRead function:

FWIW, I created the following spreadsheet to keep track of the variants between the Teensy 3.0, 3.1, 3.2, and LC in terms of pin usage, and I've added some notes about usage:
 
Thanks for the info and help!

Is #3 question even possible? (Easily)
3. I don't want to add USB to my board, how can I load my code onto the board without the USB components on the PCB? (I know you can use a Arduino UNO to program other UNO's using only a reset, rx, & tx pin)
 
Re #3 AFAIK::
> On Teensy - the USB is just the pins/connector - the onboard processors that are Teensy are the USB components needed for code upload
-- Serial is Hardware USB without added support chips, Serial1 is independent hardware on pins 0/1 - not like Arduino
> To date PJRC only interfaces through this USB for programming. In future Paul has indicated there may be PJRC support for side-loading from serial over WiFi/ESP8266 or similar type devices that can present the incoming code.
-- There are existing proof of concept interfaces by others that do this - but limitations, bricking risk and finding it and making it work is up to the user.
 
So basically it needs all that USB stuff. My original plan was to use an SD card for sounds, so the end user can add their own sounds to the board (engine sounds for RC trucks). If I add all the USB components, is it possible to transfer files over USB directly onto a memory chip on the board, to avoid an SD card all together? How would I go about setting something like that up?

I also have a lot of user-settable settings on my board that currently are set with a simple menu with push buttons and LED's blinking. Could I also somehow make the users change settings over USB? Would I need to code some kind of windows program to do this? I have no experience with anything like this.

My main goal here is that I do not want the end user to be able to see or use my whole code programmed onto the chip.

If I add USB to the board I want to take full advantage of what else I could do with it, if that's possible. Any info is much appreciated!

Thanks!
 
It is just a small matter of programming.

The Teensy Transfer program that Frank B wrote allows you to upload and download to the Teensy Prop Shield that has an 8 megabyte flash memory chip. Now, the way I use it is to download the program to a Teensy to update the flash memory, and then reflash my normal program, but you could use it as a subroutine in your normal sketch. https://github.com/FrankBoesing/TeensyTransfer.

In terms of not allowing the users to see your code, bear in mind, you really can't protect yourself from a determined code cracker.

Also from a legal standpoint, make sure that all of the library code you use is not licensed with a license like the straight GPL (Gnu Public LIcense).

From your questions, I suspect you may have a steep learning curve to come to grips with #1-#3. I would suggest getting your system working first using off the shelf components (Teensy, Teensy LC prop shield). Only after you get the first draft working, then start thinking about how to engineer your own boards, etc. By then, you will know exactly what you will need. Be sure to consider the costs of making your own board vs. how many units you realistically can sell. For small volumes, it may be better to just ship standard parts than going the custom route, since the custom route has a high startup cost, and it likely won't break even until you sell thousands, if not tens of thousands of copies.
 
Last edited:
I just got the board in the mail today and did not realize just how TEENSY it is rofl... I think I will be trying to install the teensy directly onto my own PCB. Have other people done this also before in a retail product? Tried to find some examples but could not. I expect to sell less then 100 of what I'm making so this might be the best way to go.

Which leads me to another question I could not even figure out the words to search for. The pads for the other pins under the Teensy, how could to connect them to your own PCB without simply soldering wires on, do they sell really small spring loaded pins or something like that?

Thanks for everyones help so-far!
 
I just got the board in the mail today and did not realize just how TEENSY it is rofl... I think I will be trying to install the teensy directly onto my own PCB. Have other people done this also before in a retail product? Tried to find some examples but could not. I expect to sell less then 100 of what I'm making so this might be the best way to go.

Which leads me to another question I could not even figure out the words to search for. The pads for the other pins under the Teensy, how could to connect them to your own PCB without simply soldering wires on, do they sell really small spring loaded pins or something like that?

Thanks for everyones help so-far!

Maybe like this ?
https://oshpark.com/shared_projects/0T6ZdhhG
trough-hole pads, cut in half.

osh-park has no problems with it, but to be sure, i'd ask the pcb-service if they can do that
 
Last edited:
The pads for the other pins under the Teensy, how could to connect them to your own PCB without simply soldering wires on, do they sell really small spring loaded pins...
I'm wondering if it's easier to just stick to the pins you can access from the edges and use multiplexing liberally as needed if the pin count isn't sufficient on its own... unless you can avoid it outright by a accessing the belly.
 
I already planned out to use nearly every pin on the Teensy, I really like the idea of cutting the bottom of the PCB out like that, looks really good.

Surprisingly it only took a day to port all my 2600+ lines of code over from the UNO to the Teensy and everything is already working perfectly. On the UNO I manually setup my timer interrupt (timer compare) and on the Teensy I just used the "IntervalTimer" like it recommend on their site, its working very well but I'm curious if that is really as good as manually setting up a timer on the Teensy? I'm manually controlling pins for 5 servo PWM and 3 motors (12 pins for 3x h-bridges) in that timer. I want to add audio on top of all that and I'm wondering if I can get away with all this?

I started looking at the audio examples, I did not buy the audio adapter, my plan was to just use the DAC right from the chip but I've been having a hard time figuring out how to actually go from that DAC to a small speaker. What do I all need to look into to get that to work? Even with that audio adapter can that even directly hook up a speaker?
 
I use an amplifier to amplify the teensy dac output. from that amp I run my speakers. There are tiny wee 'standalone' amps available, and I think the pjrc prop shield has one ....
 
I use an amplifier to amplify the teensy dac output. from that amp I run my speakers. There are tiny wee 'standalone' amps available, and I think the pjrc prop shield has one ....

Yes, the prop shield has a 2 watt amplifier. Pin 5 enables the amplifier. http://www.pjrc.com/store/prop_shield.html.

Note, if you are using all of the pins on the Teensy, you probably don't want to use the prop shield, since it uses some of the pins to control aspects of the shield.
 
I was trying to avoid using a shield just because I do want to eventually sell my own PCB, trying to keep it as simple as possible.

Can the audio quality be lowered at all? If the audio running with all my servos and motors slows things down I would not mind dropping off some audio quality, this will be used with small speakers inside RC toys, so it doesn't need to be studio quality or anything.

Has anyone done any engine sound effects with a Teensy? I seen a forum post on here about that but they never seem to got it to work, they were looking at pitch bending.
This is what I'm after here: https://youtu.be/vSD7dr1pRBk?t=4m23s
 
I was trying to avoid using a shield just because I do want to eventually sell my own PCB, trying to keep it as simple as possible.

Can the audio quality be lowered at all? If the audio running with all my servos and motors slows things down I would not mind dropping off some audio quality, this will be used with small speakers inside RC toys, so it doesn't need to be studio quality or anything.

I wouldn't worry about the onboard dac being too hifi for you.

adafruit sell really dinky little standalone amplifiers and funny little speakers... not even 10 bucks allup ... probably 5 ...can't remember ... I have one of them little amps and a couple of dinky speakers lying around here ....
 
...I was trying to avoid using a shield...

No need for the shield if you're building a custom PCB anyway... you can just use the LM48310 and copy the amp part of the prop-shield schematic:
i2c_audio.PNG
It's just a few passive parts and the chip... should add only a buck or two to the cost of the board and you can still use the 'witout' prop-shield during development.
 
Last edited:
If you're concerned about GPL libraries for when you ship a proprietary product, the main one is the Arduino SD library. It's GPL. If you only need to read the card, I made a complete MIT licensed rewrite of the SD library. But so far it only reads. You can use it by editing SD_t3.h to enable the optimized version. With minor editing, you could easily delete all the GPL files, if you're really concerned about such things.

If you use Arduino Uno (or pretty much any other Arduino board), the GPL license SD library is pretty much your only choice for SD card access.

When you're ready to lock your chips, look for documentation in hardware/teensy/avr/cores/teensy3/mk20dx128.c. Pay attention to the issue of preventing accidental press of the program button!

If using touchRead() with the touch sensing pins, and if you also use the class-D amp chip, keep the speaker wires away from the touch sensing wire and pads/surfaces. Likewise for SPI signals if using the audio lib and a SD card or flash chip. The touch sensing can be disrupted if those rapidly changing digital signals get capacitively coupled.
 
Hey Paul! Thanks for all the help so far everyone. I've been slowly working through issues on this project and making some progress.

I ran into another issue I'm having a hard time finding an answer to. I'm using a 5v switching power supply for my breadboard and the switching noise is making its way into my sound setup. I'm using a 8002B amplifier chip, running directly off the DAC pin of Teensy, with a 10uf capacitor in-between. Its got a constant static buzz. Is there anyway to decouple that from the audio?

I need to use a switching PSU because of the wide input voltage range my board will need to accept. The PSU will be powering 5x servos and the Teensy. I want to support up to a 3s Lipo (~12v) battery, I expect up to 3 amps being drawn from the servos max, so I can't really use a linear voltage regulator to drop that much voltage off.

Couple more questions...
I have not gotten my motor drivers hooked up yet on the Teensy but I'm worried about those causing noise on the speaker also, any tips for that? It is a total of 12 mosfets (3x h-bridges)

What do you think would be the best way to make an engine sound effect with the current audio library? I'm not fimmilar with filters at all, can those be changed on the fly to make the engine sound like it smoothly accelerates based on input? Otherwise I'm thinking of just using a mixer and cross fading volumes of different engine sounds together, won't sound as nice though I think, not sure.
 
Another problem I just ran into also, trying to play 2 wav files at the same time and the entire Teensy bogs down and doesn't process any other code in my loop until the 2nd sound stops playing. I need to be able to play 4 wav files at once, not sure why it can't even handle 2 I don't what I'm doing wrong. How can you lower the quality of the audio? I don't need studio quality sound coming out for this project, wouldn't that make the whole program do less work to lower it down?
 
Last edited:
Two problems are working together to cause this slowdown.

#1 - You probably have a high-latency SD card. Better quality SD cards are faster.

#2 - The Arduino SD library reads only 1 sector at a time. This results in a lot of overhead waiting for the SD card, which makes #1 much worse.

At this time, the best available solution for more than 2 files is a serial flash chip. Those chips have low latency, so you can play more sounds simultaneously.

Later (probably sometime in 2017) the SD library will be improved. Especially on the upcoming Teensy 3.6 board where we have more RAM, the SD library will cache more data and use multi-sector reads for better performance with the latency of common SD cards.
 
I kind of figured it out shortly after my last post, I had 2 of the audio files still in stereo, I changed them to mono, and I'm able to play 3 sounds at the same time right now with a little slow down to the servos, but 4 sounds and everything bogs down.
Is it possible to setup the Teensy to transfer files from an SD card to a flash memory chip? So the end user can load files onto SD card easily, then when they power the device on I can have it wait until all files are moved, then play sounds from the flash chip?

I wonder if I'm even handling my servo output correctly. I'm using a IntervalTimer setup for every 25 microseconds, in the interrupt for that I increment each servos pulse count, until it reaches the current desired position, then it toggles the pin from high to low. I do not have the timer setup for PWM, its all done manually in my code, is that a horrible way to do this?
 
Status
Not open for further replies.
Back
Top