Raspberry Pi Teensy Hat

Status
Not open for further replies.

jwatte

Well-known member
The Raspberry Pi is nice and all -- it has good CPU power and a GPU, at a low cost and low power budget.

It doesn't have analog I/O, and it doesn't have a good way of reading RC PWM input signals. (Perhaps some kernel module can be cooked up that does it with interrupts, but I haven't seen anything like that.)

I've successfully used Teensy paired with Raspberry Pi for a few years now, and quite like the model. But, you know what would be even better? A Raspberry Pi "hat" that contained the Teensy chips right on it, rather than having to use separate carrier/interface boards.

I know that PJRC sells the special "programmer" chips for tying into the Freescale MCUs. Thus, a "hat" could presumably be built with that chip, and either the Teensy LC MCU (for low cost) or the 3.5 MCU (for 5V tolerance, at slightly higher cost.)

However, if I were to build a few dozen of these and sell on Tindie, that wouldn't really be economical. Meanwhile, if the LC was available as a hat from PJRC -- same board/chips, just a bigger PCB and a 2x20 pin female on the bottom -- that might be reasonably priced. (I'm guessing here -- perhaps the connector and the bigger board would double the price; I don't know?)

Another thing that would be cool would be a version of HalfKay that runs on the Raspberry Pi serial port, rather than USB. (Or I2C, or SPI.) That way, the "hat" would be totally programmable from the Pi without needing a loop-around USB cable. I dislike the USB cables; it's not a robust signalling protocol for things the move and shake, and the cables end up being almost as big as all the other electronics when assembled.

Clearly, it's "possible" to run HalfKay over a serial port, instead of USB, but a more interesting question would be: if I built a dozen boards, would PJRC be interested in selling MKL02 chips that loaded that custom bootloader, rather than the USB-based one?
 
Sounds interesting to me.

I have some of my own hats for the RPI. So far played around with a few different boards, some with T3.2 others with 3.5/6... Currently mine use the whole Teensy and not the components as they are beyond my soldering skills. But it would be great if one could use a serial interface instead of USB as for the most part I am avoiding using USB... Actually most of the time USB is fine for me as I program the board from my desktop, and have it then communicate with RPI (or currently in my case an up board or odroid )... But it would be nice to have the ability to program it through the main host without needing a cable.
 
In the best of worlds, the bootloader would be able to read/write both USB and serial port. But that can't be the default behavior, because some other installations may of course have things on the serial port that would be interefered with by that protocol...
Given that the HalfKay is so small, I wonder if the sketch itself could have a mode where it puts itself into HalfKay-in-RAM mode and can bootload?
If so, I could initially program using USB, but then each "properly configured" sketch could support re-programming with serial port.
 
Keeping up with the Teensy form factor, you could always swap the RasPi for its cheaper, 'teensier' cousins like the NanoPi Neo. This board also breaks out a USB port on headers, next to the standard RasPi header.
 
Thanks for the suggestion. To my thinking, the price of the Pi is not a problem. The Pi is well supported, has reasonable GPU support, 1 GB of RAM, and four USB ports (which I use all of!) And it has an on-board camera connector, which I don't see on the Neo? The direct support for the camera->GPU path is super helpful for computer vision, which is why I need the Pi in the first place (else I'd just use a Teensy.)
The goal for me is ot get a Teensy onto the Pi, not the downgrade the Pi.
My next robot may use a Jetson + Teensy instead of a Pi + Teensy. A "hat" would still be useful, because the default Jetson devkit motherboard comes with a Pi-layout header!
 
NanoPi has almost two dozen types of RasPi clones. Maybe the M2 is more suited for your application? It has a camera interface, two USB connectors and two USB ports on headers.

You could also look at the OrangePi line of boards.

To me it's not really about the price, but about the extra hardware features that would make a RasPi type board so much more useful (e.g. the USB ports on headers). Clones like these enjoy excellent Armbian support.

Personally I also think your application plans will move forward faster if you switch to solutions already available in the market.
 
Because it enables you to make a working hat with the currently available MKL02 bootloader chip without using USB cables, which is your goal if I'm correct, and not having to wait on a special version of the MKL02 that may never come to be.
 
But it wouldn't be a hat, because it's not for the Raspberry Pi then. I have tons of software already written for the Pi GPU, and I use libraries (like caffe2) which have Pi support but not Allwinner support.
Btw: the Allwinner boards don't even seem to have 3D GPU suppirt on any modern kernel (4.x and up)
 
Another maybe option?

I remember reading a thread where some have had some luck maybe downloading a new version of their program over wifi using ESP8266 module. My assumption was that they connected the ESP board to the Teensy over a serial port.

Again I don't remember the details, but if I remember correctly you have to have special code in your own Teensy program, that somehow can download the new program and save it away. There were constraints like your Teensy program could not be > then some size like maybe half the total program space... Again I am probably missing something...
 
seeing jwatte's other post on autonomous rover, I can image other application where you simply plug a teensy board onto RPI extending the functionality of RPI.
Let Teensy do all the time critical activities and RPI the other stuff.
One only needs a teensy adapter with all pins broken out and connector ro RPI
 
The current one is not fully generic:
RPI Hat.JPG
It is also currently sitting on an UP board. Normally does not sit this high off of RPI/UP, but put in 2nd header on RPI plug to make it higher to make it easier to hook up Logic Analyzer...

And yes I wish to use the Teensy on this to control Dynamixel Servos (AX-12 mostly). So have the Teensy control all of the servos and take care of interpolation between steps...
 
Hi KurtE and others.

