Search This Blog

Showing posts with label kinetis. Show all posts
Showing posts with label kinetis. Show all posts

Friday, 17 April 2015

PlatformIO - A Cross-Platform Code Builder and Missing Library Manager

I ran across this awesome site a couple weeks ago, and was astounded by their claims.  I had to try it out!

In a nutshell, PlatformIO has automated the various build aspects of cross compiling for your favorite Microcontroller across Mac OS X, Windows, and Linux, both on Intel as well as ARM (Meaning you can run PlatformIO on your Raspberry PI, or Beagle Board!)   

Basically, you can write your embedded code once, and compile across several target boards with very little additional work.

PlatformIO for each Operating system includes compiler, debugger, uploader (for embedded) and a bunch of useful tools. Popular settings for most popular Embedded Platform Boards are pre-configured out of the box.

To date, PlatformIO out-of-the-box support includes:



And of Special NotePlatformIO.org has worked with the guys that developed the Teensy 3.1 board to include it in their supported systems.  I make note of this, as the Teensy does use the Freescale Kinetis K20dx256 32bit ARM cortex-4 MCU, but they have simply made this board more readily available to work with.  (I also have a vested interest in this board!) 


Once installed, you can get a list of the 60 or more supported boards by typing “platformio boards” ...


 It's really as simple as installing PlatformIO onto your Laptop, Desktop, or Single board Computer (Raspberry Pi, BeagleBone, etc...), and choosing your target Embedded System to develop for. 

You Install PlatformIO itself, then invoke it to install the toolsets and libraries for your preferred board/processor,
something akin to  "platformio install freescalekinetis"  and it pulls down all of the cross compiler tools, and kinetis core libraries.

You then initiate a project with "platformio init -bteensy31".  It creates the directory structure, and you are free to use your favorite editor/IDE to write the code. 

No... this is not Visual Studio / Programming-with-your-mouse tool, but it DOES take care of a lot of the planning, configuration, build, and upload issues for you.

Once you have written your code, again invoking PlatformIO to build and upload is a simple process..  "platformio  run -t upload"... 




PlatformIO Library Manager allows you to organize external libraries. Searching for new libraries can be via commandline or Web Interfaces.  Python code in the background takes care of the rest.  Think of this as a package manager for your embedded libraries.










My fellow Teensy developers... If you feel constrained by the limitations of the  Arduino IDE (even though they did such an awesome job extending it with Teensyduino) And you are not up to the complexity of a full fledged bloated developer suite.. Please do yourself the favor, and try out PlatformIO.


References:

PlatformIO.org 
Cross-board and cross-vendor embedded development with PlatformIO 
Discovered a new tool for embedded development: PlatformIO 
Integration of PlatformIO library manager to Arduino and Energia IDEs
Building and debugging Atmel AVR (Arduino-based) project using Eclipse IDE+PlatformIO

Wednesday, 8 April 2015

Marlin Firmware on Teensy 3.1 - Analog Temperature success!

I've successfully replaced the Analog functions in Marlin's temperature.cpp, with calls to Pedro Villanueva's ADC library for the Teensy 3.1, and am getting good temperature readings out of it.

Here's a couple shots from Repetier Host. 








Now on to updating the PID functions for the heaters...

This is looking quite doable my friends!


