My Diligent Pynq FPGA Board

It’s been a while since I posted on here but wanted to start a new topic off. I recently was lucky enough to Roadtest out a Digilent Arty S7 FPGA development board on behalf of Farnell/Newark Element14.¬† Well that got me really interested although I found the Verilog/VHDL aspects quite difficult….then I became aware of the Pynq board. This board apparently can be programmed using Python to describe the blocks and this is what I want to talk about on this blog.


Do I Need A Google Account?

I’ve a fairly new mobile phone and it is no surprise it is powered by Android (the only other choice of OS would have been iOS – between them they have 99% of the market). The phone is great. Android is great….but perhaps a little too great for my liking.

Having used the Maps and enabled location I would later visit somewhere only to be prompted later with questions of “Did I go into X pub” ? “What did I think of Y place”? and “Is Z your place of work”?

This started to overstep my personal boundary of what I was after. So, knowing my Google account was separate to the actual phone, I removed the account to see what I could still do. The answer is actually quite limited. For starters I can still use Google maps to navigate point-to-point, I can still search the www, I can ring and text people.


But the contact names have all been lost – calls are just numbers which makes things awkward. Also the To-Do-List doesn’t work. What does annoy me is that the basic Android does not allow a simple phone-book as standard. Saving contacts prompts me now if I want to save them to my Yahoo account.

A friend said that I should just download a third-party phone-book app. Trouble there is that the PlayStore doesn’t work either without a Google Account. I’ll have to try out the AMazon store or one of the other free app repos.

What I’d really like to do is write my own using Android Studio, add some encryption, add some notes etc. When I manage that I’ll post the results here ūüôā


Update On 2016 Starburst Lights

Happy New Year.

Adhering to my ‘low cost’ approach I ended up wiring the lights with a mismatch of old electrical cable and 8-core alarm cable, terminal blocks and insulating tape. All units were run using 5v from several linear regulators (7805).

I’d put my lights up early and had about two weeks before Christmas. It was around the two week time that, after some foggy and cold weather, I noticed a single, end of line pixel was remaining illuminated. I could turn the mains supply to the regulators off easily and that cleared the fault only for it to come back minutes or hours later. Finally the fault cleared completely which was strange. With the units secured into the tree with Jubilee Clips I just lived with the fault rather than get the ladder out, fiddle with them and make the fault worse.

A few days between Christmas and the New Year another star developed a faulty pixel, but this was nearer the start of its run of 10x pixels and took most of that leg out. Again I could turn the power off and back on and often it reset properly.

A few days after new year I climbed up, marked the offending positions with red tape and then took all the units down, dried them off indoors and tested again. They all work fine. I then removed some of the silicone to inspect the joins but they too look OK still.

One of the faulty units was a version where I painted all bare connections prior to the silicone sealant 2nd coat. The other was the initial black silicone/clear silicone version. I can only assume for both that water/moisture ingress caused the fault. Flexing the wire doesn’t replicate the fault so it likely wasn’t a dry joint.

The Best Bits

Having a family stop at the end of my garden one evening to say their children really liked the lights.

When up the ladder taking them down a lady slowed her car down, wound the window down and told me how much she/they had enjoyed looking at them each night.

For Next Year:

  • Add extra weather protection – perhaps a clear tubing over the top.
  • Actually spend some money on the power supplies and distribution cables/connectors.
  • Make some more units – 3+1 wasn’t enough !
  • And although I liked the unmanaged approach of self-contained units I missed being able to change what they did once they were up and running. Therefore next year I may change them into DMX512 controlled lighting. Coupled with the fantastic Vixen 3 software I could so a similar starburst, synchronise the stars, change the colours to match etc. To this end I’m already looking at testing out some RS485 comms chips from Texas instruments.


What to do next ?

Reverse engineer the newly acquired (Saturday at Wembley) Coldplay wristband (aka Xyloband) lying on the cofee table ?

Start a costume/prop build for London MCM ComicCon 2017 ?

Make my Raspberry Pi home server – that web scrapes key local info to a single page?

Make a Pi/Nexus 7″ in car entertainment system?

Start designing some Christmas lights?

Learn Haskell?


And the Finished Portal Gun….

After a very sucessful day out at MCM Comic Con London on Sunday the gun is earning a very well deserved rest on it’s MDF stand. This stand also enabled us to transport the gun, strapped down with velco tapes, in one piece.








One of the best comments we got was “…do you know some people build those from scratch?”.

What did I like best about Comic Con ?

Comic Village and talking directly to those talented artists, writers and designers; like Nick Cook

