Wednesday 17 December 2014

How to build Yocto RT for Minnowboard Max Drone



Before you begin, it good idea to read through Yocto getting started guide.  And we assume you are using Ubuntu.

How to build Yocto for Minnowboard Max drone:

1) Install require tool/software for Yocto build:
 


sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm

2) Download Yocto and meta-intel:



mkdir maxdrone
cd maxdrone
cd poky
git clone git://git.yoctoproject.org/meta-intel


3) Setup build directory

cd ..
source poky/oe-init-build-env mybuild
  
 4) Add meta-intel path to  bblayers.conf

vi conf/bblayers.conf

add “/home/<user>/maxdrone/poky/meta-intel \”to BBLAYER section like below:



5) Add platform,  RT and Linux version to local.config.



vi conf/local.conf

And add this line to the end of the file:

MACHINE ?= "intel-corei7-64"
PREFERRED_VERSION_linux-yocto = "3.14%"
PREFERRED_PROVIDER_virtual/kernel = "linux-yocto-rt"

      6) Create local Linux kernel for Kernel or driver customization (skip if not build for debug):



bitbake linux-yocto -c kernel_configme -f
bitbake linux-yocto -c menuconfig

You will see a menu like this, make sure you save and then exit if you are making change to the configuration.




7) Build the image, we use sato sdk.  Other image like “core-image-sato” if you are done with development.  Also if you want build with yoction image with UI interface, try “hop” command instead of "bitbake".


bitbake core-image-sato-sdk



8)      Once the OS image is build, it will be store in <Build Dir>/ tmp/deploy/images/intel-corei7-64, and we use dd to write to USB drive.  You can use df to quickly search for the usb drive located, our case, it at /dev/sdc.



Then use DD to write to USB drive:

sudo dd if= core-image-sato-sdk-intel-corei7-64.hddimg   of=/dev/sdc

Wait until the light on the USB drive stop blinking.  Now you have a Yocto RT USB drive. 

Have fun.

Tuesday 9 December 2014

Kicad on Win7

Recently I created a PCB for the drone project that I'm working on and I would like to share my experience with Kicad for PCB creation.


Above is the finish PCB design that I send for fabrication this afternoon, will post the PCB photo once I got my PCB back from China, hopefully by next week.


First, you need to download the kicad for window,  I use this version from:

http://kicad.nosoftware.cz/

The latest build I can find on net is default stable version is 2013, which does not have the latest interactive routing.  I wish they could update the stable version to late 2014 build..

Just download from the latest version.  I found it to be really stable, no crash so far (after I fix the really annoying PCB footprint library)


Once you install kicad on window, you should copy the PCB footprint library to local disk, default is getting the library from github, which is really slow, and some time cause crash (I think someone fix the github path crash issues, it use to point to some path that is no longer exist).

There is python script that will download all the github library to local disk. But the posted version seem to be have error in it, will post my version later.  You can read about the frustration of using the footprint library here

Basically, you need to download all the footprint library to local disk, here is the step
  1. Download library using git from python script. (script to be send out later, make sure you install git and python in your PC)
  2. Copy fp-lib-table.for-pretty from C:\KiCad\share\template to C:\Users\<user>\AppData\Roaming\kicad as fp-lib-table
  3.  create or update runkicad.bat with  KISYSMOD to local disk. SET KISYSMOD=C:\kicadlib\kicad\share\github-repo <your local area>

Now you need to start kicad with the bat file, so that it will point to the local library.

Kicad schematic editing is really easy, just open a new project start creating.  Here is example of my drone schematic.


Just place and round the schematic, and sometime you may need to design your schematic symbol, which also very easy in kicad. the library editor is really easy to use too, just open an existing symbol, make change and save as your new symbol.


Once you are done with schematic design, the next stage is to create netlist for PCB as well as assigning footprint, it done using another tool call CvPCB.



Once you are done with footprint assignment, you move to PCB design.   We base our board design base on MinnowBoard Max lure.  you can import the board outline easily, and the Minnowvoard Max board design file is freely downloadable. (pointer to be update later)

