Monday, July 29, 2019

Who is Andre Courchesne ?


Professional experience
  • 25 years doing various electronic designs, re-engineering or integration
  • 21 years managing IP networks
  • 20 years using Linux for server and desktop applications
  • 18 years doing code at a professional level
  • 18 years using version control as a core key of the software development process(CVS, Git)
  • 16 years of technical support experience (on the phone and in the field)
  • 10 years working mainly remotely while keeping a strong work discipline, professionalism and ethics
  • 6 years experience managing customers projects of up to 5M$/year
Team management
  • 4 years managing a team of 4 1st level support technical
  • 2 years managing a team of 2 2nd level technical and 2 certified engineers
  • Strong believer of the following keys of engineering team management:
    • Daily stand-up and weekly 1-on-1 team management strategies
    • Knowledge sharing
    • Strict versioning using Git
    • Peer code/design reviews
Programming language experience
  • Ruby, C, Perl, Bash, x86 Assembly, PHP, HTML, HTML/CSS/JS/jQuery, Electron just to name a few languages I am deeply familiar with.
  • I use the language I feel will be the best for the task at hand
Hardware platform experience
  • x86
  • Arduino (Atmel)
  • RaspberryPi
  • BeagleBone
  • Onion Omega
  • Anything Linux and open-source
