Saturday, March 14, 2015

Install MplabX On Linux Ububtu 64 Bit

Searched so many answers every time I re-install my Ubuntu, here it is so I never forget or search again,


This is to install the 32bit libraries.  we need these to run MplabX.
sudo apt-get install libc6:i386 libx11-6:i386 libxext6:i386 libstdc++6:i386 libexpat1:i386
Also, we need to install Java SDK or RTE.  Openjdk...
sudo apt-get install openjdk-8-jre  openjdk-8-jdk
Also, I need to mention how to wire the ICD3 to connect to flat connector that would work with PICKIT3.
These are the Pins/Wires Order and numbers:

  1. Blue
  2. Yellow
  3. Green
  4. Red
  5. Black
  6. White





Reference:
http://blog.laczik.org/microchip-mplabx-installation-on-64-bit-ubuntu-system/
http://www.electronic-products-design.com/resources/customer-guides/manufacturing/ibex-microchip-icd2-programming-cable

Wednesday, March 11, 2015

UserControl What a Wonderful Future in C# C-Sharp You should be using

Working on a big project that contains a lot of functionality, modules and futures really gets stressing and gets out of control.  So the best approach is to divide code into modules and structure them to be unique and reusable.



The following is a screen shot or the main application I put together for the example purpose.  It contain a text  box that is displays all output logs.
You can send text logs from "Add Text Test" command button,
you can also, type specific text in the two text boxes and send them to the Output Log Text box.




 I created this user control, a text box and a command button that can be used to type in your text log and press the button to update/send to the main Output Log text box.



Overall Concept

The idea, is when creating main application GUI, you create new user control that can be used later and almost standalone. So it is self contained and can be reused.
The following diagram shows an application that has a text control and three other control groups that consists of a text entry and a command button.
these command buttons can be used multiple times in the same application with different needs and functionality.



The first goal is to create the control group and define events and properties you need to use for this user control. In the user control we using there are:
  • Event that occurs when user clicks on the Command button
  • Properties related to the Text Entry
    • Set: modify the contents of the Text Entry
    • Get: read the contents of the Text Entry
Command Button Events are handled as follow:
  1. User Control Class:
    1.  Add new public delegate 
      • public delegate void Update_Output_Log_Event(string message, Boolean next_line);
    2.  Create new event of same delegate type 
      • public event Update_Output_Log_Event Update_Output_Log;
    3. In the button click add a call to that event
      • Update_Output_Log(Message_Log_TextBox.Text, true);
  2. Main Application Class
    1. Add the User Control to the GUI of the main form
      • I will rename it my_User_Control_Log1
    2. Create function that has the same parameters as the delegate in User Control
      • public void Update_Output_Log(string message, Boolean add_new_Line)
    3. Register the event to the new function
      • my_User_Control_Log1.Update_Output_Log += new my_User_Control_Log.Update_Output_Log_Event(Update_Output_Log);


Properties are handled as follow:


  1. User Control Class:
    1. Add description and category to make it look nicer!
      • [Description("Retrieves and sets the Message Log Text"), Category("Data")]
    2. Create new variable that represents the data type we need to access
      • public string update_Messsage_Text
    3. Add get and set properties for that variable
      • get { return Message_Log_TextBox.Text; }
      • set { Message_Log_TextBox.Text = value; }
      • These two properties will modify/read from the Text Box Message_Log_TextBox.Text
  2. Main Application Class:
    1. when needed you can set or get text values using the following
    2. Output_Log_TextBox.AppendText(my_User_Control_Log1.Update_Message_Text);
    3. my_User_Control_Log1.Update_Message_Text = "Test New Text...";




Here are all the details on how to do that step by step...












Saturday, March 7, 2015

Linux Copy Files Remotely Over SFTP

Using ssh between systems running Linux and always in need to transfer files back and force...?
Then you should consider using sftp as you will be able to copy files so easy unless you use a GUI application to click, click, click, which is OK and nothing wrong with that.  But, for me I like to feel the move and be in control...

So, sftp has the same commands almost as ssh that connects you to your remote PC.  However, it also has the commands that can run on your local PC.  So, after you login to your remote session, all sftp commands you type should run on your remote session,

If you type ls, then you are listing all commands in your remote session.
Now, type
lls
and you see list of all files in local folder you started from


If you type

  • mkdir xyz   you created folder in your remote PC

now type

  • lmkdir xyz  and you created folder in your remote PC



If you type:

  • pwd  you will list current working directory on remote PC

now type

  • lpwd  you will see your current working directory on local PC


Here are some useful commands that I need to use all the time


  • put puts files from your local working directory to the remote directory
  • get gets files from your remote directory to local directory





All following commands work on remote PC and when you add l, that is lower case L, you run them on local PC

  • lls, ls
  • lpwd, pwd
  • lmkdir, mkdir