Before start editing in PCB, you need to set few more thing, one is the PCB design rule, you need to review you PCB manufacture design rule and update you kicad design rules accordingly.   Normally they display the rule at front of the order page, here is the example PCB  rule found on ebay:

Here is where you set the rule in kicad (Design Rules --> Global Design Rules):




Also you may want to create wide wire for power or some net that need wide track, it better to do this before starting routing, else you need to use "change segment/track width" canvas pulldown menu to change the wire width.

To create wide wire, go to Design Rules --> Net Class Editor.  First by adding a new net classes in the window, then select the newly create net class in the pull down menu on the right of membership. You just add and remove the net from the net class.   



OK.  Once you are done with the design, you need to generate and send the gerber to PCB manufacture for review and quote.   Normally they will comeback with some request if there is problem.  Below is our gerber output setting that our PCB manufacture requested after some feedback from them.  Our board is 2 layer design:




Also you will generate a drill file as well, and here is our setting:

 

 As always, you should review your gerber file before sending for fabrication. Any mistake will be costly.  Here is our final design view in gerber file viewer provided by kicad.





This my quick update on how to setup and use kicad on window platform.  Hope you enjoy it..


Saturday 26 April 2014

BeagleBone Black Linuxcnc with RAMPS 1.4 (part 1)

Recently I saw a news about using BBB connect to RAMPS-FD with LinuxCNC,  But problem is the RAMPS-FD is  still expensive compare to RAMPS 1.4.   I say to myself, why not just use RAMPS?


The first thing I do is to look for way to make RAMPS compatible with 3.3v (not sure why I did it, seem like BBB does have 5v tolerance).  There is a detail discussion on how to convert 5v version of RAMPS to 3.3v for Arduino DUE in the Deltabot forum, it very simple hack, basically remove 5v connection from the RAMPS board, and reconnect all of the to 3.3v, then replace the MOSFET that support 5V to 3V input.   Detail of modification could be found here.

I did some cost cutting by replacing PSMN1R1-30L with IRLB8743PBF, it $3.5 vs $1.20, else everything is the same as discuss in the forum. Here is the picture where I remove the MOSFET:


The problem is how to connect BBB to RAMPS, the original design is to RAMPS-FD, and try find a diagram that show the pinout of RAMPS connection to Mega, and I can't!!  It seem like there is no pinout information.  After a lot of googling.... I give up and create the diagram myself.


With that. all I have to do to connect the board with BBB, which I will update in my part 2 of my BBB to RAMPS 1.4 adventure.  Here is the finish board waiting to be connected.



Sunday 6 April 2014

How to get EusLisp compile in Macosx

I was reading about robotic IDE and found this very interesting Japanese robotic development environment call EusLisp.  As usual I just want to play with it.  But it not easy to find information on how to install, seem like it not really popular outside of Japan.



OK.  Here is the step to get it compile:

1) Download the file:

  •      I use this command to get the file from svn, and it base on Trunk R671:
     svn checkout svn://svn.code.sf.net/p/euslisp/code/trunk euslisp-code     
  •      then cd to the lisp directory once it finish downloading:
     cd euslisp-code/EusLisp

     You can checkout the README file included in lisp directory for detail on how to install.. or continue with my description...

2) Setup make/compile environment variable:

  •     In the terminal.  Type in this in the terminal, make sure you are in csh (type csh in terminal to make it c-shell).

   setenv MACHINE x86_64   
   setenv EUSDIR $PWD
   setenv XLIB /usr/X11R6/lib
   setenv PUBBINDIR /usr/local/bin
   cd lisp

