Search This Blog

Saturday, 7 March 2015

Repscrap: DC Motor Control for X-Y working - now to Teacup_Firmware

I am quite happy with my results in getting the Xaxis and Yaxis PID control working Trudy's Quadrature Decoder for the Freescale Kinetis K20 (K20DX256-72MHz) used in the Teensy 3.1.
A big thank you to Miguel Sanchez for his help and inspiration.

Here's a video snip of a quick demo showing the tuned X and Y carriages tracing out a simple 1500x1500 square. The purpose of this demo was to simply allow me to tune the PID parameters for each axis.

I'm currently torn between two separate development  tracks.  The first track is using the Beta6 version of the PID library, cascading Velocity and Position, and defining velocity profiles for each axis.  I've had a fair bit of success in this track, and will publish code and results in a few weeks.  

However, the main track I'm following currently is to get my DC motor control on the Teensy 3.1, working within Teacup_firmware.  For expedience and simplicity, this forces me to emulate a stepper at the moment, passing STEP/DIR commands from Teacup into my motor drive logic.  The reason for splitting the tracks is that the cascaded PID control does not function well in small encoder increments.  Ramp time in the Velocity PID is calculated from position delta... blah blah blah.. 

My Teacup inspiration came from Nikki V's awesome blog series  in when she builds a Teensy 3.1/RAMPS based 3D printer controller over the course of about a month.  I highly suggest you go read through it.

Anyway.... I have had some difficulty (my own lack of awareness) in getting Teacup compiled properly on Ubuntu 14.10 for the Teensy.   Yesterday, I opened issue #122 and was answered within hours!

I'm currently using the newest teensy3 folder from Paul Stoffregen's git repo https://github.com/PaulStoffregen/cores

Dave "drf5n" answered my logged issue, and set me straight.  (It also looks like he's working on Marlin... I should ask him about that..)

I backed up and then removed the version of Teacup_firmware I was currently working from, then issued:

git clone https://github.com/Traumflug/Teacup_Firmware.git && cd Teacup_Firmware
 
After downloading and changing to the directory, I checked out the teensy3 branch:

git co teensy3
 
Then, again carefully following instructions, updated the correct files in the folder to reflect the Teensy hardware.  The makefile also needs to be modified to point to your ARM toolchain and link to the above mentioned Teensy Core library.

$ cp config.teensy3.h config.h
$ cp ThermistorTable.single.h ThermistorTable.h
$ cp Makefile-teensy3 Makefile
$ make
 
Aaaaaaand..... Success!   Compiled! 


Tonight's plan is to modify the config.teensy3.h file to properly reflect the Teensy pinouts for the hardware configuration I have built. 


 
  



References:

https://community.freescale.com/thread/320695
http://reprap.org/wiki/Teacup_Firmware
https://github.com/Traumflug/Teacup_Firmware
https://github.com/Traumflug/Teacup_Firmware/issues/122

http://www.idt.mdh.se/kurser/ct3340/ht09/ADMINISTRATION/IRCSE09-submissions/ircse09_submission_22.pdf