The general friendlyness and banter from everyone.

The Amazon Prime church set and trailer of the new Preacher series staring Dominic Cooper.

Portal Gun Mods Due

The control board worked faultlessly and the 3x AAA batteries powered the unit all day long, but changes needed are:

  1.    Change the firmware to allow the LEDs to pulse, flash in intensity
  2. ¬†¬† Rebuild the PCB using 0.1″ connectors rather than hardwire
  3.    Incorporate a 3x AAA battery holder
  4.    Secure wiring inside better
  5.    Make it lighter somehow Рperhaps vac form the shells?

Homemade Portal 2 Gun

After being asked at home “Can you make me a Portal Gun for ComicCon ?” my reply was “What’s a Portal Gun?” and then “What’s ComicCon?”

Well after being shown some online images of the gun, and a very impressive build blog by a professional prop designer called Harrison Krix ( see here ) the challenge was on. From glancing down Harrison’s blog it all seemed straight forward ! How wrong could I be.

ComicCon is tomorrow (after posting this morning I printed my tickets and see I have booked for Sunday’s event) and I will need to wire everything together this evening but nearly there at last. This is some notes and ideas that fellow hobbyist/diy builders may find useful. Here’s my gun so far:


Our gun was always built as cheaply as possible – main components are 68mm PVC downpipe, 102mm section of PVC pipe (sold for installing extractor fans), 150mm section of PVC pipe (again for extract fans), Oasis florists foam, old aluminium sections from a greenhouse, papermache and other sundries.

Once tomorrow is out of the way I hope to update this blog with lots of detail….but for now I’ll just stick some build photos in there.

The electronics are also homemade – I salvaged the RGB LEDs from my corroded outdoor lighting strips and re-soldered to some homemade PCBs. I made a controller to take care of the selection (Blue or Amber) and utilised the same trigger switch for the main ‘fire’. The circuit uses MOSFETs to sink the high current from the LEDs. Rather than power the unit from 3x AA batteries I have used a smaller USB Lithium-Ion battery pack. As these can deliver high currents I have also incorporated an inline fuse. The update here is that I have discovered the Lithium USB stick decides to power off after about 1 minute – I think the current is too low so it thinks the attached device has fully charged. I tried increasing this to a minimum of 400mA but this still wouldn’t result in power being left connected. Therefore back to plan 1: 3x AAA batteries. Strangely a much larger USB Powerbank I have will keep powering the circuit but this powerbank is too large to fit into the Portal Gun housing.

One of the first stumbling points when following Harrison’s blog was that I didn’t have a lathe but I soon found a really good article online (well presented, clear instructions and a motivated young engineer building it).¬† See Youtube article on the Art Of Weapons post here

…more to follow


This is so vey soft that once you have made something it is almost useless. I glues the blocks together using hot melt glue. I then made full size plans for plan view, side view and end views. I place one view onto my assembled blocks and cut straight down inline with the template. I repeated this for the other two views but these became progressivley more difficult as square was lost. Then I sanded all the ridges away using P80 sandpaper. An issue arose with the glue seams – they needed cutting back with electronic snips as they were too tough to sand.

The finished rear cowel looked great but had absolutely no strength – the slightlest knock or rough handling left marks. This thing needed toughening up. I tried treating a few off cuts; some with acrylic paint, some with PVA glue and some with polyurethane varnish. The latter seemed best so I coated the whole coweling with thinned down varnish. It got really heavy and stank the shed out. The next day it got left in the sun and dried quite well – it was definately harder but not ideal.

Next I decided to paper mache it. This made it much stronger.

Then I covered it with some plasterers glass fibre scrim – the self adhesive stuff. Over this I added a layer of car body repair filler. This was filed and sanded down (don’t forget to use a dusk mask if you are doing this) and repeated several times.

I also tried watered down wood filler that also worked well and went hard. This sanded more easily than the car filler and didn’t smell as bad nor get stuck on my tools.


Drawn out using Eagle PCB Design software . In the past I have used Staples and printed to acetate at 50p a sheet but this time they wanted an additional £3 for accessing the files off my CD Рseemed a bit steep so I wnt elsewhere. This time I printed onto plain white paper at my local library Рthank you Hampshire County Council as your staff were great sorting me out. I dabbed vegetable oil onto the circuit layout and they pressed the paper between sheets of kitchen towel to renmove excess. The oil makes the paper go translucent. I doubled the sheets up, puts them togetehr and exposed asome pre-sensitised copper clad board on my homemade UV box (3minutes 20s per side). I developed this in warm Sodium Hydroxide and etched in my small etch tank (a rectangular glass vase from Ikea with a 50W fish tank heater inside). Etching took about 4 -5 minutes. Front_Board_Layer1_v2