3) Edit the makefile and compile file for MacOSX:


  • First link the Makefile.Darwin to Makefile:

    ln -s Makefile.Darwin Makefile
  • update X11 library path to Mac path, I use vi to replace path:
    vi Makefile.Darwin
  • Inside VI run this command to replace the X11 path, original file point to /opt/X11 but in Mac, it in /usr/X11R6:
    :%s/\/opt\/X11/\/usr\/X11R6/g
    :wq
  • Next fix the wrong compile flag in comp/comp.l, it should be -falign-functions but instead it set to -malign-functions :
    vi comp/comp.l

  • Inside VI run this command to replace the error flag:

    :%s/-malign-functions/-falign-functions/g
    :wq

4) Build
    
     make all

Now you can try the build by running this command:

$EUSDIR/Darwin/bin/eusgl


If run successful, you will see this screen in you terminal.



JSK EusLisp have better demo, and the step to fix the build problem is the same.  Include is the JSK EusLisp demo:

Particle Demo




IRT Viewer Demo
Hand Grasp IK Demo



Saturday 1 March 2014

How to install MachineKit BeagleBone LinuxCNC in MacOSX

Recently I wanted to use Beaglebone black for my Chinese CNC 3040 router, trying to installing it is bit complicated.  Here is my learning....

You will not able to use MachinceKit directly because the setup_sdcard.sh script only work on linux. So the first thing you need it todo is to install VMWare.   Once you have the VMware install, you need to install Ubuntu.

Make sure you share your work area in mac to VMWare using the Sharing feature in setting:


Once you share your mac directory to vmware, the director will be located at /mnt/hgfs/<name of directory you share>.

You can't build the image and write to it directly. You need to create the image file in vmware, then write the image to the sdcard manually.

Here is the command I use to create the image file, please note that you need to use the --img-4gb option, the default is 2gb and will not be enough to hold all the file.

sudo ./setup_sdcard.sh  --uboot bone_dtb --img-4gb kk.img

depend on your ubuntu build, you may need to download other program, please read the screen for error message and see if you need to install more program.

Once your image is build, go back to terminal in mac and follow the step to install OS image to usb drive.

Here is my step, please know your location may be difference.


  1. use  df -h to location your usb drive, my usb drive is located at /dev/disk2s1
  2. unmount the usb drive using sudo diskutil unmount /dev/disk2s1
  3. use sudo dd bs=1m if=./kk-4gb.img of=/dev/rdisk2 to write the image to usb drive

Once you done writing the file to usb drive, you will need install the file to beagle bone black, the process of writing and updating beagle bone black take some time.  You will know you are success when you login to your update BBB and see 3.8.13xenomai-bone33 in the login message. 



Or you can run BBB as standalone machine:



Sunday 23 February 2014

What is this 3D slicer program? - Part 2

My favorite slicer program is Slic3r, it have one unique feature that other don't have, ability to set honeycomb fill pattern, it really a strong and beautiful structure.   Here is picture of the pattern.


There is also one other feature that you may want to turn on is the brim feature, it the extra printed line at boundary object you are printing.  The main purpose is to extrude the first few inch of plastic so that it have a better consistency when printing actual object. See the picture below:




 Let get start on how to setup you slic3r, first you need to download the program from here.

 Once you download the software and run it, you will see setup screen:


Next is to select the Firmware type, if you using the diy reprap, it should be "RepRap (Marlin/Sprinter/Repetier)" unless you use other firmware.


Next is to set the print bed size.   Normal is 8"by 8" or 200 by 200mm.


Next is to set the Nozzle diameter, for my case, I use 0.35mm.  Make sure you are setting to the right number.


Next is to set the filament Diameter. it either 1.75mm or 3mm.


Next is Extrusion Temperature.   You may need to play with this number later on.  I use 240c for ABS.   Note that this may melt your hotend if you are not careful.   Buy full metal hotend if possible. J-head is just too much pain if you using ABS.


Next is to setup the heat bed temperature.   I use 100c for ABS, but sure to use Kapton tape so that it help part stick well to the bed.   Will go into detail in one of my future post.  


You have setup your printer!!


Once you have it setup, you can drag a object to your work area.  It just have the outline of area use in the printer and to see the model in 3d, just click on the View panel.




