Powering a Teensy 4.0 with a Teensy 4.1 connected via USB

topicbird

Active member
Hey guys,

it may be a newbie question, but could you maybe tell me how to power up a Teensy 4.0 by only connecting a Teensy 4.1? My plan is to build a step sequencer with a touch screen. For this I have the two Teensies connected via serial communication. Once I'm finished with the project, I don't want to plug in two individual USB cables to the two teensies, but one into the 4.1 which also powers the 4.0.
I'd be very grateful for any help. :)
Thank you!

Best regards,
Máté
 
Hey guys,

it may be a newbie question, but could you maybe tell me how to power up a Teensy 4.0 by only connecting a Teensy 4.1?

@topicbird (Máté):

Connect pin 48 on the T4.1 & pin 28 on the T4.0 together. This way, the USB power connected to the T4.1 Vin pin will also provide power to the T4.0 Vin pin. Make sure to also connect at least one ground pin on the T4.0 to a corresponding ground pin on the T4.1 (if you haven't already).

Hope that helps !!

Mark J Culross
KD5RXT
 
Thank you so much Mark! If I'm not wrong, these pins can be only connected by using a cable which I solder to both of it's corresponding copper traces? Also, would I still be able to power up both of them with USB in order to upload new code? I really don't want to fry one of them. :D Thank u in advance!
 
Thank you so much Mark! If I'm not wrong, these pins can be only connected by using a cable which I solder to both of it's corresponding copper traces? Also, would I still be able to power up both of them with USB in order to upload new code? I really don't want to fry one of them. :D Thank u in advance!

@topicbird (Máté):

Yes, you should make your connections with wires soldered in place on the two Teensies. When the two Teensies are connected this way, you would want to connect a USB cable to only one at a time. Both Teensies will be powered, but whichever Teensy you plug the USB cable into will be the one that you are programming.

Hope that helps !!

Mark J Culross
KD5RXT
 
Note: if you wish to plug a T4.0 into a T4.1, one option is to use the USB Host cable, like: https://www.pjrc.com/store/cable_usb_host_t36.html

The 5 pin connector on the T4.1 is setup for these cables and includes a +5v pin.

And with this you can obviously simply unplug the T4 and plug it into a normal USB port on PC to reprogram.

Alternatively, I know that some have reprogrammed a Teensy while plugged into a Teensy. Been awhile since I tried it.
 
May I ask, why you need 2 teensy for that project? I am running a step sequencer with tons of modulation, probability and stuff, and the MCU is running so fast, that the Pulse (I am doing 192ppqn resolution) is hardly measurable in microseconds. Doing IO (50 buttons, 20 Encoders, 70 RGB LEDS, 5 MIDI Channels + 4xUSB MIDI and an ILI9341 display with the t4) library on the mainloop and the sequencer tick on an interrupt is no problem at all for the teensy. I will run out of memory (storing all project data in PSRAM) way before I will run out of MCU power.
Not, that I want to talk you out of your approach, but maybe its not really needed to go with 2 MCUs and that really slow Serial communication between them.
I used to use a Raspberry Pi Pico to handle the Encoders and Buttons (way cheaper than a Teensy 4.0 that's way overpowered to do such a tiny task), but this is also possible with just a few Multiplexers etc.
 
Last edited:
Thank you @kd5rxt-mark for the quick help, once again! :)

@KurtE:
That's also a really great idea! Never heard of this option before, thank you!

@Uija:
Your point is perfectly valid. The reason behind this is, that I used a multiplexer before to "extend" the pins. For some reason though, I just wasn't able to use the internal clock I've coded for the sequencer after implementing the multiplexer. This is the reason behind that. I'd be really really happy though, if we could maybe have a chat about the way you managed to build your sequencer! I'd also be really happy to build it as efficient and cheap as possible.

Thank you guys for your helpful responses! :)
 
I just wrote down how my sequencer is running „multithreaded“ in a different thread, that lets the midi sequencing run as tight as used to even if I load or save the project from SD card that takes up way longer than a midi tick. Maybe that helps you finding a solution for your timing issues.
For this purpose here, I should add: There is a third „thread“ running, that reads IO from hardware on a pin-changed interrupt, that queues IO -messages that are than handled in the main loop, as I use I2C GPIO-Extenders to be able to work with that many buttons and encoders, and to not miss encoder pulses, I have to read the data as soon as the external chip notifies a change. my first version of a sequencer has way less Encoders and I was able to use multiplexeres for the buttons in the main-loop.