The circuit is controlled by a PIC16F1829 microcontroller by Microchip who make, what I believe, is one of the best supported ranges of microcontrollers. This is easily programmed using the Pickit3 and the free XC8 C compiler.


These are URM43 type coaxial cable outer sheathing. Inside is some stout galvanised fencing wire and a twisted pair of small signal cable on the end of which is soldered the white LEDs up near the claws. Each has an inline 150 Ohm resistor.

Cast or Turn

I made an armature that fitted snugly in the 68mm PVC drainpipe. I used a combination of glued strips of PVC, MDF and car body filler to make the various sections at the end and to then turn them down to size. Harrison’s site made something similar but then made a negative mould and cast this as one piece – I turned the part instead (as it’s a one-off that doesn’t matter).


I forgot to buy the online decals that I could print on my inkjet. Instead I used white tissue paper (from a greetings card shop), used double sided tape to stick a piece to some stout card and passed this through my printer. I stuck the images on using PVA glue – careful not to put too much on the face as the ink is water soluable.


The C code used in the compiler is shown below.

 * File:   Portal Gun Controller v1b - editted for Blog site
 * Author: Rodders
 * Created on 22nd May 2016
 * Config Control
 * Purpose:
 * Target PIC is PIC16F1829 - 20 pins
 * v1b   xxxx

#include <xc.h>
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>            // Boolean (true/false) definition

#define    _XTAL_FREQ    16000000        // Variable used for time delays only

void flash(int intFlashes);
void initialPic(void);

//global variables
bool FireColour;
int Pattern;