Will go through the detail setting in my next update, for now, I'm going to show you where you set the print fill structure setting.  Goto "Print Settings" --> Infill --> Fill pattern, select "honeycomb"



And for the brim, goto "Print Setting" --> "Skirt and brim" --> "Brim width".  Just use 2mm.


I hope you like this work through, next I will go into more detail on each of the options using in slic3r.

Thursday 13 February 2014

What is this 3D slicer program? - Part 1

3D printer firmware is software that control the hardware to create the print, and it mainly GCODE interpreter.   You generate the GCODE by using Slicer program.  Slicer convert 3D object into instruction or GCODE on how to create the object using you printer hardware.

Most common use slicer is:
I never able to get Skeinforge to work on my Mac System, so I'm not the right person to discuss about  it.  When I got started 2010, the only slicer is that are free and commonly use is Slic3r. At that time, I also able to compile Cura for viewing, never really try to use it for production work.  I start to play with KISSlicer when I got started to build delta printer.  Kossel provided KISSlicer configuration file, it make setup much simpler.

Unfortunately it will be a long discussion, and I just finish capture the screenshot, may not be able to finish the post today.  Tomorrow will talk about Slic3r setup and configuration.



Wednesday 12 February 2014

What this 3D printer motor thing?

There is two main type of motor use in 3D printer, servo motor and stepper motor, servo motor is less common because of it higher cost, and servo also consider a close-loop solution, e.g, it know if current location hence better quality.

I'm not going to detail about servo motor, you can get more detail from wiki, as for stepper motor, you just need to know few key property:

Step angle is the single step rotation angle, most type version is 1.8 degree per full step, 200 per revolution.

Micro stepping is the subdivision of the single step, and typical stepper controller support up to 1/16 step, 1/32 is less common, Higher micro step increase the resolution of the printer.

Bipolar or Unipolar is the way the motor is configure.  Below is bipolar internal wiring.


And here is the internal wiring for unipolar.  Unipolar motor can become Bipolar.  typical stepper motor have 4, 6 or 8 wire, 5 wire are less common and require separate controller then the normal version.



Motor size is set by the NEMA standard, the most common size is NEMA17, next is holding torque or holding force of the motor, Z, Y and Z normally require 13.7N-cm/19.4 ozf.in and for gear extruder require 40 N.cm, recently we are seeing increase use gear stepper motor for extruder.

For the most optimize micro stepping, choose motor that have voltage range of 3-5v and current range of 1-1.15A.  It this true for stepper controller that have current-limiting feature such as Pololu A4988.

Shaft size typically 0.5mm diameter.  Make sure you get the correct pulley with the right bore size.

Motor Controller chip provide the control to set the direction and step, it normally allow user to control of the stepping rotation resolution such as full, half, 4th, 8th, 16th and 32 step.  higher the step higher the resolution.    Another thing to take note is the output current, higher the current mean you can drive a bigger motor.

There is a trip-pot allow you to set the desire current.  If you building printer from parts, make sure you check the motor current is setup correctly, test the perfomance of your motor by check if it too running too hot then it maybe over current, also if when you try to hold the rotation of the motor shaft and it skip step, it maybe under current, both case you need to adjust the power using the trip-pot. Be careful not to short the circuit during adjust, else you may burn the controller.

Also in the firmware configuration.h, there a are that section that the step per unit .  You need to adjust this part when you have the correct pulley and stepping.


Tuesday 11 February 2014

What this 3D printer controller board?

Every 3D printer require a controller,  either it a dedicated microcontroller board such as Arduino and Arduino derivative board or your PC.  The main purpose of the 3D printer controller is run software that convert Gcode to electronic signal that drive stepper motor or the control plastic extruder.  Think it as a command interpreter.

Here is the key component of a typical 3D controller board:

  • Computer or microcontroller that run the printer control software, normally this software is call printer firmware.
  • Motor control board for 3D location and extruders.  if you have have more the one extruders then you may need more controller board.  
  • Temperature Sensor for the extruder and heat bed.
  • SDCard support for printing file storing and retrieving.
  • Power on/off switching for Heating as well as fan.
  • X, Y and Z end-stop to tell the software where the printer head is located at start.