This thread has gotten my interest up for a couple of reasons. In my third rover project, https://forum.pjrc.com/threads/4574...penMV-Camera-(Machine-Vision)?highlight=rover, I am using a OpenMV cam to do the video processing for obstacle avoidance but it does have memory limitations. Basically, I determines the angular positions of potential gaps to go around any obstacles. The Teensy takes that info and uses a distance sensor to determine the actual gaps and if none detected runs a VFH algorithm. Uses alot of the same code from: https://forum.pjrc.com/threads/41117-Teensy-3-5-Autonomous-Robot?highlight=rover. Probably expand this to use GPS as well in the future.

I started looking at a couple of other solutions, including a RasberryPI to do the OpenCV stuff. But since my requirements would be to run it off a LiPo and keep the rover foot print small for now (doing indoor avoidance) not sure which model or what other possible solution there would be.

Any suggestions?
 
One thought might be to look at the USB hubs for the Pi zero-W. These mount underneath the zero-W and use pogo pins to attach to the power and USB ports. I could imagine some creating a PCB that mounts the Teensy 3.2 and it has tiny pogo ports for the USB D-/D+ pins, connecting to a board that had larger pogo pins and a 20 pin connector to connect the pi above the Teensy. That way the Teensy would be connected, but you wouldn't have to run external wires to connect the two USB systems (you presumably would need to add a USB hub in between the two), and you would program a Teensy normally.

In terms of running off of a lipo, your best bet is probably the zero/zero-W which I believe uses the least amount of power (and is also the smallest). There are some lipo converters already:
 
You can put a bootloader as static data in your program, then copy it into RAM and run in from there when loading. That allows you to program all of flash (minus the size of the bootloader data.)
That might be the least bad option. Plus, a small USB cable can be used when needed.
I might do a hat prototype like this!
 
@MichaelMeissner - thanks for the info on the Pi Zero. Been looking at it, and it looks like it would fit the bill. Would have to do some testing on it. Thanks for the reference. Wasn't sure it would be enough to run opencv but I found out how to do that. Think I found the stuff I would need over at Adafruit. Now have to learn Linux.

@jwatte - ok you lost me on that. Are you saying doing that on the Pi or the Teensy?

I know we are getting away from the original intent of the thread so if you want to take it over to https://forum.pjrc.com/threads/45741...ighlight=rover it would be alright.

Maybe we can get Paul to put a Robotics category if there is enough interest?
 
@jwatte - ok you lost me on that. Are you saying doing that on the Pi or the Teensy?

On the Teensy! Basically, the Teensy memory map has a few blocks of SRAM and Flash and I/O devices.
You can build a small bootloader, and tell the linker to link it for living in RAM instead of in Flash.
Then you can take that code, and create a static const array of data that you put into the flash memory (instead of readable memory) in your regular sketch.
Then, when time comes to bootload, the sketch would:

1) memcpy() the bootloader code out of payload, and into the appropriate RAM location

2) set the stack pointer to a suitable value

3) jump directly to the bootloader (you can do this with casts to pointer-to-function type, or inline assembly.)

Because the bootloader code is now all in SRAM, you can overwrite all of flash. Thus, you can speak whatever protocol you want, and overwrite the flash. When you're done, do the magic write function to reset the Teensy, and you'll be back running the new sketch in the flash.

Note that this is not as robust as the separate loader chip that is the "magic" of Teensy. Thus, if this process somehow goes wrong, or is interrupted, you will likely have to revert to loading a new sketch from USB. It's nice that there's always that safety!
 
In the past it was very hard to get Pi Zero's (both the $5 version and the $10 W version with wifi/bluetooth), and the places that sell it tend to limit you to 1 per customer. Part of the issue is the pricing structure. I imagine that Raspberry Pi org is not making any money off of these, and the shops that sell it (like Adafruit) sell it in the hopes you will buy other zero stuff. For Raspberry Pi it furthers their overall goal of getting computers into the hands of people to hack with.

At the moment, Adafruit has stock. Sometimes Adafruit will sell out of the basic package, but have the combo's in stock or vice versa. It looks like Sparkfun also has them in stock. Note, in the past Adafruit has sold packages that include a pre-installed disk, but the disk would not run on the Zero W. I've yelled at them for selling a newbie package that didn't run (back when I did the Adafruit forums more) and others did also. Hopefully by now, they have updated the new firmware in the pre-installed micro-SD cards.

If you live in the USA and have a MicroCenter near by, they always seem to be able to get Zeros (though if you are buying more than one, the price jumps from $10/unit to $13/board). However, you typically can't mail order the zeros from MicroCenter.

If you are doing something that needs to buy in bulk, it is probably better to go with the Pi 2A, 2B, or the 3. Similarly if you need more memory or horsepower, you need to move up.

Just in case, you might want to use a 32GB card or smaller. I know initially the boot procedure required a VFAT formatted card, and above 32GB the cards become micro-SDXC cards and typically use the exFat partition system instead of VFAT.

However, in terms of battery usage, you probably don't want the Pi 3 (at least running all 4 cores). Here are some posts for power usage:
 
Last edited:
The Pi 3 has higher-power GPU and CPU than the Zero, though, which means my vision pipeline can do more work. If I actually use that power, then not having it available is a non-starter :)
My current pipeline uses about 280% of a Pi 2, which is more than a Zero / Zero W can provide, unfortunately. And I'm going to go up from there!
If I want the most image processing power per watt, I probably want a Jetson TX2.
And, it turns out, the Jetson also has support for the Pi Hat form factor adapter boards. So, yay?
 
That's a neat project! There's a meetup group that does much the same thing, the Donkey Car: http://www.donkeycar.com/
A bunch of rover racers congregate there; not just those using the specific Donkey that they have plans for.
 
Status
Not open for further replies.
Back
Top