// ********************************************************************
void interrupt isr(void){

    GIE=0;                      //turn off interrupts (note they are automatically turned on when ISR finishes)

    // finish
    // reset any flags

// ********************************************************************
//void interrupt low_isr(void){ //only if device has two priority levels???

// ********************************************************************
void initialPIC(void)
{   // Initialize user ports and peripherals.
    //clock set up; 64MHz

    OSCCONbits.SPLLEN = 0;   //x4 clock even if config file sets pllen=0

    // Set port directions for I/O pins: 0 = Output, 1 = Input
    ANSELA = 0b00000000;            // Make all PORTA pins digital I/O
    TRISA = 0b00000000;            // PWM RA0-RA7 = x8 pins    RA0 is CS/SS for SPI
    LATA = 0x00;

    ANSELB = 0b00000000;
    TRISB = 0b10000000;            // PWM RB0-RB5 = x6 pins    Keep RB6 and RB7 clear as ICSP only                   // Change RB7 and RB6 to SPI inputs

    ANSELC = 0x00;
    TRISC = 0x00;                     // RC3 and RC4 are inputs for SPI from Raspberry Pi

    OPTION_REGbits.nWPUEN=0;    //if off - needed to set portc pull ups in next line
    WPUC = 0b10000000;
    INLVLC=0x00;          //schmitt triggers 0=off

    //TMR2 Setup
    //uses Fosc/4 = 16Mhz
    T2CON=0b00000001;          //pre-scale to 1/4
    PR2=80;                    //test increment 256 steps

    // Interrupt on Change, IOC
    IOCAP=0x00000001;       //portA, Positive edge    ....caution as using CD4011B

    //INTCON setup


// ********************************************************************
void flash(int intFlashes)
// as a test utility
    for (int j=0; j< intFlashes;j++)
        // Turn LED on and wait for a time delay
        for ( int i = 0; i < 5; i++ ) __delay_ms( 100 ); //see
        // On the PIC18F series, the __delay_ms macro is limited to a delay of 179,200
        // instruction cycles (just under 15ms @ 48MHz clock).

        // Turn LED off and wait for a time delay
        for ( int i = 0; i < 5; i++ ) __delay_ms( 100 );

    for ( int i = 0; i < 10; i++ ) __delay_ms( 100 );        //finish with a slight delay before exiting

int main(int argc, char** argv) {

       //set up hardware

       FireColour=false;                //false=blue, true=orange

       //turn the main output LEDs off

       while(1){                        //the main loop that continously runs

           // set the top indicator LED colour according to the FireColour value, RGB LED
           // take low to illuminate these LEDs
           if (! FireColour){
                LATCbits.LATC0=true;        //R
                LATCbits.LATC1=true;        //G
                LATCbits.LATC2=false;       //B

           //now wait for the trigger to be pulled, and for the line to go low, internal resistor pulls this pin high


           //wait and test again
           __delay_ms( 300 );
           if (PORTBbits.RB7==false){
               //line is still low so assume it was a large trigger pull as the user wants to fire

               //turn claw LEDs off

               //work out which colour
               if (! FireColour){
                   LATBbits.LATB4=true;         //B
                   LATBbits.LATB5=false;        //G
                   LATBbits.LATB6=false;        //R

               while (PORTBbits.RB7==false){
                   //wait for it to go high which signals a release of the button

               //turn main output LEDs off

               //and the claw LEDs back on
                __delay_ms( 300 );

           else {
                //line has returned high quickly; a quick tap - so toggle the colour on the indicator
               if (FireColour){

           } //else
           __delay_ms( 300 );           //add a delay to stop racing

       }    //while

    return (EXIT_SUCCESS);

And the associated CONFIG.H

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

#pragma config FOSC = INTOSC    // Oscillator Selection (INTOSC oscillator: I/O function on CLKIN pin)
#pragma config WDTE = OFF       // Watchdog Timer Enable (WDT disabled)
#pragma config PWRTE = OFF      // Power-up Timer Enable (PWRT disabled)
#pragma config MCLRE = ON       // MCLR Pin Function Select (MCLR/VPP pin function is MCLR)
#pragma config CP = OFF         // Flash Program Memory Code Protection (Program memory code protection is disabled)
#pragma config CPD = OFF        // Data Memory Code Protection (Data memory code protection is disabled)
#pragma config BOREN = OFF       // Brown-out Reset Enable (Brown-out Reset enabled)
#pragma config CLKOUTEN = OFF   // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
#pragma config IESO = ON        // Internal/External Switchover (Internal/External Switchover mode is enabled)
#pragma config FCMEN = ON       // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is enabled)

#pragma config WRT = OFF        // Flash Memory Self-Write Protection (Write protection off)
#pragma config PLLEN = ON       // PLL Enable (4x PLL enabled)
#pragma config STVREN = ON      // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)
#pragma config BORV = LO        // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
#pragma config LVP = ON         // Low-Voltage Programming Enable (Low-voltage programming enabled)

Pointers in C and C++

If you don’t understand pointers in C/C++ can I suggest running up a text editor+gcc or Visual Studio and just typing some code in. Play around with the code and see what you get. Try making a character pointer instead….e.g. the following code might make things easier to understand.

// Test_Pointers_1.cpp : main project file.
// This simple test program explores the basics of pointers in C++
// Pointers can cause a lot of confusion when learning C and C++ therefore
// I encourage you to change the code around until you understand it fully
// by:            Rodders
// created:        17th March 2016

#include "stdafx.h"

using namespace System;
using namespace std;

int main()
    int myVariable1 = 25;
    int myVariable2 = 44;

    int ValueHeld;

    int* myPointer;
    char Keyboard;

    Console::WriteLine(L"A Simple Program to Demonstrate Pointers in C++\n\n");

    cout << "The value held by myVariable1 is: " << myVariable1 << " which is held in 
          location: " << &myVariable1 << endl;
    cout << "The value held by myVariable2 is : " << myVariable2 << " which is held in
          location: " << &myVariable2 << endl;

    myPointer = &myVariable1;

    cout << "myPointer is now set to look at myVariable1" << endl;

    ValueHeld = *myPointer;
    cout << "And it points to a memory location that holds the value: " << ValueHeld  << endl;
    cout << "Where my pointer is: " << myPointer << endl;

    ValueHeld = *myPointer;
    cout << "\nIncrementing the pointer makes it point to a memory location that holds the value: " << ValueHeld << endl;
    cout << "Where my pointer is now: " << myPointer << endl;

    cout << "\nTherefore the compiler knew it had to add on 4 bytes to get the next integer pointer even though the code was myPointer++";

    cout << "\nPress return to exit";

    return 0;

Which gives:

A Simple Program to Demonstrate Pointers in C++

The value held by myVariable1 is: 25 which is held in location: 0018EE44
The value held by myVariable2 is : 44 which is held in location: 0018EE48
myPointer is now set to look at myVariable1
And it points to a memory location that holds the value: 25
Where my pointer is: 0018EE44

Incrementing the pointer makes it point to a memory location that holds the value: 44
Where my pointer is now: 0018EE48

Therefore the compiler knew it had to add on 4 bytes to get the next integer pointer 
even though the code was myPointer++
Press return to exit