Teensy Breadboard

From RepRap
Revision as of 08:11, 8 March 2014 by DavidCary (talk | contribs) (suggest move section)
Jump to: navigation, search

Teensy Breadboard

TeensyBreadboard20121031.JPG

Combines a $16 ATmega32U4 based carrier from http://www.pjrc.com/teensy with Pololus on a solderless breadboard. Runs Teacup through integrated USB using LUFA serial at 38400 baud. (Teensy is capable of 12MBit/sec communication per [[1]]. Tested at 230400 baud with CoolTerm, and 250000 Baud with Pronterface with modified Teacup using Teensy's usb_serial* routines.) Possible (and recommended) upgrade path to the AT90USB1286 on a $24 Teensy++ towards Teensylu and Printrboard compatibility. Possible upgrade path to a $19 32 bit ARM Cortex-M4 48MHz processor on Teensy 3.0, http://www.pjrc.com/store/teensy3.html

Philosophy

Some of the most expensive parts for a RepRap are the steppers and stepper drivers. If you settle on either NEMA14 or NEMA17 steppers, you can buy them with some stepper drivers early in the RepRap process. Before committing to a RepRap design, or even to Filament Deposition Manufacturing, you could play with the steppers and control with an eye towards other projects. If you think automated steppers would be fun to play with, you can start with a single stepper, matching driver, a piece of breadboard, and a USB-capable cpu.

Price, commitment, end-of-lifecycle-wise, $9*4 for the drivers + $16 for the CPU and $4 for a Protected Mosfet gets you most of what you need for the electronics for only $56 worth (2012-11-01) of very reusable components.

On the electronics side, it all fits in a single solderless breadboard ($4 Ebay 2012-11-01) with a little usb-capable carrier like the Teensy. The Teensy 2.0++ might be easier to build firmware for, since it matches the atmega1286usb chip already used in the in the Teensylu and Printrboard. I used the smaller Teensy 2.0 since I already owned one.