My Previous blogs on this project:
(little did I know I'd be working on this on and off for a year... and the real work is just beginning)






Wednesday, 1 April 2015

Repetier successfully connected and functional with Marlin Firmware on Teensy 3.1

 I've had a few informative back and forth emails with Nikki V from Freescale regarding my failure to get connected to Repetier Host from the Marlin Firmware on my Teensy 3.1.  

(Here's a link to Nikki's 3D printer blog: https://community.freescale.com/grou...on-rampsmarlin)

As mentioned in my previous article, I was finally able to compile and install the Marlin Firmware when I used the fork that Paul Stoffregen started, along with Nikki's Configuration.h and pins.h files. However, I could not connect to the firmware with Repetier.   

Marlin was sending the appropriate communications out through the USB serial port, as evidenced by this screenshot: 

But the Repetier connect request was not initializing Marlin, and returning the printer information.



Nikki pointed me back to the same thread on the Teensy Forum that I've already read 100 times... 

Yeah... but I'm apparently blind or ignorant... or both...

She brought my attention to the fact that this issue has already been identified, and could be remediated  by clicking a "fake OK" button from within the Manual control page.
I couldn't find the "Fake OK" button, so I read a little deeper.

And then Paul chimed in with a comment about compiling on Linux, and it all came together... Thank you Nikki, Thank you Paul.

Here's what Paul had to say that made all the difference: 

I tried the Linux version. It also has only "OK", not "Fake OK", but it seems to work fine.
I had to edit the baud rate to 57600 in Configuration.h. The Linux driver doesn't seem to like 250000 (even though Teensy 3.1 complete ignores the baud rate).

Repetier-Host does seem to be getting hung up on something and requires the "OK" button clicked. I believe it's due to the missing temperature feature. The blue bar will stay stuck as "1 Command Waiting". Clicking "OK" gets it unstuck.



I set the baudrate in configuration.h to 57600, and recompiled and uploaded to the Teensy 3.1.  I then launched Repetier, and went into the printer configuration, and selected 57600.



I applied, saved, and hit "Connect" .....

And Voila!

 


 Marlin Firmware now connects, and provides printer information. 


As of today, I have hard wired in 100k thermistors for Extruder and Bed heater temperature sensing, and set the pullup resistors for the endstops...

The Quadrature encoders are functioning on X and Y axis via the Flextimer module QuadDecode library, and *MY* PID routines (using the Arduino PID library)  are successfully driving both X and Y axis DC motors from the manual controls in Repetier.

The Quadrature encoders are functioning on Z axis with Phase A/B hardware pin interrupts , and *MY* PID routines  are successfully driving one Z axis DC motors from the manual controls in Repetier.

I have a functional I2C 20x4 LCD display, as well as SDcard reader.

As far as capacity on the Teensy, here is the size of code  - all in - so far:
From the Arduino IDE:
Binary sketch size: 108,816 bytes (of a 262,144 byte maximum)
Estimated memory use: 14,080 bytes (of a 65,536 byte maximum)

Is it running... sure... is it printing... no... my budget hasn't allowed me the pleasure of a real extruder. I'm simply stepping a NEMA17 I had kicking around.    I keep saying "next paycheck!"


TODO:


  1. Acquire a real extruder/hotend  (today I'm simply driving a NEMA17 that I had kicking around.)   (anyone want to help??  LOL)
  2. Wire up FET transistors to drive extruder and bed heater elements
  3. Wire up endstops 
  4. Lots and lots and lots of PID tuning.  Things have changed since porting/merging my DC motor code into the Marlin Firmware.
  5. Take video this weekend and upload to Youtube!  LOL 
  6. Remove MY PID routines, and create macro/wrapper to use existing Marlin PID routines meant for temperature management.
  7. Put "conditional" code back in so I can merge this stuff back to github
  8. Figure out how to merge stuff back to github 
  9. figure out whether 7. or 8. should come first...

Sunday, 28 December 2014

Prototype Board: DC motor/Encoder - Teensy 3.1 based 3D printer controller

This will be a short post today.  

I had mentioned putting up pictures as I go along, so I took this to show the first prototype of the controller board.

Here is the layout of my Teensy 3.1 based 3D printer controller.


As of this shot, I have not yet wired it.  Nor have I installed the analog components (power supply, heater drivers, pullup resistors, filter capacitors, etc...).  It is also missing the connector for the extruder stepper motor. 

As I described in my previous post, my motor control design is based on Adafruit's Motor Shield V2.3.  For my prototype... well... I'm using their shield, pilfered from one of my older robots. This fantastic design employs an NXP PCA9865 16 channel 12 bit PWM controller, intended to drive LEDs, but instead to  driving a pair of dual Mosfet H bridge TB6612FNG motor drivers.

The Library for this Shield works with the Teensy 3.1 just fine. (It is just I2C after all).

Ok... I'm off to wire this up... wish me luck.
 





 



Thursday, 21 August 2014

Running Kinetis Design Studio (32bit Eclipse) on 64bit Ubuntu



YAY!!!!  I got it working!  

Back in the end of May, I enrolled in the beta for Kinetis Design Studio installer for Linux to allow me to develop on my Teensy 3.1 bare-metal,
only to find that it would not run on my Ubuntu 14.04 64bit.  I'm running Oracle Java 7


Kinetis Design Studio installed properly from DEB, but when I launched it, it immediately complained that it could not load the SWT library for Eclipse.  It turns out that they built the Debian (Ubuntu) base on 32bit Eclipse.  

After some futzing around, I opened a case with Freescale Support: (putting the details here for search engine assistance)
SR Number: 1-2152355207Date Opened: 07/28/2014 05:28:35 PHX timeSubject: kinetis-design-studio will not load in Ubuntu 14.04Description: Fresh install of Ubuntu 14.04uname -aLinux ballmik-Satellite-L305 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Running Oracle Java java version "1.7.0_65"Java(TM) SE Runtime Environment (build 1.7.0_65-b17)Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

Eclipse appears to be built for 32bit platform. is the a 64bit version ?attaching eclipse log.
Thank you.
!ENTRY org.eclipse.osgi 4 0 2014-07-28 08:06:23.472!MESSAGE Application error!STACK 1java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: /home/ballmik/.eclipse/org.eclipse.platform_4.3.2_870091379_linux_gtk_x86/configuration/org.eclipse.osgi/bundles/430/1/.cp/libswt-pi-gtk-4335.so: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directoryno swt-pi-gtk in java.library.path/home/ballmik/.swt/lib/linux/x86/libswt-pi-gtk-4335.so: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directoryCan't load library: /home/ballmik/.swt/lib/linux/x86/libswt-pi-gtk.so


Their quick response was that the DEB was built on/for Ubuntu 12.04LTS 32bit.... 

Not helpful...  So...  life got in the way, and I finally returned to this last night.  With fresh eyes, I simply searched G00gle for "running 32 bit eclipse on 64 bit Ubuntu 14.04"  and came up with a bunch of different solutions. 


The issue is that in 64bit Ubuntu base install, the 32bit libraries are not installed.  period.

Prior to Ubuntu 14.04, you used to be able to "sudu apt-get install ia32-libs", but they removed this ability recently because dpkg now has multi-arch enabled by default. MEANING, that if you actually knew what libraries were failing, you could reinstall them with a :i386 at the end of the package name.  Seemed like a lot of work to find the specific libraries... 


Here's what worked for me.
(from Stackoverflow: How to install ia32-libs in ubuntu 14.04 LTS)

sudo -i
cd /etc/apt/sources.list.d
echo "deb http://old-releases.ubuntu.com/ubuntu/ raring main restricted universe multiverse" >ia32-libs-raring.list
apt-get update
apt-get install ia32-libs



Reboot, and voila! Kinetis Design Studio is now working!


Now, on to figuring out how to code for the Teensy 3.1...



Resources:

Freescale: Kinetis Design Studio
Ubuntu.com: Multiarch
Stackoverflow: How to install ia32-libs in ubuntu 14.04 LTS
Teensy 3.1 Bare-Metal