Above diagram show an typical arrangement how the part is connected to the controller.  Sensor like temperature is read using A2D (analog to digital convertor).  Normally the heat sensor use is Thermistor, need to be careful on which thermistor you are using, difference thermistor have difference temperature table.  Make sure you are setting the correct table in your firmware configuration file, else you may overheat or underheat you extruder due to wrong temperature reading.  It the most common mistake make by a new builder.

Heating element like resistor, nichrome wire and recently cartridge heater is driven by the microcontroller PWM signal, PWM is very common method of controlling the amount power to a load without incurring losses. Think of it as a method to control temperature and typically the PWM signal is connected to a MOSFET device that act as switch that connect the heating element to the main supply. e.g.12v or 24v, so that it can drive with full power from the main.  Controller also run PID routine for better temperature stability.  There also have a Gcode to help you tune your extruder.

GPIO is use for taking input signal from the X Y and Z start location switch, and to send control signal to motor controller.   Will have a dedicator discussion on the motor controller and motor itself, since it very importance subject that need more clarification.   Your print quality is depended on you motor!!! So be really careful on you Motor configuration.

I leave out feature such as networking and SDcard support, both very nice to feature but really needed for typical operation.







Monday 10 February 2014

What is this I2C PWM breakout board?

In one of my project, I needed more PWM output for servo control, but the board I'm using only have 2 PWM output, which mean I have two choice, either use a software base PWM (slow) or external PWM chip, I decided to go with external chip.

And the most common DIY I2C PWM chip is PCA9685 or TKC5940, and because PCA9685 is have free running feature (does not require constants update from micro microcontroller or CPU), we are going with this chip. 

You can buy prebuilt board such as Adafruit 16-Channel 12-bit PWM/Servo Driver.  But it cost over $15USD and mail to Malaysia will added few more dollar.  And because I such a cheapskate, I wanted to see how can I do to reduce the cost and also not spending a lot of time building my own PCB. 

First is to check if I can buy this chip locally, and Farnell/Element14 does carry them, and it about 9.42RM/2.49USD. Which I think is very reasonably price.

Second thing I do is to see if there is a TSSOP to DIP conversion board, if I can convert the pins to DIP, it make everything simpler, since I can build my own breadboard.  And ebay is your friend, I found 5 pieces TSSOP to DIP28 for $1.66 and free shipping.  Also got myself 50pin Gold plated male pin for $0.25USD.


For cost of $3.33, I have all the needed part, yes, it not as nice as the Adafruit I2C PWM board, but for 1/5 of the cost, I can live with that.

One of the main concern is how the hell are we going to solder TSSOP tiny pins? it so small, the fact is, it really easy to solder them, the trick is to solder all the pins at once and then clean it up later.

Here is the step:

  • Hold down the part to be solder, I used glue.


  • Next is to align the pins, you need a magnifier glass for this.
  • Add solder to the pins, short is ok, will clean up later.

  • Try to remove the excess solder by using your soldering iron as much as possible then use multicore wire and with a lot of solder flux to remove any remaining solder. Just put the multicore wire on top of the shorted area and hold down the soldering iron to transfer the solder to the wire.
  • Once you removed all the solder, you will have a clean and short free board.


From the picture, you can see that you can get really good connection using this simple method.  And it save a lot of money too.

Very importance to visually check the pins to see if there is any shorts, I'm using a 3X magnify glass from Daiso, it only $5RM/$1.5USD.


The whole process only take 20min, and it reduce the cost by 5X!!  It really a wonderful learning. I hope you will try this out too...

Here is some useful information that you can get from datasheet.  Here is the pin information:

   Also here is the application example, I notice that Adafruit board have 220ohm as output protection.  So in  diagram below, you can replace the transistor, led and resistor to single 220ohm, will build the breadboard in my next update: