19 January, 2017

Updating Node on my Linux box

Recently, I read that Node 7 has been released. I am thinking that it is time to update my Linux box to the newer version.

There are multiple ways to update a Linux box.

One way is to use the package manager that shipped with Ubuntu. This method is good for a system that doesn't already have node installed and for a person who wants to spend minimal effort on keeping Node up to date.

The command to install Node 6 would be
 curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -  
 sudo apt-get install -y nodejs  

The command for Node 7 would be
 curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -  
 sudo apt-get install -y nodejs  

If Node is already installed then the latest release can be installed with
 sudo n latest  

The stable version can be installed with
 sudo n stable  

I am going to give nvm a try for installing the latest version of Node.

I will start by installing nvm with the command
 curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash  

Then use the following command find the latest version of Node
 nvm ls-remote  

Once I determined which version I wanted to install, I ran the command
 nvm install v7.4.0  





16 January, 2017

Setting up OctoPrint

I am setting up OctoPrint to give me more flexibility in monitoring and to free up a computer from being connected to the 3D Printer.

High Level Steps

  1. Get the OctoPi image
  2. Burn the image to an SD card. I am using Linux (Ubuntu) to burn the image.
  3. Configure the Raspberry Pi
  4. Test
  5. Move the equipment to the same location as the printer.


Detailed Steps

  1. Download the latest version of OctoPi
  2. Plug in your favorite Memory Card Reader
  3. Plug in your SD Card into the Memory Card Reader
  4. Open the Disks app
  5. Find your SD Card. The device is '/dev/sdd1' on my machine. Save the device info for a later step.
  6. In a terminal issue the following command: sudo dd if={location of image} od={destination} bs=4M
  7. I entered: sudo dd if=~/Downloads/2016-03-18-octopi-jessie-lite-0.13.0.img of=/dev/sdd bs=4M  
    • Warnings and notes about dd command
      • You need to run the command as superuser or use sudo
      • The dd command does not display any feedback while it is running. You need to wait for the command prompt to return
      • If the write fails try using 1M for the bs parameter.
      • The uppercase M in the bs parameter is important.
  8. Eject the SD card
  9. Put the SD Card into the Raspberry Pi.
  10. Plug in the Network Cable
  11. Apply power
  12. Wait for the Raspberry Pi to boot.
  13. In the terminal ssh to the Pi using the command:  ssh pi@octopi.local
  14. You will be prompted that the authenticity of the host can't be established and will need to accept the fingerprint. The default user for OctoPrint is 'pi' and the default password is 'raspberry'.
  15. Change the password of the pi to something that is secure and you can remember. Changing the password is done using the command:  passwd  
  16. Configure the Raspberry PI by issuing the command:  sudo raspi-config
  17. You will want to expand the filesystem, exit and reboot the Raspberry Pi.
  18. Once the Pi has finished rebooting, you can use the URL http://octopi.local. This may take a minute or two for page to display.
  19. You will be prompted to enter user name and password.
  20. Once the site appears, log in with the user name and password from the previous step.
  21. If prompted to update OctoPrint, perform the update. This will take a few minutes. When the update is complete you will be asked to reload the user interface. The update and reload took about 10 minutes for me.
  22. You will be prompted to set up a slicing profile. If you are already a Cura user you can import the profile. I updated my current Cura profile.
You should now have a basic setup for OctoPrint.

Plug your 3D Printer's USB cable into the printer and the Raspberry Pi then test if you can connect. In my case, I couldn't connect using 'Auto' for the Serial Port and Buadrate. I was able to connect once I manually set the values.

Testing that the Web Cam works by going to Settings -> Webcam & Timelapse. I clicked the test button, a dialog box pops up. I don't see the stream. To fix the issue, I used ssh to connect to the Pi, issued 'sudo nano /boot/octopi.txt', changed the camera usb options line to read 'camera_usb_options="-r VGA", saved the file, and rebooted the Pi.

Update 25 March 2017

I got some hardware to add to my OctoPi build out. The first item is 2.8 TFT with Touchscreen from adafruit. I followed the instructions for the Easy Install.

Note: in the scripts folder on the Raspberry Pi that is script named 'enable-adafruit-pitft' that did not work for me. It appears that script tries to install older libraries for the display.

It took some work to get OctoPiPanel running. My first attempt was to use the script included with OctoPi. This did not work for me. I was getting an error about pygame not being installed. What did work was using the instructions from the OctoPiPanel github page.

The second piece of hardware is a Raspberry Pi Camera Module Board. To get the module to work, I modified the file '/boot/octopi.txt', I just removed the # from the line camera_raspi_options="-fps 10"
.









23 July, 2014

Brushing up on PowerShell

Over the last couple of days, I have been working with PowerShell on a project. My usage of PowerShell in the past has been mostly for one off tasks or for a tasks that I need to get done really quickly so I can move on to the next. My current project caused me to think about PowerShell as a tool for creating re-usable scripts.

To load additional modules and snap-ins use the commands:
 Import-Module  
and
 Add-PSSnapIn  
.
If you try to load the same snap-in more in the same session an error occurs. One way around is to ignore the error.
 Add-PSSnapin -Name "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue  

Great care must be taken when using variables. A simple typo can lead to a lot of confusion. It is also worthwhile to read up on variable scope.
 help about_scope  

PowerShell allows you to create methods or functions within a script. The basic syntax is
 function  { script block }  

A quick example of creating a function to add two numbers together and calling the function.
 function Add ([int] $x, [int] $y) {   
   $results = $x + $y;  
   Write-Host "Results $results";  
 }  
 Add 3 4  

In the above example, I am doing a few small things that are more personal preference than anything else. There are multiple ways to create parameters. I like to create parameters on the same line as the function name. I also like to add the datatypes. This just gives a me a bit of clue as to what the function would like to have for data. I am also using semi-colons at the end of each line. This comes from my history of working with C, C++, Java, JavaScript, and C#.

You will notice in calling the function, "Add 3 4", parameter are separated by spaces.

Single line comments start with the # sign.
 #A simple one line comment  

Block comments are encased in <# #>
 <#  
 This is a multiple line comment  
 or block comment  
 #>  

Accessing the help system within PowerShell is straight-forward. There are multiple key words that can be used.
 Get-Help  
,
 Help  
, or
 Man  

Calling the help system on the cmdlet Get-Content.
 man Get-Content  

The help system also comes with a set of switches for showing the full listing.
 man Get-Content -full  




18 July, 2014

C++ header file location

This morning I was working a tutorial on openFrameworks. The tutorial called for the creation of a new class. I was a bit careless in the creation of the files. The files were created outside of the src folder. I used Visual Studio 2012 (VS) to move the files to correct location. When I went to use the new class in the code, VS could not find the files. VS did not move the file on the hard drive. I had to manually move the files myself.

Today's lesson is that I must be careful when creating new class files (.h and .cpp) to make sure there are created in the correct location. The other lesson is when moving source files around it is worth checking to make sure the files are moved on the hard drive.


17 July, 2014

openFrameworks - Notes on Getting Started

The other day, I learned of the existence of openFrameworks. According to the openFrameworks website, openFramework is a "toolkit designed to assist the creative process by providing a simple and intuitive framework for experimentation." openFrameworks runs on multiple platforms (Windows, Mac OS X, Linux, iOS, and Android).

I am learning and work with openFrameworks for a few reasons. I would like to increase my knowledge of C++. I am hoping that the libraries that are included with openFrameworks will take some of the pain out of learning C++. My next reason for learning openFrameworks is gain experience outside of business programming. I make my living by writing code for businesses.

Steps

1.) Download the framework (v0.8.3) - http://openframeworks.cc/download/.
2.) Unzip the files. I choose to put the files at c:\openFrameworks.
3.) Create the first solution.
3a.) Run projectGenerator.exe
3b.) Change the value of Name field
3c.) Accept the default path. Older versions of the openFramework relied on relative paths to find libraries. I choose not to risk change the location for my first project.
3d.) Leave the Addon alone for now. I am looking forward to playing and experimenting in the near future.
3e.) Click 'Generate Project'. Watch the screen carefully. The process runs very quickly and it is easy to miss the done message.
4.) Open the project with Visual Studio 2012. I learned this the hard way. I was unsuccessful with building the project in VS2013. Additional research is needed to figure out why.
5.) Run the project. The first build takes a while to compile all the parts. Once it is done, you should see a gray window.

The next step is now to start working my way through the tutorials.

17 April, 2014

Keeping an Eye on Rosyln

Over the past few days there has been a bit of news about Roslyn. I am working on getting my head around what is Roslyn and why do I care?

What is Roslyn?

"The .NET Compiler Platform ("Roslyn") provides open-source C# and Visual Basic compilers with rich code analysis APIs. You can build code analysis tools with the same APIs that Microsoft is using to implement Visual Studio!" - http://msdn.microsoft.com/en-us/roslyn

The way I am understanding this is Roslyn allows the C# code to help write C# code. A few others has commented that Roslyn would allow for the scripting of code plus the ability to compile/execute that code on the fly. 

Should I care about Roslyn?

The short answer is yes. 

Roslyn holds the promise of changing the way code is written, the way code is refactored, and the way code is analysed. 

It seems to me that the inline declaration expressions will take a little getting use to and will help produce more readable code.

I am rather excited to see what new features and tools people will develop to help with refactoring code. The example, I see the most showing off Roslyn's refactoring capabilities is the inline rename. 

It seems to me that Roslyn can help with Aspect Oriented Programming (AOP). In the AOP world, logging is the use case people point to for the need of AOP. Logging is common utility that is needed through out a program. It can get rather ugly and boring to write a logging statement in each method. It would be great to have a tool, script or the compiler automatically add logging to each method and to not clutter up the code with logging statements.

References


04 April, 2014

I was struck by the blog post 'The 30 second habit with lifelong impact.' The heart of the article is about taking 30 seconds after an important meeting, lecture, or experience to write the most important points.

My typical day includes several meetings, reading articles, writing code, learning new technologies, and increasing my knowledge of technologies. I encounter a lot of information each day. This idea of taking a few seconds to write down key points seems like it would be a valuable way to sort through all the information I encounter.

I have been keeping a journal. I really should rephrase, every few days I write something in what I am calling a journal. I don't have a good habit of writing each day. Taking a few seconds at the end of the day to write down a key point or two about the day would help to give me something to write about in the journal.

Challenging myself to learn something new

I have recently set a big challenge for myself. I want to know about Machine Learning . To add to the challenge, I am trying out usin...