https://forum.pjrc.com/threads/7125...-read()-method?p=314099&viewfull=1#post314099

as I said: I did use a Raspberry Pi Pico to handle the IO First. To power this up, I just connected the 3.3V of the Teensy with the 3.3V of the Pico. this worked without a single issue!
 
@Uija

thats a lot of useful information! I didn't know about the GPIO-Extenders before.
I just read your other thread and it's pretty impressive that your clock is more tight than the ones from your other machines!
The other reason though, why I used a Teensy 4.0 to get enough IO is simply that I had one.
Considering the price aspect, you could even take an arduino clone instead of a raspberry pi and it'd be even cheaper and do the job or not?
I know the Multiplexer is a tenth of the price but I just had so many problems with it and I became pretty discouraged in using it..
As I told, the function to read the changing values at the multiplexer simply destroyed the clock.
The problem was that I just couldn't time the reading intervalls with my millis()-lastMillis()... way but I had to use delay() which obviously destroyed the clock.
Pretty annoying but after talking about it now, maybe I'll give it another try.
 
@Uija

Is there any essential piece of information about the clock rate and the rate of which you read the multiplexer values? I had the feeling that if I'd have been able to sync them up, it could have been a solution to my problem.
 
As soon as you move your sequencing code out of the main loop and trigger it via the timerinterrupt, the speed of the main loop does not interfere with the sequencing code.
I had the multiplexer read every single loop. If I remember correctly, there were some very short delays in there to slow it down to work correctly. I just looked at the Control_Surface Library, how he did access the multiplexer.
If you want to work with timings, that you calculate yourself, elapsedMillis and elapsedMicros is a very good solution, so you dont have to do all that millis() and micos() calculation yourself all the time.
Code:
elapsedMillis em;
void loop() {
  if( em >= 1000) {
    // Do what every you want to do every 1000 milli seconds
    em = 0;
  }
}

I just read your other thread and it's pretty impressive that your clock is more tight than the ones from your other machines!
Yeah, I wondered myself too. I think one of the reasons is, that most of the other devices do way more than "just" sequencing, and a lot of them use way slower MCUs as the Teensy4.1 has.
But that IntervalTimer seems to be very accurate. I am missing devices to see, if a microsecond there is really a microsecond, but non of the tools I had (Hardware and DAWs) or was able to lend was showing any jitter.
And it is so easy:

Calculate the microseconds between every pulse. (BPM is quarter notes per minute, a Minute as 60 million microseconds, so a quarter note takes 60.000.000 / BPM microseconds. Devide that by your resolution (PulsesPerQuarterNote, in my case 192) and you have the amount of microseconds you need to wait between every pulse.

So there is a IntervalTimer somewhere. Than you have a callback function, that is called, when the interrupt occurs. And than you start it with the microseconds you calculate and update it, when you change the BPM.

Code:
// used variables
IntervalTimer pulseTimer;
uint16_t microSecondsPerPulse =MICROSECONDS_PER_SECONDS / bpm / PPQN;

// callback method
void onPulseTimer() {
  Sequencer::pulse();
}

// start the timer

pulseTimer.begin(onPulseTimer, microSecondsPerPulse);

// update the timer if the bpm changes
// first recalculate the microSeconds
microSecondsPerPulse = MICROSECONDS_PER_SECONDS / bpm / PPQN;
pulseTimer.update(micoSecondsPerPulse);

This is pseudo code, I wrote down here to explanation. You should check for datatypes etc. Defines are missing, etc.

I use the Raspberry Pi Pico for everything, that I don't need that much power, because its 3.99€ shipped from a shop a few cities away. No need to spare a few bucks for a Arduinoclone that is slower and might not work correctly from china there :p
 
@Uija

Thank you so much for this detailed answer! Is there maybe any chance to talk via mail or in any way with you? It'd be a huge help!

- Máté
 
Back
Top