Tuesday, November 22, 2016

Bench Power Supply Panel - Create CNC GCode from .STL file

I'm building a Bench power supply from a leftover PC power supply.  It will initially have +12 -12, +5 and +3.3 volt outputs, with a voltage and ammeter available for each output voltage.  Later, I'll be adding other outputs, powered separately by a transformer.

The front panel will be cut out using a Linux based CNC router.

Current status of this page:  Not quite there yet.

When viewed in LinuxCNC, the .ngc file has only data on the x axis.  I don't think we're ready for 1 dimensional physical objects yet!

Software to convert STL to NGC format.


On problem I needed to solve is the creation of a Linux CNC GCode file for the panel from the downloaded STL file from Onshape.

I've installed LinuxCNC's distribution in virtualbox.  In this virtual machine, I'm attempting to install stl2ngc from github - stl2ngc README.md

Before executing the opencamlib and stl2ngc build instructions on that page,  there's a number of pre-requisites that need to be installed.

 Here's the list of commands for installing the pre-requisites:

apt-get -y install cmake
apt-get -y install doxygen
apt-get -y install libboost-all-dev

Now you can follow the instructions in the stl2ngc README.md file:

git clone https://github.com/aewallin/opencamlib && cd opencamlib
mkdir build && cd build && cmake ../src && make -j4
sudo make install

git clone https://github.com/koppi/stl2ngc && cd stl2ngc
make
sudo make install
sudo mv /usr/local/lib/opencamlib/libocl.so.11.10.66 /usr/lib
 
See Note 2 below...
 

Get the .STL File from Onshape.com


Here's the Onshape page for the Bench Power Supply Design  the panel's STL file can be downloaded from there.  see note 1 below if your browser doesn't have WebGL enabled.

In the Onshape page for the power supply,
  • click on the Front Panel Tab.  
  • right click on the Front Panel Tab and select Export.
  • Choose Format:  STL
  • Choose STL Format: Text
  • Choose Resolution: Fine (might as well)
  • Click OK
Front Panel.STL will be in your Downloads folder.



Using stl2ngc:

 
cd ~/Downloads

cat "FrontPanel.stl" | stl2ngc > "Front Panel.ngc"


Note1: 

Onshape uses WebGl, which is not enabled by default in iceweasel, the browser in the LinuxCNC distribution.

from stackoverflow: How to enable WebGL on Iceweasel
  1. Enter into URL about:config
  2. click continue.
  3. search webgl
  4. find webgl.force-enabled right click and left click Toggle
  5. verify webGL works by visiting website get.webgl.org

Configuring LinuxCNC

 

 


Note2:

I had trouble running stl2ngc, so I added the move command above.


While both opencamlib and stl2ngc build correctly, the opencamlib ends up in /usr/local/lib/opencamlib.
This is not in your library path unless you add it, either for a single invocation or permanently. 
 
See Stack Overflow for an explanation that doesn't seem to tell the whole story covering this case:
Is /usr/local/lib searched for shared libraries?
 
One thing that works is:  

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib stl2ngc 

which will set it only for that invocation.

While this works, the permanent way is to get the library into the load library cache.  I was not able to do this correctly so I did ta bit of digging. 
 
/usr/local/lib/opencamlib contained libocl.so as a link to  libocl.so.11.10.66.  My hypothesis: This may be an error and it needs to be  a link to /usr/local/lib/opencamlib/libocl.so.11.10.66  or alternatively libco.so.11.10.66 needs to be moved to /usr/lib.

Moving it to /usr/lib seemed like the easy way to go, so I did that.  Now stl2ngc runs without complaining that it cannot find the library.
 
Ah the mysteries of linux....
 
Maybe someone can explain what I really should have done.





No comments:

Post a Comment