My Wallace uses 4 NEMA 14s ($16 from Pololu) and an expensive MakerBot high torque NEMA17 ([17Y402S-LW4-01] (overkill) on my Wade's extruder.

The design is future proof in that you could easily add a couple more axes, extruders, fans, or an upgraded processor, as RepRap or your needs evolve.

Firmware


Here's a screenshot of Teacup/Gen7 working on a Teensy 2.0:

TeacupGen7 Teensy Pronterface.png

Parts


  • Note 1: 1-3 MOSFET circuits and thermistor circuits, depending on whether or not you have a heated bed or fan. More heater/spindle circuits are possible, depending on pin availability
  • Note 2: Other MOSFETS could certainly be used. But fully protected, logic-level, ESD-protected MOSFETS reduce component count. This 49A one is overkill, but should handle anything a reprap could need. Other (OMNIFETS or OMNIFET IIs) might work better for you. If you chose one which more closely matched the amps of your extruder or bed, it would limit the current for you and protect better against shorts, over temperature, etc.. If you are using the overcurrent/overtemperature feature, you will want a protection resistor, R3, in series with the gate to protect the output pin from the overtemperature feedback feature.

Pinouts

Teensy 2.0

My pinouts from https://github.com/Traumflug/Teacup_Firmware/blob/master/config.teensy.h :

/*
	Machine Pin Definitions
	- make sure to avoid duplicate usage of a pin
	- comment out pins not in use, as this drops the corresponding code and makes operations faster

Teensy http://www.pjrc.com/teensy ATMega64U4 carrier:

DaveX plan for Wallace:
                               USB
           GND       GND |-----#####-----| +5V              ATX +5SB
     ATX PS_ON         0 |b0   #####   F0| 21 A0            Extruder TC
         X_MIN         1 |b1           f1| 20 A1            Bed TC
         Y_MIN         2 |b2  /=e6     f4| 19 A2            Stepper -ENABLE (or -SLEEP)
         Z_MIN         3 |b3 *      *  f5| 18 A3            STEP X
                 PWM   4 |b7  aref=/   f6| 17 A4            DIR X
                 PWM   5 |d0           f7| 16 A5            STEP Y
                       6 |d1           b6| 15 A6  PWM       DIR Y
                       7 |d2   V G R   b5| 14 A7            STEP Z
           Fan         8 |d3 d c n S d b4| 13 A8            DIR Z
      Bed Heat   PWM   9 |d6 5 c d T 4 d7| 12 A9  PWM       STEP E
 Extruder Heat   PWM  10 |d7 * * * * * d6| 11 A10 (led)     DIR E
                         --------------------
                          23 ^      \ \----22 A11
                                      \------ RST

      Interior E6: 24, AIN0, INT6
      Interior Aref : Aref
      End d5 : 23
      End d4 : 22, A1


With This configuration there remain 4 (or 7, if you count the three holes in the interior) IO connections leftover.

Teensy++ 2.0

A layout from https://github.com/Traumflug/Teacup_Firmware/blob/experimental/config.teensypp.h :

Teensy https://www.pjrc.com/store/teensypp.html AT90USB1286 carrier:

DaveX plan for Teensylu/printrboard-type pinouts (ref teensylu & sprinter) for a TeensyBreadboard:

                               USB
           GND       GND |-----#####-----| +5V              ATX +5SB
     ATX PS_ON    PWM 27 |b7   #####   b6| 26    PWM*       Stepper Enable 
                  PWM  0 |d0           b5| 25    PWM*        
                  PWM  1 |d1           b4| 24    PWM        
         X_MIN         2 |d2           b3| 23               
         Y_MIN         3 |d3           b2| 22               
         Z_MIN         4 |d4  * *      b1| 21                      
                       5 |d5  e e      b0| 20               
           LED         6 |d6  5 4      e7| 19               
                       7 |d7           e6| 18               
                       8 |e0             | GND              
                       9 |e1   a4 a0    R| AREF             
                      10 |c0   a5 a1   f0| 38 A0            
                      11 |c1   a6 a2   f1| 39 A1            
                      12 |c2   a7 a3   f2| 40 A2            
                      13 |c3           f3| 41 A3            
      Bed Heat    PWM 14 |c4   V G R   f4| 42 A4            
 Extruder Heat    PWM 15 |c5   c n S   f5| 43 A5            
           Fan    PWM 16 |c6   c d T   f6| 44 A6            Bed TC
                      17 |c7   * * *   f7| 45 A7            Extruder TC *4.7k *+5          
                         -----------------                  

      Interior E4: 36, INT4
      Interior E5: 37, INT5
      Interior PA0-7: 28-35  -- Printrboard and Teensylu use these pins for step & direction:
	     T++ PA Signal  Marlin
              28 a0 X_STEP  0
              29 a1 X_DIR   1
              30 a2 Y_STEP  2
              31 a3 Y_DIR   3
              32 a4 Z_STEP  4 
              33 a5 Z_DIR   5
              34 a6 E_STEP  6
              35 a7 E_DIR   7


With the AT90USB1286 on this carrier, many additional IO ports are available, and any firmwares that support Printrboard or Teensylu should work, with suitable pin reassignments. Marlin may work with SD support and a display, but take care since some of the pin numbers are assigned alphabetically instead of in Teensyduino order.

Wiring

Most of the wiring is straightforward. You can leave a few things disconnected and iteratively power up and test things as you build.

  • Cut the +5V-VUSB trace on the Teensy so you can use the. See http://www.pjrc.com/teensy/external_power.html for details and other options (The diode or modified cable options might be nicer)
  • I put the four stepper drivers on the left end of the breadboard, signal-side towards the front and motor side towards the rear. I put the teensy on the right, USB on the right edge. (If you put the teensy on the left and the drivers on the right, you could switch sides and leave more of the analog inputs open.)
  • Wire a power supply to the terminal block
  • Tie +5 and GND to the rails of the breadboard (I used the ATX standby +5V)
  • If using PS_ON, connect that output pin on the teensy to the ATX power supply's PS_ON input through a 1K current-limiting resistor.)
  • Wire the Teensy to +5 and GND
  • Wire each stepper driver to enable itself (Pololus: short -SLEEP to -RESET, GND to GND, VDD to +5),
  • Wire the microstepping (I used 1/(4,4,2,4) microstepping for (X,Y,Z,T), so I wired my Pololus with 1 microstepping pin each (MS2, MS2, MS1, MS2) tied to +5.)
  • Connect the -ENABLE pin of each stepper driver together and to the STEPPER_ENABLE pin on the Teensy
  • Connect the DIR and STEP connections for each stepper driver to the Teensy
  • Run a separate 12V line and GND from the terminal block to the VMOT and GND on the motor side of the stepper drivers.
  • Tune the stepper drivers appropriately Pololu_stepper_driver_board#Tuning_motor_current (On my Pololus, Vref of 0.280V will feed 0.7A to my stepper coils.)
  • Connect the motors to the stepper drivers, swapping wires as appropriate to get one coil attached to the 1A-1B pair on the driver, and the other coil on the 2A-2B pair on the driver.
  • Add pigtails to the MOSFETs, two heavier wires (10A+ for the bed) to the source and drain of the MOSFET, and a thinner, breadboard compatible wire for the gate. Wire the MOSFET sources to a terminal block ground, the drains to their own terminals, and the gate to the appropriate pin on the Teensy through a 1K protection resistor. The MOSFETS are mounted on the terminal block, with just the signal wire going to the breadboard.
  • I mounted the thermistor calibration resistor R2 in one row lined up with the appropriate Teensy pins: R2 vertical with short side in the +5 rail and long side in the first pinhole, leaving the other pinholes for the thermistor. Repeat for extruder and bed. See lower right corner of Media:TeensyBreadboard20121031.JPG at points (60-61) X (+,-,A,B) for a picture. If you have a 100K thermistor, you might not want to use a parallel R1.
  • Check and test

Options

  • The version shown above shows a Teensy 2.0, a couple Pololus with voltage regulators, a couple regular Pololus, a single heater output for the extruder, no endstops, and a single thermistor circuit. The Pololus are fed 12v through separate lines.
  • The $24 Teensy 2.0++ uses an AT90USB1286, which matches the Teensylu and Printrboard chips, which may make compiling and configuring a firmware easier. It also has lots of extra IO pins.
  • The Teensy 2.0 has 25 IO pins, 12 of them can do analog input, while 7 of them do PWM output, which is more than enough for the 15 pins required for 4 steppers, 2 heaters, 2 thermistors, and 3 endstops.

Discussion on first build

  • 2012-09-29 -- The original thermistor circuit is pretty noisy, with successive dT up to ~10C. The thermistor is fed off of the +5 rail supplied by an ATX power supply, and uses a 4.7uf capacitor, small relative to other electronics. Using a regulated 5V supply and a 10uf capacitor as in Ramps#Schematic or Sanguinololu may help with the noise. Alternately, you could filter it in software with TEMP_EWMA
  • 2012-10-29 -- The teensy and 4 pololus would take only 12+4*8=44 columns on a breadboard, so it should fit easily on one slab of 830 point solderless breadboard.
  • To avoid overloading the breadboard connector and busses (<2A), I use a 10A terminal strip connected to the powersupply, and run a separate 12V line to each Pololu Vmot input. For the extruder and the bed heaters, I wire the MOSFETs directly to the terminal strip and bring just the gate lines back to the breadboard. Nophead had a post about something like this at http://hydraraptor.blogspot.com/2012/07/sanguinololu-fan-hack.html
  • 2012-10-29 -- The thermistor capacitor didn't seem to smooth the noise much. Maybe I should try to reduce the noise with a slower PWM frequency.
  • 2012-11-04 -- If you are building this, I'd recommend trying the Teensy++ 2.0, which uses the AT90USB1286 and should be compatible with several standard firmwares. I've not tested it, but it should work with Marlin as MOTHERBOARD = 8 with the connections modified to match pins.h or vice versa. Under Sprinter it should be MOTHERBOARD = 8 or 9, with either pins.h or the connections modified to match. With Teacup it should work with MCU_TARGET = at90usb1287 in the Makefile, and a config.h modified appropriately.
  • 2012-11-27 -- A PCPowerSupply can have significant noise: up to 120mVpp on the 12v lines, and 50mVpp on the +5V lines per the ATX specs (http://en.wikipedia.org/wiki/ATX#Power_supply ). If your ADC is using VCC as a reference, or as supply to the thermistors, 50mVpp noise could account for 0.050/(5/1024)=10 ADC counts worth of noise. You should add capacitors to smooth out the power supply ripple. The newer ATX 2.3 spec requires stability with up to 10,000uF of capacitance on its + lines, while older ATXs specify stability for up to 350uF on +5Vsb. On mine, I smoothed 50mVpp to 10mVpp with a 220uF capacitor across the GND-+5SB lines.
  • 2014-01-16 -- I rebuilt it with a Teensy++2.0 with a few changes, rewiring some of it like a Teensylu, and using a USB cable with a cut V+ line. Marlin pin mapping for the AT90USB is very confusing, but this works with both Teacup and Marlin.

Thermistor Table

This page has been flagged as containing duplicate material. An editor has suggested merging this page or section into Teacup Firmware . (Discuss)

The information in this section only applies to Teacup, not any other firmware that could potentially run on this Teensy Breadboard, so I suggest moving the "Thermistor Table" section to Teacup Firmware.

I used an EPCOS B57560G1104 100K Beta_25/100=4092 thermistor in Teacup, so this is one of my thermistor table fragments. Note that for Teacup, the temperatures are C*4.

// Thermistor lookup table for RepRap Temperature Sensor Boards (http://reprap.org/wiki/Temperature_Sensor_2_0)
// Made with createTemperatureLookup.py (https://github.com/triffid/Teacup_Firmware/blob/master/createTemperatureLookup.py)
//           (patched per https://github.com/drf5n/Teacup_Firmware/blob/Gen7/createTemperatureLookup.py)
// default thermistor lookup table
// You may be able to improve the accuracy of this table in various ways.
//   1. Measure the actual resistance of the resistor. It's "nominally" 4.7K, but that's ± 5%.
//   2. Measure the actual beta of your thermistor:http://reprap.org/wiki/MeasuringThermistorBeta
//   3. Generate more table entries than you need, then trim down the ones in uninteresting ranges.
// In either case you'll have to regenerate this table, which requires python, which is difficult to install on windows.
// Since you'll have to do some testing to determine the correct temperature for your application anyway, you
// may decide that the effort isn't worth it. Who cares if it's reporting the "right" temperature as long as it's
// keeping the temperature steady enough to print, right?
// Temp*4 table from https://github.com/triffid/Teacup_Firmware/blob/master/createTemperatureLookup.py
// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=2700 --beta=4092 --max-adc=1023 --min_adc=20 --multiplier=4 --vadc=5.0
// r0: 100000
// t0: 25
// r1: 0 (parallel with rTherm)
// r2: 2700 (series with rTherm)
// beta: 4092
// min adc: 20 at 0.09765625 V
// max adc: 1023 at 4.9951171875 V
// ADC counts from 20 to 1023 by 52
#define NUMTEMPS 20
// {ADC, temp*4 }, // temp         Rtherm     Vtherm      resolution   power
uint16_t temptable[NUMTEMPS][2] PROGMEM = {
   {  20,   1548}, //  387.20 C,       54 Ohm, 0.098 V, 5.62 C/count, 0.18mW
   {  72,   1080}, //  270.22 C,      204 Ohm, 0.352 V, 1.09 C/count, 0.61mW
   { 124,    920}, //  230.13 C,      372 Ohm, 0.605 V, 0.57 C/count, 0.99mW
   { 176,    823}, //  205.99 C,      560 Ohm, 0.859 V, 0.39 C/count, 1.32mW
   { 228,    754}, //  188.57 C,      773 Ohm, 1.113 V, 0.29 C/count, 1.60mW
   { 280,    699}, //  174.77 C,     1016 Ohm, 1.367 V, 0.24 C/count, 1.84mW
   { 332,    652}, //  163.18 C,     1295 Ohm, 1.621 V, 0.21 C/count, 2.03mW
   { 384,    612}, //  153.02 C,     1620 Ohm, 1.875 V, 0.19 C/count, 2.17mW
   { 436,    575}, //  143.82 C,     2002 Ohm, 2.129 V, 0.17 C/count, 2.26mW
   { 488,    541}, //  135.28 C,     2458 Ohm, 2.383 V, 0.16 C/count, 2.31mW
   { 540,    508}, //  127.16 C,     3012 Ohm, 2.637 V, 0.15 C/count, 2.31mW
   { 592,    477}, //  119.26 C,     3700 Ohm, 2.891 V, 0.15 C/count, 2.26mW
   { 644,    445}, //  111.43 C,     4576 Ohm, 3.145 V, 0.15 C/count, 2.16mW
   { 696,    413}, //  103.47 C,     5729 Ohm, 3.398 V, 0.16 C/count, 2.02mW
   { 748,    380}, //   95.18 C,     7317 Ohm, 3.652 V, 0.16 C/count, 1.82mW
   { 800,    344}, //   86.25 C,     9643 Ohm, 3.906 V, 0.18 C/count, 1.58mW
   { 852,    304}, //   76.21 C,    13374 Ohm, 4.160 V, 0.21 C/count, 1.29mW
   { 904,    256}, //   64.14 C,    20340 Ohm, 4.414 V, 0.26 C/count, 0.96mW
   { 956,    190}, //   47.64 C,    37959 Ohm, 4.668 V, 0.39 C/count, 0.57mW
   {1008,     55}  //   13.89 C,   170100 Ohm, 4.922 V, 1.25 C/count, 0.14mW
};


Compiling Teacup for Teensy using the Makefile

Below is a transcript of a download and compilation of the Teacup Gen7 branch for Teensy. You will likely need to make your own config.h and ThermistorTable.h

Note that this was performed on 2012-11-25 using commit 9bbdbdd38d958a785db5542f3601162084ac203e.

GIT $ git clone -b Gen7 https://github.com/triffid/Teacup_Firmware.git TeacupTriffidGen7_20121125
Cloning into 'TeacupTriffidGen7_20121125'...
remote: Counting objects: 3954, done.
remote: Compressing objects: 100% (1277/1277), done.
remote: Total 3954 (delta 2865), reused 3713 (delta 2658)
Receiving objects: 100% (3954/3954), 2.01 MiB | 1.22 MiB/s, done.
Resolving deltas: 100% (2865/2865), done.
GIT $ cd TeacupTriffidGen7_20121125/
TeacupTriffidGen7_20121125 $ cp config.teensy.h config.h
TeacupTriffidGen7_20121125 $ cp ThermistorTable.double.h ThermistorTable.h
TeacupTriffidGen7_20121125 $ sed -i -e '/MCU_TARGET = atmega32u4/s/^#//' Makefile # uncomment CPU
TeacupTriffidGen7_20121125 $ make
rm -f .depend
avr-gcc -g -Wall -Wstrict-prototypes -Os -ffunction-sections -finline-functions-called-once -mcall-prologues -mmcu=atmega32u4 -DF_CPU=16000000L -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -save-temps -Winline -fno-move-loop-invariants -fno-tree-scev-cprop -MM mendel.c gcode_parse.c gcode_process.c dda.c dda_maths.c dda_queue.c timer.c temp.c sermsg.c watchdog.c debug.c sersendf.c heater.c analog.c intercom.c pinio.c clock.c home.c crc.c delay.c serial.c usb_serial.c > .depend;
  CC        mendel.o
  CC        gcode_parse.o
  CC        gcode_process.o
  CC        dda.o
  CC        dda_maths.o
  CC        dda_queue.o
  CC        timer.o
  CC        temp.o
  CC        sermsg.o
  CC        watchdog.o
  CC        debug.o
  CC        sersendf.o
  CC        heater.o
  CC        analog.o
  CC        intercom.o
  CC        pinio.o
  CC        clock.o
  CC        home.o
  CC        crc.o
  CC        delay.o
  CC        serial.o
  CC        usb_serial.o
  LINK      mendel.elf
  OBJCOPY   mendel.hex
  OBJDUMP   mendel.lst
  SYM       mendel.sym
    SIZES             ATmega...  '168    '328(P)    '644(P)    '1280
    FLASH : 17700 bytes          124%       58%        28%       14%
    RAM   :   857 bytes           84%       42%        21%       11%
    EEPROM:     0 bytes            0%        0%         0%        0%
TeacupTriffidGen7_20121125 $ teensy_loader_cli -mmcu=atmega32u4 -v -w mendel.hex 
Teensy Loader, Command Line, Version 2.0
Read "mendel.hex": 17772 bytes, 55.1% usage
Waiting for Teensy device...
 (hint: press the reset button)
Found HalfKay Bootloader
Read "mendel.hex": 17772 bytes, 55.1% usage
Programming...........................................................................................................................................
Booting
TeacupTriffidGen7_20121125 $ ../Printrun/pronsole.py 
Unknown variable 'bed_size_y'
Unknown variable 'last_file_path'
Unknown variable 'last_temperature'
Unknown variable 'last_bed_temperature'
Unknown variable 'bed_size_x'
*** Unknown syntax: button 0 "D_S1" M111 S0
*** Unknown syntax: button 1 "D_S0" M111 S1
Welcome to the printer console! Type "help" for a list of available commands.
PC>connect
No port specified - connecting to /dev/cu.usbmodem12341 at 250000bps
PC>Printer is now online
PC>m115
SENDING:M115
PC>ok FIRMWARE_NAME:Teacup FIRMWARE_URL:http://github.com/triffid/Teacup_Firmware/ PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1 TEMP_SENSOR_COUNT:2 HEATER_COUNT:3
PC>m114
SENDING:M114
PC>ok X:0.000,Y:0.000,Z:0.000,E:0.000,F:0
PC>g01 x1 y2 z3 f5000
SENDING:G01 X1 Y2 Z3 F5000
PC>m114
SENDING:M114
PC>ok X:1.000,Y:2.000,Z:3.000,E:0.000,F:5000
PC>m0
SENDING:M0
PC>exit
Disconnecting from printer...
Exiting program. Goodbye!
TeacupTriffidGen7_20121125 $ git log -n 1
commit 9bbdbdd38d958a785db5542f3601162084ac203e
Author: Markus Hitter <[email protected]>
Date:   Sat Nov 24 15:56:55 2012 +0100

    Give up on REPRAP_HOST_COMPATIBILITY.
    
    Was never really accepted and these days, hosts usually adjust
    to the firmware instead of the other way around.
TeacupTriffidGen7_20121125 $ git status
# On branch Gen7
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   Makefile
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	Makefile-e
no changes added to commit (use "git add" and/or "git commit -a")
TeacupTriffidGen7_20121125 $