Professional views
  • Information sharing is the key to success
  • GitLab is an essential tool for engineering team management and project management.
    • Don’t work on something if there is no GitLab ticket for it.
    • Use shipit-cli (https://gitlab.com/intello/shipit-cli) so that all merge request are uniform.
    • Rebase and squash to before merge to maintain a clean head
    • Maintain a changeling using Semantic versioning
  • If you develop for Linux use Linux or macOS not Windows.
  • If it exists and it’s open-source and does 80% of what you need why re-invent it ? Add to it, use it and share it when ever possible.
  • Thrive on open-source, share it, embrace it.
  • Automatization for uniformity, avoid snow flakes (Ansible, scripts,…)

Monday, July 22, 2019

Itsycal: A even better macOS clock replacement

In December 2018 I wrote about Day-O (https://net-forces.blogspot.com/search?q=day-o) as an amazing customizable macOS clock replacement.

One thing that bothered by with Day-O was that in dark mode it was really hard to read and the font was pretty small (I must be getting old).

Well the other day while checking if there was any update to it, the author mentioned the dark mode issue and pointed to Itsycal (https://www.mowglii.com/itsycal/) as a possible dark mode issue free replacement.

Well it does work and is even more customizable:


As you can see you can have it display the week number and it can even fetch your calendar(s) appointements.

It has a large font mode for old folks like me and has a lot of customizations:

Give is a shot I'm sure you will like it.

Monday, July 15, 2019

Adding an image to your KiCad EDA PCB

Had to add a logo/image on a PCB I recently made. As this PCB exceeded the size of the free Eagle CAD version I decided to give KiCad a try.

I was plesently surprised at how easy it was. Needs a bit getting used to regarding the component to footprint association but works like a charm !

Image

Now about the subject of this blog post: Adding an image to a PCB in KiCad. At first I was sure there would simply be a "Import JPEG/PNG" and that would be it... Well no...

Adding an image is a 3 step process:
  1. Convert your image to a "kicad_mod" library
  2. Add the library to KiCad
  3. Add the image from the library to your PCB
Let's go through these 4 steps using the following jpeg:

Image result for opensource logo
Convert your image to a "kicad_mod" library

You can use the following tool to convert an image to a KiCad library and at the same time resize the image. Unfortunatly you can not resize the image within the PCB editor, so you need to resize it before.

Simply upload the image, select the proper scaling factor so that the image fits on your PCB. In this case I selected a 0.03 scaling factor which generated an image of 24mm x 18mm.

Once you have it as you want (using the "preview" checkbox), simply uncheck it and download the KiCad library file to your project folder.

Add the library to KiCad

In the PCB editor, go to the "Preferences" -> "Manage Footprint Libraries...". From that dialog click on the folder icon:


And select your project folder. This will create a new library entry to the name of your project folder. Click "OK" to close this dialog. The library is now added to KiCad.

Add the image from the library to your PCB

Finally the last part ! From your KiCad PCB editor, click on the "Add footprint" icon and click somewhere in your PCB to bringup the footprint selection dialog.

Scroll down to find your project name and expand to reviel your image part:

Click "OK" and place the image where ever you want on your PCB:

It's not a straight forward process and you will probably have to try it a few times before you have the image you want, but it works.

Wednesday, June 19, 2019

Displaying a MySQL/Mariadb table on a web page using Ruby Sinatra and JS DataTables

My son was working on a project where he needed to display data from a MySQL/Mariadb table on a web page. Having no prior HTML/JS experience he had no clue how to do this.

He already had a Sinatra based API for the same project so I decided to build him a small demo using Sinatra as the backend API and "web server" and JavaScript DataTables as the front-end.

First let's take a look at a simple database with a single table:

CREATE database demo_datatables;
USE demo_datatables;
DROP TABLE employees;
CREATE TABLE IF NOT EXISTS employees (
  name VARCHAR(255),
  position VARCHAR(255),
  office VARCHAR(255),
  extn VARCHAR(255),
  start_date VARCHAR(255),
  salary VARCHAR(255)
);
GRANT ALL ON demo_datatables.* TO my_user@localhost IDENTIFIED BY "my_password";
INSERT INTO employees VALUES ('Tiger Nixon','System Architect','Edinburgh','5421','2011/04/25','$320,800'),('Garrett Winters','Accountant','Tokyo','8422','2011/07/25','$170,750'),('Ashton Cox','Junior Technical Author','San Francisco','1562','2009/01/12','$86,000');

Ok the datatypes used suck and are inappropriate, but this is not the scope here.

Next let's create our Sinatra API (api.rb):

require "sinatra"
require "sequel"
require "json"

mysql_host   = 'localhost'
mysql_user   = 'my_user'
mysql_pass   = 'my_password'
mysql_db     = 'demo_datatables'

# Initialize out database connector and table dataset
db ||= Sequel.connect(
  adapter: 'mysql2',
  host: mysql_host,
  username: mysql_user,
  password: mysql_pass,
  database: mysql_db,
  max_connections: 10
)
table = db[:employees]

# Data from MySQL
get '/data' do
  a = table.all.map { |h| h.values }
  { data: a }.to_json
end

# Page web root (this must be the last method as out pages data is in /)
get '/:name' do
  if File.file?(params['name'])
    send_file params['name']
  else
    "File #{params['name']} does not exists"
  end
end

As you can see we have a /data endpoint that will fetch the entire content of the table, format it as an array compatible with DataTables.

We also have a catch all endpoint on / that is used as a poor-man web server. It could be made much better but for this demo it makes the point. This endpoint will simply take any file passed as endpoint and if they exist send them over.

We can start this simply by running ruby api.rb. The output should be similar to this:

[root@monitor1 ~]# ruby api.rb
[2019-06-19 19:38:07] INFO  WEBrick 1.4.2
[2019-06-19 19:38:07] INFO  ruby 2.5.1 (2018-03-29) [x86_64-linux]
== Sinatra (v2.0.5) has taken the stage on 4567 for development with backup from WEBrick
[2019-06-19 19:38:07] INFO  WEBrick::HTTPServer#start: pid=19804 port=4567

So our server is running on port 4756. We can easily test out API by running curl -s http://localhost:4567/data:

[root@monitor1 ~]# curl -s http://localhost:4567/data
{"data":[["Tiger Nixon","System Architect","Edinburgh","5421","2011/04/25","$320,800"],["Garrett Winters","Accountant","Tokyo","8422","2011/07/25","$170,750"],["Ashton Cox","Junior Technical Author","San Francisco","1562","2009/01/12","$86,000"]]}6,000"}]}

We see that out endpoint to get the data works.

Let's now create out base HTML file (index.html):

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title></title>
  <meta name="author" content="">
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css" rel="stylesheet">
</head>

<body>

  <table id="example" class="display" style="width:100%">
    <thead>
      <tr>
        <th>Name</th>
        <th>Position</th>
        <th>Office</th>
        <th>Extn.</th>
        <th>Start date</th>
        <th>Salary</th>
      </tr>
    </thead>
  </table>

  <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
  <script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
  <script src="script.js"></script>
</body>

</html>

It's a simple HTML that has the skeleton for a table and fetches the required dependancies from global CDN sources.

And our small Javascript snippet (script.js):

$(document).ready(function () {
  $("#example").DataTable({
    "ajax": "/data"
  });
});

Again very simple DataTables usage where we will fetch out data from the /data endpoint and have DataTables render in in the table with ID #table.

And let's look at the result:

Not bad for some ~70 lines of code.

Note that this is by no mean secure, failures trap would have to be added and scaleability would have to be evaluated, but it's simple as hell and I hope a good starting point.


Friday, May 31, 2019

Exposition des finissants en génie électrique du Collège Lionel-Groulx - 2019

Et oui encore une fois cette année j'ai assisté aux présentations des projets des finissants en génie électrique du Collège Lionel-Groulx.

Ayant été finissant a ce même collège en 1993 c'est toujours un grand plaisir de revoir certains de mes professeurs et membre du personnel qui sont encore présents.

Moi et mon coéquipier Eric Jarry lors de la presentation de projet en 1993

Cette année a eu droit à 16 projets des élèves en profils Systèmes Ordinees et  en Télécommunications:


Voici quelques photos et vidéo prisent pendant l'événement:

Kasparov 2.0 par Jean-Chrystophe Rasine et Huillaume Marcoux-Legault


CNC Laser par Sergio-Victor Jara et Marc-Antoine Schanck


Revolution par Alexandre Charrier et Matthieu Mafran




Pinball sans fil par Eric Girard et Delmar Valesquez




Bravo particulier a  Guillaume Génier (projet de crayon capteur) et Nicolas Roy (projet Auto-Topo) qui se sont mériter une bourse offert par Hydro-Quebec: https://www.nordinfo.com/actualites/deux-laureats-a-lexposition-des-finissants-du-clg-en-genie-electrique

L'utilisation des Arduino et RaspberryPi sont omnipresent dans les projets ainsi que l'utilisation de l'open source tant logiciel que matériel. Il faut plus d'initiative comme celle-ci et une plus grande participation des industries afin d'encourager la relève.

Petit conseil aux équipes de l'an prochain:

  • Planifier chaque étape de vos projets, assurez-vous d'avoir du temps pour chacune de ces étapes. N'ayez pas peur de mettre certains éléments comme non-necessaire et "nice To havent" afin de pouvoir avoir un projet complet à presenter. 
  • Passez moins de temps à faire de la mécanique et plus de temps a l'élaboration, la planification et l'implementation logiciel et électronique. 
  • Mettez vos projets sur Gitlab et faites en la publicité sur les réseaux sociaux (Facebook, Twitter....)

Thursday, May 30, 2019

RFID activated bird feeder

Over the past weeks I have been working on a project for the Geography and Environmental Systems Department at the University of Maryland.

The idea is to study feeding habits of birds. Birds are equipped with very small RFID tags on their legs and the feeders will only open when they stand on the perch of the said feeder.

All in all not a very complex project code wise, more of a mechanical challenge. Also the feeders mush be autonomous (aka battery operated) and must record the time/date and RFID tag ID when birds come to feed on an SD card.

I started with a proof of concept showing my contact that it could be done. First activating the servo via an RFID tag:



And then activating a "door" with that servo:


One of the challenge was that their RFID tags were 125kHz tags so the choice of RFID reader was more limited. 

Bird leg RFIS tag


Turned our there were 2 models: RDM630 and RDM6300. The major difference between the 2 modules is that the RDM630 is superior in functionality and little more expensive, but the RDM6300 will read the same tag continuously if it's put near the reader for a long time.

So my choice was the RSM630 at first but turned out it did not work as expected for this application. We needed to know if the tag was present so that we kept the seed door open for the bird to feed.

So I ordered some RDM6300 from Robotshop and in conjunction with using interrupt on the Arduino it worked perfectly.

There was no budget or time to make an Aduino shield PCB to hold the RFID reader, RTC and SD module so I did a protoboard assembly:


Now that I had the code working as I wanted and the electronics assembly done I needed to work on the actual feeder assembly. A few hours of Sketchup and I came up with this design:





It allowed for a removable side panel to access the electronics and retrieve the SD card as well as a removable top to insert the seed bag and delivery system (which the final customer would be taking care of).

Because MDF is easy to work with I decided to use it for this build along with some 3D printed parts (all the parts you see in gray in the above picture are 3D printed). Here are some pictures of the build:




















I really suck at the painting process. But after final test I shipped it to the customer and here was their comment when they received it:



So I guess I did not do too bad on that job. It was fun and I learned new things.

Wednesday, April 17, 2019

Integer to it's binary string representation in C

My oldest son is studying mathematics and programming in college and wrote me asking for a way to convert an integer to it's binary representation in C. My C string handling is a bit rusty, but I accepted the challenge. This was the result, maybe it can be useful for someone.

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

const char *int_to_binary_string(int);

#define BITS_REQUIRED (sizeof(value_to_convert) * 8)

const char * int_to_binary_string(int value_to_convert) {
  char *result_string = malloc(BITS_REQUIRED + 1);

  for (int bit_counter = BITS_REQUIRED - 1; bit_counter >= 0; bit_counter--) {
    int current_bit = value_to_convert >> bit_counter;
    strcat(result_stringcurrent_bit & 1 ? "1" : "0");
  }

  return strchr(result_string, '1');
}

int main(void) {
  int value_to_convert = 55;
  printf("%i in binary is %s\n", c, int_to_binary_string(value_to_convert));
}

And the output:

{21:32}[2.5.0]~/Desktop ➭ gcc test.c
{21:39}[2.5.0]~/Desktop ➭ ./a.out   
55 in binary is 110111