Pages

New domain and blog

Wednesday, 29 August 2012

So I got my Raspberry Pi yesterday and am super excited. I feel like a 10 year old on Christmas morning. I had already loaded the the Raspbian image onto an SD card so as soon as I got it I powered it up and away it ran.

The first thing that I wanted to get working was the GPIO pins. I did a bit of reading and some basic python examples and away I went. Have a look at this website for a very decent crash course in python.

The first thing you need to do is import the GPIO module. This can be installed from here.

Then you need to tell python that you are going to use the Raspberry Pi's pin numbers when referencing the ports. The direction of the port is then set.

Once the setup is complete, you can start your code. In my hardware, I connected a push button switch to pin 11 and pin 18 and an LED to pin 3 and pin 5.

Friday, 17 August 2012

In the test development environment, the need often arises where a microcontroller needs to be programmed before the testing can be completed. This can either be done with the development environment or through the command line if this method is provided for by the manufacturer.

Programming in the IDE is nice and easy, but very slow and needs the user to press the buttons. Often in the test environment, this process needs to be automated with as little user input as possible. Here is where using the command line parameters comes in so handy. You will need this hard-to-find document which outlines the commands to use.

In my application I am programming the PIC18LF26K22 microcontroller from Microchip and using the MPLAB PM3 device programmer. To test the devices I am using LabVIEW and TestStand from National Instruments.

There is a provision in LabVIEW where you can run command line programs, but I have found this to be a bit slow when interfacing with the PM3 programmer. This made me think of writing a C# dll to perform this task. Now I am no expert at C# programming, but am trying to learn where I can so thought this would be a good exercise.

I started off be investigating the Process Class and found just what I was looking for. All you need to do is create a new object of the Diagnostics.Process class. Then build the string that you need to send. The make up of this string is explained in pdf attached above.

This is an example of how to load an image onto the PM3. I build the string and then once I start the process, I read the standard output to make sure the the operation was successful.

The dll I wrote can handle loading an image to the programmer, program a device where the image is already on the programmer and erase the device. There are many other processes that can be performed but for the production testing that I am doing, this is all I need.

In the project attached, I also wrote a simple form application and a TestStand sequence to test the dll. You can find those files here.

By using a dll, I decreased my programming time from 60sec in LabVIEW to 15sec. When the device being tested only takes 30sec to test, an extra 45sec programming time is huge.

I hope this helps and if you need anything explained further, please leave a comment and I will try help where I can.