3D Printer Software with Teensy 3.1

Status
Not open for further replies.
Little progress with my Teensy 3.1 to Ramps 1.4 adaptor using:

- Teensy 3.1
- Tall Dog LLC Teensy 3.1 Breakout
- Arduino Mega Protoboard with stackable headers
- Ramps 1.4
- ATX power supply/Felix frame

View attachment 2305

Hello I was wondering if you got this going yet ?
If so do you have the pin assignments?

Thanks Stan
 
Hello I was wondering if you got this going yet ?
If so do you have the pin assignments?

Thanks Stan
I am stuck, because the ATX power supply doesn´t work. :-(

I did a first pin assignment ... on paper. Because i need two HCT245 and there is little space on the board, i may change some pins.
This is my current(!!!) definition for board 85 in pins.h:
Code:
/********************************************************************************************************************************************************************************/
/****************************************************************************************/

/*****************************************************************************************
*****************************************************************************************
* Teensy 3.1 Breadboard pin assignments (MK20DX256)
* Requires the Teensyduino software with Teensy 3.1 selected in Arduino IDE!
  http://www.pjrc.com/teensy/teensyduino.html
* CLI build: HARDWARE_MOTHERBOARD=85  make
* 
****************************************************************************************/
#if MOTHERBOARD == 85
    #define KNOWN_BOARD 1
    #define AT90USB 1286  // Disable MarlinSerial etc.

    #ifndef __MK20DX256__
        #error Oops!  Make sure you have 'Teensy 3.1' selected from the 'Tools -> Boards' menu.
    #endif

    #define LARGE_FLASH     true

    //  T31Ramps14 by aikx
    //  Pin-33: http://forum.pjrc.com/threads/24823-Teensy-3-1-Tying-Pin-33-(pta4)-low-freezes-teensy
    //  TODO: needs work here, to define pinout....
    //#define name              Pin T31 //->Pin Mega  /   IO-Type // comment

    // Serial 1
    #define T31_Serial_RX1          0   //->    /  DIN5V
    #define T31_Serial_TX1          1   //->    /  DOUT5V
    // T31 SPI port
    #define T31_SPI_CS              10  //->    /   SPI_CS_SD
    #define T31_SPI_MOSI            11  //->    /   SPI_MOSI
    #define T31_SPI_MISO            12  //->    /   SPI_MISO
    #define T31_SPI_SCK             13  //->    /   SPI_SCK
    // i2c interface 
    #define T31_I2C_SDA0            18  // D20 ->   /   i2c Port 0
    #define T31_I2C_SCL0            19  // D21 ->   /   i2c Port 0
    //--------------------------------------------------
    // ENABLE all stepper drivers
    #define STEP_ENABLE_PIN         2   //->38  DOUT5V

    #define X_STEP_PIN              3   // A0->54   /   DOUT5V
    #define X_DIR_PIN               4   // A1->55   /   DOUT5V  
    #define X_ENABLE_PIN            STEP_ENABLE_PIN //->38  /   DOUT5V
    #define X_MIN_PIN               4   //->3   /   DOUT5V
    #define X_MAX_PIN               -1  //->2   /   DOUT5V

    #ifdef DUAL_X_CARRIAGE
        // Pins for second x-carriage stepper driver ( from Configuration_adv.h)
        #define X2_STEP_PIN         4   //->    /   DOUT5V
        #define X2_DIR_PIN          5   //->    /   DOUT5V
        #define X2_ENABLE_PIN       STEP_ENABLE_PIN //->    /   DOUT5V
    #endif

    #define Y_STEP_PIN              6   //->60  /   DOUT5V
    #define Y_DIR_PIN               7   //->61  /   DOUT5V
    #define Y_ENABLE_PIN            STEP_ENABLE_PIN //->56  /   DOUT5V
    #define Y_MIN_PIN               4   //->14  /   DOUT5V
    #define Y_MAX_PIN               -1  //->15  /   DOUT5V

    #define Z_STEP_PIN              8   //->36  /   DOUT5V
    #define Z_DIR_PIN               9   //->34  /   DOUT5V
    #define Z_ENABLE_PIN            STEP_ENABLE_PIN //->30  /   DOUT5V
    #define Z_MIN_PIN               4   //->18  /   DOUT5V
    #define Z_MAX_PIN               -1  //->19  /   DOUT5V
      
    // these pins are defined in the SD library if building with SD support
    #ifndef SDSUPPORT
      #define CS_PIN                T31_SPI_CS      //->    /   SPI_CS_SD
      #define MOSI_PIN              T31_SPI_MOSI    //->    /   SPI_MOSI
      #define MISO_PIN              T31_SPI_MISO    //->    /   SPI_MISO
      #define SCK_PIN               T31_SPI_SCK     //->    /   SPI_SCK
    #endif

    // Extruder 0
    #define E0_STEP_PIN             14  //->26  /   DOUT5V
    #define E0_DIR_PIN              15  //->28  /   DOUT5V
    #define E0_ENABLE_PIN           STEP_ENABLE_PIN //->24  /   DOUT5V
    // Extruder 1
    #define E1_STEP_PIN             16  //->36  /   DOUT5V
    #define E1_DIR_PIN              17  //->34  /   DOUT5V
    #define E1_ENABLE_PIN           STEP_ENABLE_PIN //->30  /   DOUT5V

    // PWMs: Heater and fans
    #define HEATER_BED_PIN          20  //->    /   PWM5V   /   Bed
    #define HEATER_0_PIN            21  //->10  /   PWM5V   /   Extruder E0
    #define HEATER_1_PIN            22  //->9   /   PWM5V   /   Extruder E1
    #define FAN_PIN                 23  //->9   /   PWM5V   /   Fan

    // TODO: temperature.cpp still only AVR compatible - much ADC code
    #define TEMP_BED_PIN            A10 //->    /   AIN33V  /   Bed
    #define TEMP_0_PIN              A11 //->A13 /   AIN33V  /   Extruder 0
    #define TEMP_1_PIN              A12 //->A15 /   AIN33V  /   Extruder 1
    
    // SD 
    #define SDPOWER                 -1  //->-1  /   ??? /   
    #define SDCARDDETECT            -1  //->    /   ??? /           
    #define SDSS                    -1  //->25/53   /   DOUT33V

    #define LED_PIN                 -1  //->13  /   ???
    #define PS_ON_PIN               -1  //->12  /   ???
    #define KILL_PIN                -1  //->    /   ???
    #define ALARM_PIN               -1  //->    /   ???


    #ifdef ULTIPANEL
        #define LCD_PINS_RS         -1  //->    /   ???
        #define LCD_PINS_ENABLE     -1  //->    /   ???
        #define LCD_PINS_D4         -1  //->    /   ???
        #define LCD_PINS_D5         -1  //->    /   ???
        #define LCD_PINS_D6         -1  //->    /   ???
        #define LCD_PINS_D7         -1  //->    /   ???
        #define BTN_EN1             -1  //->    /   ???
        #define BTN_EN2             -1  //->    /   ???
        #define BTN_ENC             -1  //->    /   ???
    #endif
#endif  // MOTHERBOARD == 85 (Teensy 3.1)

/********************************************************************************************************************************************************************************/
/****************************************************************************************/
 
Has anyone worked on porting the temperature code?

I haven't had any time for this project in the last 2 weeks, and with my focus on SPI transactions for the next several days, it may be another week until I can look at Marlin porting again.
 
I am stuck, because the ATX power supply doesn´t work. :-(

I did a first pin assignment ... on paper. Because i need two HCT245 and there is little space on the board, i may change some pins.
This is my current(!!!) definition for board 85 in pins.h:
Code:
/********************************************************************************************************************************************************************************/
/****************************************************************************************/

/*****************************************************************************************
*****************************************************************************************
* Teensy 3.1 Breadboard pin assignments (MK20DX256)
* Requires the Teensyduino software with Teensy 3.1 selected in Arduino IDE!
  http://www.pjrc.com/teensy/teensyduino.html
* CLI build: HARDWARE_MOTHERBOARD=85  make
* 
****************************************************************************************/
#if MOTHERBOARD == 85
    #define KNOWN_BOARD 1
    #define AT90USB 1286  // Disable MarlinSerial etc.

    #ifndef __MK20DX256__
        #error Oops!  Make sure you have 'Teensy 3.1' selected from the 'Tools -> Boards' menu.
    #endif

    #define LARGE_FLASH     true

    //  T31Ramps14 by aikx
    //  Pin-33: http://forum.pjrc.com/threads/24823-Teensy-3-1-Tying-Pin-33-(pta4)-low-freezes-teensy
    //  TODO: needs work here, to define pinout....
    //#define name              Pin T31 //->Pin Mega  /   IO-Type // comment

    // Serial 1
    #define T31_Serial_RX1          0   //->    /  DIN5V
    #define T31_Serial_TX1          1   //->    /  DOUT5V
    // T31 SPI port
    #define T31_SPI_CS              10  //->    /   SPI_CS_SD
    #define T31_SPI_MOSI            11  //->    /   SPI_MOSI
    #define T31_SPI_MISO            12  //->    /   SPI_MISO
    #define T31_SPI_SCK             13  //->    /   SPI_SCK
    // i2c interface 
    #define T31_I2C_SDA0            18  // D20 ->   /   i2c Port 0
    #define T31_I2C_SCL0            19  // D21 ->   /   i2c Port 0
    //--------------------------------------------------
    // ENABLE all stepper drivers
    #define STEP_ENABLE_PIN         2   //->38  DOUT5V

    #define X_STEP_PIN              3   // A0->54   /   DOUT5V
    #define X_DIR_PIN               4   // A1->55   /   DOUT5V  
    #define X_ENABLE_PIN            STEP_ENABLE_PIN //->38  /   DOUT5V
    #define X_MIN_PIN               4   //->3   /   DOUT5V
    #define X_MAX_PIN               -1  //->2   /   DOUT5V

    #ifdef DUAL_X_CARRIAGE
        // Pins for second x-carriage stepper driver ( from Configuration_adv.h)
        #define X2_STEP_PIN         4   //->    /   DOUT5V
        #define X2_DIR_PIN          5   //->    /   DOUT5V
        #define X2_ENABLE_PIN       STEP_ENABLE_PIN //->    /   DOUT5V
    #endif

    #define Y_STEP_PIN              6   //->60  /   DOUT5V
    #define Y_DIR_PIN               7   //->61  /   DOUT5V
    #define Y_ENABLE_PIN            STEP_ENABLE_PIN //->56  /   DOUT5V
    #define Y_MIN_PIN               4   //->14  /   DOUT5V
    #define Y_MAX_PIN               -1  //->15  /   DOUT5V

    #define Z_STEP_PIN              8   //->36  /   DOUT5V
    #define Z_DIR_PIN               9   //->34  /   DOUT5V
    #define Z_ENABLE_PIN            STEP_ENABLE_PIN //->30  /   DOUT5V
    #define Z_MIN_PIN               4   //->18  /   DOUT5V
    #define Z_MAX_PIN               -1  //->19  /   DOUT5V
      
    // these pins are defined in the SD library if building with SD support
    #ifndef SDSUPPORT
      #define CS_PIN                T31_SPI_CS      //->    /   SPI_CS_SD
      #define MOSI_PIN              T31_SPI_MOSI    //->    /   SPI_MOSI
      #define MISO_PIN              T31_SPI_MISO    //->    /   SPI_MISO
      #define SCK_PIN               T31_SPI_SCK     //->    /   SPI_SCK
    #endif

    // Extruder 0
    #define E0_STEP_PIN             14  //->26  /   DOUT5V
    #define E0_DIR_PIN              15  //->28  /   DOUT5V
    #define E0_ENABLE_PIN           STEP_ENABLE_PIN //->24  /   DOUT5V
    // Extruder 1
    #define E1_STEP_PIN             16  //->36  /   DOUT5V
    #define E1_DIR_PIN              17  //->34  /   DOUT5V
    #define E1_ENABLE_PIN           STEP_ENABLE_PIN //->30  /   DOUT5V

    // PWMs: Heater and fans
    #define HEATER_BED_PIN          20  //->    /   PWM5V   /   Bed
    #define HEATER_0_PIN            21  //->10  /   PWM5V   /   Extruder E0
    #define HEATER_1_PIN            22  //->9   /   PWM5V   /   Extruder E1
    #define FAN_PIN                 23  //->9   /   PWM5V   /   Fan

    // TODO: temperature.cpp still only AVR compatible - much ADC code
    #define TEMP_BED_PIN            A10 //->    /   AIN33V  /   Bed
    #define TEMP_0_PIN              A11 //->A13 /   AIN33V  /   Extruder 0
    #define TEMP_1_PIN              A12 //->A15 /   AIN33V  /   Extruder 1
    
    // SD 
    #define SDPOWER                 -1  //->-1  /   ??? /   
    #define SDCARDDETECT            -1  //->    /   ??? /           
    #define SDSS                    -1  //->25/53   /   DOUT33V

    #define LED_PIN                 -1  //->13  /   ???
    #define PS_ON_PIN               -1  //->12  /   ???
    #define KILL_PIN                -1  //->    /   ???
    #define ALARM_PIN               -1  //->    /   ???


    #ifdef ULTIPANEL
        #define LCD_PINS_RS         -1  //->    /   ???
        #define LCD_PINS_ENABLE     -1  //->    /   ???
        #define LCD_PINS_D4         -1  //->    /   ???
        #define LCD_PINS_D5         -1  //->    /   ???
        #define LCD_PINS_D6         -1  //->    /   ???
        #define LCD_PINS_D7         -1  //->    /   ???
        #define BTN_EN1             -1  //->    /   ???
        #define BTN_EN2             -1  //->    /   ???
        #define BTN_ENC             -1  //->    /   ???
    #endif
#endif  // MOTHERBOARD == 85 (Teensy 3.1)

/********************************************************************************************************************************************************************************/
/****************************************************************************************/

Thanks very much for the prompt responce. I'm waiting on my Oshpark 3.1 before
I can test (Hopefully they are supported by PJRC I have 2 teensy 3.0's from Paul).
I'm used to 5v logic, I forgot about level shifting thanks. Your using 2 HCT245 are
you using 1 for each direction?

Thanks much
Stan
 
Thanks very much for the prompt responce. I'm waiting on my Oshpark 3.1 before
I can test (Hopefully they are supported by PJRC I have 2 teensy 3.0's from Paul).
I'm used to 5v logic, I forgot about level shifting thanks. Your using 2 HCT245 are
you using 1 for each direction?
Stan
No Direction;-) Teensy 3.1 inputs are 5V compatible.
Only "DOUT5V" pins need level shifting.
 
Last edited:
Hey all, has anyone gotten any motors to move with Marlin and Teensy 3.1? The code compiled and I changed the pin assignments to match with my setup but the motors wouldn't move. I have basically a functional printer with Teacup and Teensy but I would like to get Marlin ported over to Teensy :)

EDIT: Just got the motors to work!! Now on to the temperature porting. Paul, have you had the chance to look at this again?
 
Last edited:
EDIT: Just got the motors to work!! Now on to the temperature porting.
Congratulation!
After getting a new power supply i decided to take the "modular" approach: a great controler-board holding a teensy 31 on beakoutboard, two stepperdriverboards (2x3max DRV8825), one PWM-board. Today i will test the first stepper.
My plan is to solder and test 3 stepperdriver and the endstops. Then join with the printer hardware and test the combined movements.
Next step solder and test the PWM-board.
 
Hi everyone :)

Hey all, has anyone gotten any motors to move with Marlin and Teensy 3.1? The code compiled and I changed the pin assignments to match with my setup but the motors wouldn't move. I have basically a functional printer with Teacup and Teensy but I would like to get Marlin ported over to Teensy :)

EDIT: Just got the motors to work!! Now on to the temperature porting. Paul, have you had the chance to look at this again?

I expect Paul has some ideas, but just in case he is busy, I can describe how I did it for the Due port of Marlin. I haven't looked into Teensy code much yet, but I would like to add Teensy3.1 support to it, currently I don't have the hardware but I have some on order.

In temperature.cpp the interrupt function ISR(TIMER0_COMPB_vect) needs to be called every millisecond. In the AVR version, this shares the millis() timer used by the Arduino core. In the Due version, I decided it was easier to allocate a new timer to call the temperature function. One of those methods should also apply to the Teensy version.

The other change required in the temperature ISR is the code to actually read ADC values, I took the easy route and just call analogRead().

There is code in tp_init() which initializes the AVR analog ports, and again I took an easy route and skipped that - the Arduino core will do the required initialization.

Hopefully next week I will get a Teensy and put some hardware together.
 
Last edited:
I expect Paul has some ideas, but just in case he is busy, I can describe how I did it for the Due port of Marlin. I haven't looked into Teensy code much yet, but I would like to add Teensy3.1 support to it...


That's awesome, thank you so much for your suggestions! I'll try them out and see if I can get the ADC stuff going for Teensy. Please let me know if you make any progress also!

I wonder if we can add on the what Paul already started:
(Paul, thanks for your help with this!)

BTW, I have attached the config file I used to get the motors moving.
 

Attachments

  • Configuration.h
    30.7 KB · Views: 320
Last edited:
My plan is to solder and test 3 stepperdriver and the endstops. Then join with the printer hardware and test the combined movements.
i finished testing hardware of stepperdriver-module with breadboard and my contollerboard.
Now the controller is connected with the endstop and (first) the x-axis motor of my felix-printer.

My problem: the motor doesn´t move with marlin, but moves fine with an AccelStepper based test programm!?

Any idea?

Additional: Sometimes it moves a little bit ( about one millimeter), but i cannot repeat this. Using arduino or repetier doesn´t make a difference.
 
Last edited:
Hey aikx, I actually had a very similar issue! Hmm let me see... here's what I tried that made it work... Since you are able to move the motors with AccelStepper, I am assuming your hardware setup is fine. At first, my stepper motors weren't moving because I didn't have the enable pin of the stepper driver grounded. How did you configure your AXIS_STEPS_PER_UNIT? Are you using microstepping with your stepper motors? These are the stepper drivers I am using: http://www.pololu.com/product/2128. If you scroll down to "Step (and microstep) size", it explains how to use microstepping. Once I added microstepping and adjusted my steps per unit, I was able to see the motors moving with Marlin. Good luck! Hope this works... let me know what happens!

Also, did you try moving the motors without any endstops?

Also, when you are using Repetier Host, is it recognizing Marlin as the firmware type in the printer information?

View attachment Configuration.h
View attachment pins.h

I have attached my config and pins files in case you wanted to compare them to yours.

On a side note... if I remember correctly, I thought you were able to get the motors moving awhile ago with marlin and teensy, no?
 
Last edited:
My problem: the motor doesn´t move with marlin, but moves fine with an AccelStepper based test programm!?

Any idea?

First send M119, it will show status of all your endstops, make sure that inverting(X_MIN_ENDSTOP_INVERTING) is set properly in config. After this you should get movement in at least one direction for each axis, then you can home an axis by ie. "G28 X0" for x, I recomend homing one axis at a time at first, chances are you have inverted some steppers direction or some endstop is not correctly plugged or something, so be prepared to pull out the plug... If you don't have "all" (3) endstops, you can try disabling "min_software_endstops" and "max_software_endstops" (set to false)..



I expect Paul has some ideas, but just in case he is busy, I can describe how I did it for the Due port of Marlin. I haven't looked into Teensy code much yet, but I would like to add Teensy3.1 support to it, currently I don't have the hardware but I have some on order.

Do you have any code we could test?
 
.... On a side note... if I remember correctly, I thought you were able to get the motors moving awhile ago with marlin and teensy, no?
Yes, forgot it! :mad:
I tried all board and stepper-driver combinations and found that DRV8825 makes the difference:
Code:
Key differences between the DRV8825 and A4988:
The timing requirements for minimum pulse durations on the STEP pin are different for the two drivers. With the DRV8825, the high and low STEP pulses must each be at least 1.9 us; they can be as short as 1 us when using the A4988.
So i went "back" to A4988!

1. Problem: Stepper driven by DRV8825 doesn´t step and rotate. But there are mini-movements and some noise inside! AccelStepper test worked! ->>Marlin on Teensy 31 generates too short pulse durations on the STEP pin! I cannot measure this.

See more discussion here and here!

Good message: I could test three MIN-Endstops, move X,Y,Z steppers using A4988 Stepper Motor Driver Carrier . They home with Repetier and i could test an gcode file (cold, no extrusion)!

2. Problem: The movements are very, very slow!
I used 16 microsteps same as ramps. Same definition of steps per unit as for felix 2.0. The measured movement is correct.
Is it possible, that the teensy timer is too slow? I found many hardware constants in stepper.cpp but don´t understand them....
Teensy runs 48 or 72 MHz, no difference.

my configuration.h :View attachment 2645 and pins.h:View attachment 2646

Baseboard with teensy 3.1 on breakoutboard:
p20140905_164212_001.jpg

Baseboard with first stepper-driver-modul
p20140905_164032_001.jpg
 
Last edited:
Hi,

When I tried to compile it for Teensy 3.1, I got the following error:


Arduino: 1.0.6 + Td: 1.20 (Windows 7), Board: "Teensy 3.1"
stepper.cpp: In function 'void st_wake_up()':
stepper.cpp:262: error: 'ENABLE_STEPPER_DRIVER_INTERRUPT' was not declared in this scope
stepper.cpp: In function 'void trapezoid_generator_reset()':
stepper.cpp:323: error: 'OCR1A' was not declared in this scope
stepper.cpp: At global scope:
stepper.cpp:339: error: expected constructor, destructor, or type conversion before '(' token

Please help;)
 
Last edited:
I have an Ultibots K250VS delta printer that I would love to control with the Teensy 3.1 and RAMPS 1.4.

Teacup currently does not support delta printers, but is working with Teensy 3.1. Marlin and Repetier do support delta printers, but are not known to be working with Teensy 3.1 (please let me know if I am wrong!).

Would it be preferable to spend the time adding delta support to Teacup, or finish porting Marlin to Teensy 3.1?
 
After giving it some consideration (research), I think I would rather work on porting Marlin to Teensy 3.1 rather than add delta support to Teacup. Others seems to be working on the delta support for Teacup.

I have a spare Teensy 3.1 and Ramps 1.4 on the way so I will have dedicated hardware that I can swap into my 3D printer for testing.

I got Paul's Marlin to compile by changing line 181 of stepper.cpp from:

Code:
#elif defined(__arm__) && defined(IRQ_FTM2)

to

Code:
#elif defined(__arm__)  && defined(__MK20DX256__)

Further porting and testing when the spares arrive...
 
After giving it some consideration (research), I think I would rather work on porting Marlin to Teensy 3.1 rather than add delta support to Teacup. Others seems to be working on the delta support for Teacup.
Smoothie (http://smoothieware.org) already has delta support, is designed specifically for ARM chips, and has a MUCH cleaner and easier-to-maintain codebase than either the Marlin or Repetier firmware. It's a pleasure to work on, which I know from spending hundreds of hours writing an auto-calibration routine for delta printers. Right now it only works on LPC17xx chips, but porting it wouldn't be that hard. You'd just need to get the right toolchain and adjust any CPU-specific features to use different register names, or whatever.

The one drawback is that if you want to save any settings, you need an SD card. Otherwise, you have to edit hard-coded default values in the firmware (which you already have to do a lot of with Marlin and a little of with Repetier). If you do get an SD card, it'll show up on your computer as a removable drive, so you can edit the config and drop .gcode files directly from your computer. It's pretty nice.

The reason I'd choose this over Marlin is that it's designed to work with CPUs that aren't ancient, terrible and laughably overpriced (AVR series), and that the logical structure of the program is properly organized into classes and subdirectories, whereas Marlin and Repetier firmware are "a big row of tabs, and each tab is full of spaghetti." Smoothie hasn't been shoehorned to run on 1980-class crap with no more than 4K of RAM. In fact, the Teensy's processor is even a better fit than the LPC series they use on the Smoothieboard, as it has twice the RAM (64K!)
 
Last edited:
Teensy 3D Printer

Your board looks very interesting. Are you targeting a particular firmware?

Yeah, I really like marlin. Aside from the predisposition towards atmega chips I really like the firmware and want to get it working with a teensy. Its basically a RAMBo board with the main chips swapped. I also changed some of the packages for ones that are easier to hand solder. Do to the limited pins on the teensy I moved all the stepper enable pins to an I2C GPIO expansion chip. I also left the SPI digital pot for the motor currents, I really like that feature.
 
Michael,
your board looks great I would suggest to add two things not available elsewhere:
- Place for two more stepper motors to drive four extruders, so it is possible to use E3D Kraken or to do something like the color mixing demonstrated here
- The possibility to use at least one Thermocouple instead of Thermistors, to print materials like PEEK above 290degC
 
Status
Not open for further replies.
Back
Top