Adding auto bed levelling to Prusa i3 on Sanguinololu v1.3 (Marlin firmware)

This is a diff file of my changes required in the latest Marlin firmware to enable auto bed levelling on the Prusa i3 using a Sanguinololu v1.2+ board.

You would need to change some of the figures depending on your own requirements and servo positions etc.

diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index edbeb44..45812fc 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -105,16 +106,17 @@
 // The following define selects which electronics board you have.
 // Please choose the name from boards.h that matches your setup
 #ifndef MOTHERBOARD
-  #define MOTHERBOARD BOARD_RAMPS_14_EFB
+  //Greg: #define MOTHERBOARD BOARD_RAMPS_14_EFB
+  #define MOTHERBOARD BOARD_SANGUINOLOLU_12
 #endif
 
 // Optional custom name for your RepStrap or other custom machine
 // Displayed in the LCD "Ready" message
-//#define CUSTOM_MACHINE_NAME "3D Printer"
+#define CUSTOM_MACHINE_NAME "Prusa i3 with Auto Bed Levelling"
 
 // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines)
 // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4)
-//#define MACHINE_UUID "00000000-0000-0000-0000-000000000000"
+//#define MACHINE_UUID "868d24d4-3d1e-4cf3-8787-35781bef3123"
 
 // This defines the number of extruders
 // :[1,2,3,4]
@@ -183,10 +187,10 @@
 //#define DUMMY_THERMISTOR_999_VALUE 100
 // :{ '0': "Not used", '4': "10k !! do not use for a hotend. Bad resolution at high temp. !!", '1': "100k / 4.7k - EPCOS", '51': "100k / 1k - EPCOS", '6': "100k / 4.7k EPCOS - Not as accurate as Table 1", '5': "100K / 4.7k - ATC Semitec 104GT-2 (Used in ParCan & J-Head)", '7': "100k / 4.7k Honeywell 135-104LAG-J01", '71': "100k / 4.7k Honeywell 135-104LAF-J01", '8': "100k / 4.7k 0603 SMD Vishay NTCS0603E3104FXT", '9': "100k / 4.7k GE Sensing AL03006-58.2K-97-G1", '10': "100k / 4.7k RS 198-961", '11': "100k / 4.7k beta 3950 1%", '12': "100k / 4.7k 0603 SMD Vishay NTCS0603E3104FXT (calibrated for Makibox hot bed)", '13': "100k Hisens 3950  1% up to 300°C for hotend 'Simple ONE ' & hotend 'All In ONE'", '60': "100k Maker's Tool Works Kapton Bed Thermistor beta=3950", '55': "100k / 1k - ATC Semitec 104GT-2 (Used in ParCan & J-Head)", '2': "200k / 4.7k - ATC Semitec 204GT-2", '52': "200k / 1k - ATC Semitec 204GT-2", '-3': "Thermocouple + MAX31855 (only for sensor 0)", '-2': "Thermocouple + MAX6675 (only for sensor 0)", '-1': "Thermocouple + AD595", '3': "Mendel-parts / 4.7k", '1047': "Pt1000 / 4.7k", '1010': "Pt1000 / 1k (non standard)", '20': "PT100 (Ultimainboard V2.x)", '147': "Pt100 / 4.7k", '110': "Pt100 / 1k (non-standard)", '998': "Dummy 1", '999': "Dummy 2" }
 #define TEMP_SENSOR_0 1
-#define TEMP_SENSOR_1 0
-#define TEMP_SENSOR_2 0
-#define TEMP_SENSOR_3 0
-#define TEMP_SENSOR_BED 0
+#define TEMP_SENSOR_1 -1
+#define TEMP_SENSOR_2 -1
+#define TEMP_SENSOR_3 -1
+#define TEMP_SENSOR_BED 1
 
 // This makes temp sensor 1 a redundant sensor for sensor 0. If the temperatures difference between these sensors is to high the print will be aborted.
 //#define TEMP_SENSOR_1_AS_REDUNDANT
@@ -198,8 +202,10 @@
 #define TEMP_WINDOW     1       // (degC) Window around target to start the residency timer x degC early.
 
 // Bed temperature must be close to target for this long before M190 returns success
-#define TEMP_BED_RESIDENCY_TIME 10  // (seconds)
-#define TEMP_BED_HYSTERESIS 3       // (degC) range of +/- temperatures considered "close" to the target one
+//Greg:#define TEMP_BED_RESIDENCY_TIME 10  // (seconds)
+//Greg:#define TEMP_BED_HYSTERESIS 3       // (degC) range of +/- temperatures considered "close" to the target one
+#define TEMP_BED_RESIDENCY_TIME 5  // (seconds)
+#define TEMP_BED_HYSTERESIS 2       // (degC) range of +/- temperatures considered "close" to the target one
 #define TEMP_BED_WINDOW     1       // (degC) Window around target to start the residency timer x degC early.
 
 // The minimal temperature defines the temperature below which the heater will not be enabled It is used
@@ -462,8 +468,8 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
 
 // Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way.
 #define INVERT_X_DIR false
-#define INVERT_Y_DIR true
-#define INVERT_Z_DIR false
+#define INVERT_Y_DIR false
+#define INVERT_Z_DIR true
 
 // @section extruder
 
@@ -493,8 +499,8 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
 #define X_MIN_POS 0
 #define Y_MIN_POS 0
 #define Z_MIN_POS 0
-#define X_MAX_POS 200
-#define Y_MAX_POS 200
+#define X_MAX_POS 205
+#define Y_MAX_POS 205
 #define Z_MAX_POS 200
 
 //===========================================================================
@@ -539,7 +545,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
 
 // @section bedlevel
 
-//#define AUTO_BED_LEVELING_FEATURE // Delete the comment to enable (remove // at the start of the line)
+#define AUTO_BED_LEVELING_FEATURE // Delete the comment to enable (remove // at the start of the line)
 //#define DEBUG_LEVELING_FEATURE
 #define Z_MIN_PROBE_REPEATABILITY_TEST  // If not commented out, Z Probe Repeatability test will be included if Auto Bed Leveling is Enabled.
 
@@ -562,10 +568,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
 
   #if ENABLED(AUTO_BED_LEVELING_GRID)
 
-    #define LEFT_PROBE_BED_POSITION 15
-    #define RIGHT_PROBE_BED_POSITION 170
-    #define FRONT_PROBE_BED_POSITION 20
-    #define BACK_PROBE_BED_POSITION 170
+    #define LEFT_PROBE_BED_POSITION 45
+    #define RIGHT_PROBE_BED_POSITION 140
+    #define FRONT_PROBE_BED_POSITION 0
+    #define BACK_PROBE_BED_POSITION 110
 
     #define MIN_PROBE_EDGE 10 // The Z probe minimum square sides can be no smaller than this.
 
@@ -603,9 +609,9 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
   //    |           |
   //    O-- FRONT --+
   //  (0,0)
-  #define X_PROBE_OFFSET_FROM_EXTRUDER 10  // X offset: -left  +right  [of the nozzle]
-  #define Y_PROBE_OFFSET_FROM_EXTRUDER 10  // Y offset: -front +behind [the nozzle]
-  #define Z_PROBE_OFFSET_FROM_EXTRUDER 0   // Z offset: -below +above  [the nozzle]
+  #define X_PROBE_OFFSET_FROM_EXTRUDER 40  // X offset: -left  +right  [of the nozzle]
+  #define Y_PROBE_OFFSET_FROM_EXTRUDER -40  // Y offset: -front +behind [the nozzle]
+  #define Z_PROBE_OFFSET_FROM_EXTRUDER -10   // Z offset: -below +above  [the nozzle]
 
   #define XY_TRAVEL_SPEED 8000         // X and Y axis travel speed between probes, in mm/min.
 
@@ -665,7 +671,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
 // - If stepper drivers time out, it will need X and Y homing again before Z homing.
 // - Position the Z probe in a defined XY point before Z Homing when homing all axes (G28).
 // - Prevent Z homing when the Z probe is outside bed area.
-//#define Z_SAFE_HOMING
+#define Z_SAFE_HOMING
 
 #if ENABLED(Z_SAFE_HOMING)
   #define Z_SAFE_HOMING_X_POINT ((X_MIN_POS + X_MAX_POS) / 2)    // X point for Z homing when homing all axis (G28).
@@ -679,13 +685,13 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
  * MOVEMENT SETTINGS
  */
 
-#define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0}  // set the homing speeds (mm/min)
+#define HOMING_FEEDRATE {50*60, 50*60, 2.5*60, 0}  // set the homing speeds (mm/min)
 
 // default settings
 
-#define DEFAULT_AXIS_STEPS_PER_UNIT   {80,80,4000,500}  // default steps per unit for Ultimaker
-#define DEFAULT_MAX_FEEDRATE          {300, 300, 5, 25}    // (mm/sec)
-#define DEFAULT_MAX_ACCELERATION      {3000,3000,100,10000}    // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for Skeinforge 40+, for older versions raise them a lot.
+#define DEFAULT_AXIS_STEPS_PER_UNIT   {78.74, 78.74, 4060.00, 800.00}  // default steps per unit for Ultimaker
+#define DEFAULT_MAX_FEEDRATE          {500, 500, 2, 25}    // (mm/sec)
+#define DEFAULT_MAX_ACCELERATION      {9000, 9000, 100, 160}    // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for Skeinforge 40+, for older versions raise them a lot.
 
 #define DEFAULT_ACCELERATION          3000    // X, Y, Z and E acceleration in mm/s^2 for printing moves
 #define DEFAULT_RETRACT_ACCELERATION  3000    // E acceleration in mm/s^2 for retracts
@@ -723,7 +729,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
 // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
 // M502 - reverts to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
 //define this to enable EEPROM support
-//#define EEPROM_SETTINGS
+#define EEPROM_SETTINGS
 
 #if ENABLED(EEPROM_SETTINGS)
   // To disable EEPROM Serial responses and decrease program space by ~1700 byte: comment this out:
@@ -750,12 +756,12 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
 
 // Preheat Constants
 #define PLA_PREHEAT_HOTEND_TEMP 180
-#define PLA_PREHEAT_HPB_TEMP 70
-#define PLA_PREHEAT_FAN_SPEED 0   // Insert Value between 0 and 255
+#define PLA_PREHEAT_HPB_TEMP 60
+#define PLA_PREHEAT_FAN_SPEED 255   // Insert Value between 0 and 255
 
-#define ABS_PREHEAT_HOTEND_TEMP 240
-#define ABS_PREHEAT_HPB_TEMP 110
-#define ABS_PREHEAT_FAN_SPEED 0   // Insert Value between 0 and 255
+#define ABS_PREHEAT_HOTEND_TEMP 230
+#define ABS_PREHEAT_HPB_TEMP 100
+#define ABS_PREHEAT_FAN_SPEED 255   // Insert Value between 0 and 255
 
 //=============================================================================
 //============================= LCD and SD support ============================
@@ -1072,7 +1078,8 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
 // leaving it undefined or defining as 0 will disable the servo subsystem
 // If unsure, leave commented / disabled
 //
-//#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
+//Greg: #define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
+#define NUM_SERVOS 1 // Servo index starts with 0 for M280 command
 
 // Servo Endstops
 //
@@ -1081,13 +1088,15 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
 //
 //#define X_ENDSTOP_SERVO_NR 1
 //#define Y_ENDSTOP_SERVO_NR 2
-//#define Z_ENDSTOP_SERVO_NR 0
-//#define SERVO_ENDSTOP_ANGLES {{0,0}, {0,0}, {70,0}} // X,Y,Z Axis Extend and Retract angles
+//Greg: #define Z_ENDSTOP_SERVO_NR 0
+#define Z_ENDSTOP_SERVO_NR 0
+//Greg: #define SERVO_ENDSTOP_ANGLES {{0,0}, {0,0}, {70,0}} // X,Y,Z Axis Extend and Retract angles
+#define SERVO_ENDSTOP_ANGLES {{0,0}, {0,0}, {82,0}} // X,Y,Z Axis Extend and Retract angles
 
 // Servo deactivation
 //
 // With this option servos are powered only during movement, then turned off to prevent jitter.
-//#define DEACTIVATE_SERVOS_AFTER_MOVE
+#define DEACTIVATE_SERVOS_AFTER_MOVE
 
 #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
   // Delay (in microseconds) before turning the servo off. This depends on the servo speed.
diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h
index 3b26237..2f516e0 100644
--- a/Marlin/Configuration_adv.h
+++ b/Marlin/Configuration_adv.h
@@ -285,7 +285,7 @@
 // Default stepper release if idle. Set to 0 to deactivate.
 // Steppers will shut down DEFAULT_STEPPER_DEACTIVE_TIME seconds after the last move when DISABLE_INACTIVE_? is true.
 // Time can be set by M18 and M84.
-#define DEFAULT_STEPPER_DEACTIVE_TIME 120
+#define DEFAULT_STEPPER_DEACTIVE_TIME 60
 #define DISABLE_INACTIVE_X true
 #define DISABLE_INACTIVE_Y true
 #define DISABLE_INACTIVE_Z true  // set to false if the nozzle will fall down on your printed part when print has finished.
diff --git a/Marlin/pins_SANGUINOLOLU_11.h b/Marlin/pins_SANGUINOLOLU_11.h
index d848548..011ee52 100644
--- a/Marlin/pins_SANGUINOLOLU_11.h
+++ b/Marlin/pins_SANGUINOLOLU_11.h
@@ -59,7 +59,7 @@
   #define SLED_PIN         -1
 #endif
 
-#define PS_ON_PIN          -1
+#define PS_ON_PIN          30
 #define KILL_PIN           -1
 
 #define HEATER_0_PIN       13 // (extruder)
@@ -194,3 +194,9 @@
 // #if FAN_PIN == 12 || FAN_PIN ==13
 //#define FAN_SOFT_PWM
 // #endif
+
+#if ENABLED(NUM_SERVOS) && NUM_SERVOS > 0
+  #if !ENABLED(SERVO0_PIN)
+    #define SERVO0_PIN 27 //A4
+  #endif
+#endif

bash convert resize and numerically rename multiple files

As an addendum to my previous post today I needed to resize and rename a directory of images at the bash prompt.

A nice little one liner did it for me:
i=0; for f in *JPG; do a=my_new_filename_`printf "%04d" $i`.jpg; echo Converting $f to $a; convert -resize 25% $f resized/$a; let i=i+1; done

For the multiline purists:
i=1
for f in *JPG
do
a=my_new_filename_`printf "%04d" $i`.jpg
echo Converting $f to $a
convert -resize 25% $f resized/$a
let i=i+1
done

ATI R9 270x (and R9 295X2,R9 290X,R9 290,R9 285,R9 280X,R9 280,R9 270X,R9 270) enable audio over dvi connection

As standard you do not get audio over the DVI port on R9 devices.

I got audio working correctly over DVI using an old DVI to HDMI converter that shipped with one of my previous ATI graphics cards, the HD4850x2.

They are still floating around on ebay, and look like this:
shopping

Just use a standard HDMI lead to your monitor or TV and you get full 5.1 surround sound :)

Have fun watching youtube in 5.1 :)

If this post has helped you please consider clicking on my sponsor ads if they appeal to you :)

LetsEncrypt renew Apache PluginError((‘There has been an error in parsing the file (%s): %s’, u’/etc/apache2/sites-enabled/000-default-le-ssl.conf’, u’Syntax error’),).

Trying to renew a LetsEncrypt SSL certificate in Apache and I got this unhelpful error message:
PluginError((‘There has been an error in parsing the file (%s): %s’, u’/etc/apache2/sites-enabled/000-default-le-ssl.conf’, u’Syntax error’),).

Now I can understand most error messages and figure out the issue but this one had me stumped. There was nowhere near enough information to allow me to determine the nature of the error.

My config file parsed correctly and worked without issue so I knew there was nothing fundamentally wrong with it.

Eventually I pinned it down to one of two problems:
* CaSe NoT MatcHing in <> –
* XML layout incorrect:

<ifModule greg>
	WhiteSpaces must be consistent
This line is incorrect and will break letsencrypt
	This is correct and will parse without issue
	All entries must line up
	<ifModule somethingelse>
		This must be indented correctly too
This line is incorrect and will break letsencrypt
	This line is incorrect and will break letsencrypt
		This is correct and will parse without issue
	</ifModule>
</ifModule>

This version is correct

<ifModule greg>
	WhiteSpaces must be consistent
	This line was incorrect and would have broken letsencrypt
	This is correct and will parse without issue
	All entries must line up
	<ifModule somethingelse>
		This must be indented correctly too
		This line was incorrect and would have broken letsencrypt
		This line was incorrect and would have broken letsencrypt
		This is correct and will parse without issue
	</ifModule>
</ifModule>

If this post helped, please consider clicking one of the ads. It costs you nothing but I get a nominal fee.

Apache wordpress remove index.php 404 not working .htaccess definitive solution

Scenario:
You are running Apache, have installed WordPress and are trying to get pretty permalinks working and it keeps returning a 404 page.

You’ve tried everything – a2enmod rewrite, removed the .htaccess file, reset the permalinks, changed them back to the pretty version, restarted Apache – in short everything people tell you.

The problem is still there isn’t it? The internet sucks, nobody knows anything.

Sit back, have a nice drink and we’ll have it fixed in seconds.

Edit the main Apache config file (/etc/apache2/apache2.conf in my case).

Search for:


       Options Indexes FollowSymLinks
       AllowOverride None
       Require all granted

Change it to:


       Options All
       AllowOverride All
       Require all granted

Restart Apache.

Want to thank me? This server has google ads and I receive a nominal amount per click.

Feel free to comment :)

wordpress permalinks
wordpress permalinks

Phpmyadmin root login not working apache http2

After playing around with http2 for a couple of servers I am commissioning (not this one yet!) I consistently run into issues with root being unable to log into phpmyadmin.

Logging into mysql manually works perfectly, the password is definitely correct.

If you have the same issue, try this as root:

echo "update user set plugin='' where User='root'; flush privileges;" | mysql --defaults-file=/etc/mysql/debian.cnf mysql

Let me know if it works for you. This post is actually mainly here because I never remember to do that line :P

So.. my quadcopter disappeared from view, and my life.

For quite some time I have been considering getting into the world of (or should that be the air of?) remote control flying machines such as quadcopters and the bigger brothers hexacopters and octocopters.
Recently while enjoying a nice day out shopping with my wife (we’ve all been there haven’t we) and I saw a shop that appealed to all my basic masculine needs. It was a boy toy shop for grown ups. Quicker than ‘er indoors could say “does my backside look big in this” I was detouring from the tent – er clothes – shop and meandering my way across the mall (hi Tiffany if you’re reading this – how about your comeback tour getting over to the UK? We have Europe’s largest shopping centre right on my doorstep) to Menkind.

Think for a second about that. A shop called Menkind. In this day and age of rampant feminism a shop that dares sell stuff to males.. Just a heads up ladies – there are no woman seats, unlike shoe shops which have male seats with popcorn while women fight to the death over the last pair of Jimmy Chews (alright already, I don’t want to sound like I take an interest in girly things. I know it’s Choo. Just wait until you get home and I cover them in ham slices and let the dog in. Tell me I am wrong then).
There’s another thing. Go into any shop that sells gadgets or pluggy in things and you get bombarded by extended warranty offers. Why not on a pair of shoes that cost a month’s wages and still break before the sticker comes off the bottom?

Where was I? Ah yes. I was drifting across towards the shop that glowed and I swear it had heavenly music coming from somewhere. Gold gates, masses of scantily clad angel girls all beckoning me into it.

Sorry about that, back to normal after a cold shower.

So I walked into this.. masterpiece full of Batman Neon lights and fold up tools for removing the headlight cover from a 1940s car. This shop had everything. It even had a car driving up and down on the window. On the actual window. Like something out of Mission Impossible. It must have been done with mirrors or something. What an age we live in.

Along one wall was a row of quadcopters. After spending the obligatory 5 minutes drooling a very knowledgeable member of staff (a girl no less) leapfrogged over the shambling wrecks of other men trying to get the stickers back on a Rubik’s Cube and somersaulted in front of me. Cue another heavenly fanfare.

“So, you are looking at quadcopters” she stated. I even heard the comma.
“I am indeed good man. Can you tell me the flight characteristics, expected flight time, lift capacity and control distance of each model please?” was what I wanted to say.
What actually came out was “want want want want want want want”.
“Ah, a tough customer. This is the one for you” she stated. She’d make a good statesman.

So off I skip – er manly stomp – to the checkout to pay for my pretty.

————–
Wordpress rant at this point:
I hate WordPress.com’s new editor. Whenever I get to the bottom of the page while typing my text disappears and I have to stop, scroll down and begin typing again, totally losing my train of thought.
There it did it again when I pressed Enter. Scroll up automatically WHEN I press Enter, not when I start typing. It is most disconcerting.
————–

 

Where was I? Ah yes. I was paying for my new quadcopter before She Who Must Be Obeyed got out of the changing room with two new canoes bungee strapped to her feet. Why God only knows, we live at the top of a hill. Flooding affects the poor people at the bottom of the village. It’s called Flood Plain Avenue for a reason and why we live at Flood Plain View.

So I manage to pay before my flexible friend shatters under the weight of her new Jimmy Cruise (ships), solve the Rubik’s Cube and put it back on the shelf to the sound of acolytes chanting my name. Truly I am Emperor of this new land.

I float on a cloud back across the heads of shoppers and land back in my front row seat to watch the end of the fight. The bloke in the dress won, but only because he outran the woman with the sharpened walking stick.

Someone had stolen my popcorn. Expletive deleted!

I nestle the quadcopter box under the pile of canvas sheets, tarpaulins and tents and await the return of my dainty little princess.

After 154 hours she returns (something about the fire brigade being called to get her out of the cowshed she was jammed into to try on her arks), takes one look at the lorry containing her underwear sails and asks me what the box is.

Being a brave man I tried to tough it out. When I woke up she was towering above me holding a quadcopter box, a petrol can and a lighter. Where the hell did she hide that?

“Want to try that again?” she asked in the dulcid tones she normally reserves for firemen and cake sellers.

I told her everything and she glanced over to where I was frantically pointing at a derelict store.

I willingly gave my bank card to the love of my life and she went to the nearest jewellery shop to buy herself a couple of anchors for her ears to go with her submarines.

I managed to get home. The bank, and my back, were both broke from the exertion.

Once the aircraft carriers and marquees were ensconced in the walk in cupboard (ok it is a hole smashed into the castle next door) she gave me the box containing the quadcopter.

Faster than you can say “these things have a 2 hour charging time” I was waiting 4 hours for the quadcopter battery (which was the size of a grain of sand) to charge.

Fast forward a few days. I can press a button and make the quadcopter flip. King of the world, baby!

Now to learn turning and coming back to me.

As I watched my quadcopter sail into the distance at the speed of light I tried to get it to return. Out of range of the controller the brave little quadcopter gallantly flew on towards the great unknown. It was last seen heading towards the sea and Norway.

So I am now looking forward to convincing RentATent that I need a new quadcopter, only this time bigger with more features.

One of the first features I will be adding will be a device that I have called a LinkIt One which is a wonderful little board with built in wi-fi, GPS and can send and receive SMS text messages.
Just imagine: “GPS my quadcopter”
“I am at x, y and 470 feet above sea level, come and get me please.”

I can write the code to make the aforementioned LinkIt One do that.

I just need to generate the funds to purchase a quadcopter strong enough to carry the LinkIt One with a decent flight time, and keep the funds away from Shoe Shop Annie who will blow it on ropes for her boots or something.

Wish me luck, and feel free to comment with any suggestions.

Tiffany, I was serious about the comeback tour visiting the malls of the UK. I’d even sacrifice some of my quadcopter funds to buy tickets.

Menkind is online at http://menkind.co.uk
LinkIt One is a product made by MediaTek http://labs.mediatek.com/site/global/developer_tools/mediatek_linkit/hdk_intro/index.gsp

This post is not an advertisement for either of the two companies listed above.

Lissajous Patterns on an Oscilloscope using Silego GreenPAK4 Development Kit and SLG46620V

lissajous 2 to 5 ratioIntroduction
What are Lissajous Patterns?
Lissajous Patterns are the result of two sine waves controlling the X and Y axes of an oscilloscope.
Lots of science fiction movies will show Lissajous Patterns on oscilloscopes as it is a very impressive thing to display.
https://en.wikipedia.org/wiki/Lissajous_curve
What is an Oscilloscope?
An oscilloscope is an electronic device used for viewing waveforms or electronic signals on a screen.
https://en.wikipedia.org/wiki/Oscilloscope
What is a Silego GreenPAK4?
GreenPAK4 is a highly versatile NVM Programmable Mixed-signal Matrix designed to easily implement differentiating features and functions into already highly integrated designs while minimizing component count, board space, and power consumption. GreenPAK4 comprises the best analog and digital resources from previous generations with expanded functionality and a few new additions, such as the hardware reset pin and Digital to Analog Converter (DAC), all in a tiny package.

Prerequisites
Oscilloscope and test probes
I use a Philips PM3217 which has served me well for many years
Silego GreenPAK4 Development Kit and SLG46620V
STQFN-20 (2.0 x 3.0 mm) GreenPAK4 Dual Supply Socket Adapter
Silego GreenPAK4 Designer
http://www.silego.com/products/greenpak4.html
Tweezers with antistatic coating and needle tips

Warning
As with most electronic parts the Silego GreenPAK4 Development Kit and SLG46620V are sensitive to static electricity. Ensure all static precautions are taken while using the board to prevent damage.

Setting up the board
Rather than permanently programming the SLG46620V we will be using the emulator function in the GreenPAK4 Designer software. Although the software calls itself an emulator it will actually be running on the IC. Using the emulator means that we will be able to program the IC (or use it in the emulator) again in the future, and more importantly for this tutorial we can change figures on the fly to generate different patterns and not have to burn a single use IC in the process.

I suggest working in a clean, uncluttered area with a sheet of blank white paper to put the board on while you are doing the initial set up. The IC we will be using is tiny, measuring 2 millimetres by 3 millimetres and will easily get lost forever should it drop onto a dark surface.

boardRemove all connections from the development board (including USB and the socket adapter).

socket openPlace the STQFN-20 (2.0 x 3.0 mm) GreenPAK4 Dual Supply Socket Adapter on your work area and open the top by pulling the tab slightly away from the socket adapter which releases the top panel revealing a tiny hole to carefully place the IC.

If you examine the IC you will see that one side has silver pads and the other has text. The side with the text is the top and has a small dot on one corner. This dot is the orientation point.

If you examine the socket adapter with the top panel open you will see a dot. This dot is also an orientation point.

Using your tweezers, pick up the IC, taking note of the orientation point. Place it carefully into the hole in the socket adapter ensuring the two orientation points are together and the text is still on top. Be extremely careful not to damage the pins inside the socket adapter or it will be permanently damaged and require replacement.

Once the IC is aligned and seated correctly open the tweezers and remove them before reclosing the top panel on the socket adapter.

board and socketNow connect the socket adapter to the larger board using the pins in the centre of the board, paying particular attention to the pin alignment.

Finally insert the USB cable into the USB port.

Installing the software
The software can be downloaded from http://www.silego.com/products/greenpak4.html. There are versions for Windows, Mac and Linux. I will be using the Linux version. Please follow the instructions for your particular system.

set chip revision windowOnce installed, run the software. A window will open asking you to select your GreenPAK4 chip revision. We will be working with the SLG46620V so select that one.

When the software has finished loading click on the Emulator button or press F9 on your keyboard.
emulator 1A new (rather curvy) window should open with the message “Please connect device to USB port”. Follow the instructions and plug in the USB cable. Sometimes I get an error message “The critical error message detected…” but I ignore it and click OK.
If you look at the bottom right corner of the window it says Chip P/N SLG46620V. This message means the computer can see the IC and all is well with the board.

emulator Signal Generator menuUse the secondary (right) mouse button to click on the box labelled TP3 and a new context menu will open. Select “Signal Generator”. Repeat this step for the box labelled TP6.

Setting up the oscilloscope
Each oscilloscope is different but basically we will be taking two probes and connecting them to the first and second ports of the oscilloscope and having one probe control the X axis and the other control the Y axis.

We will be using pins 3 and 6 of the GreenPAK4 board. I have arbitrarily selected those pins to allow clearance for the oscilloscope probes. The only requirement is that the pin is not VDD or GND and that it can be configured as “Signal Generator”.

Your test probes should come with crocodile clips that connect to GND. Connect those to one of the two rows of 6 pins sticking out of the board. Both sets of pins are marked GND.

TP3 TP6Take the probe connected to the X axis of the oscilloscope and connect it to the white connector on the board marked TP3. Take the other probe and connect it to TP6. You should now have 4 connections from the oscilloscope – 2 probes connected to TP3 and TP6 and 2 crocodile clips connected to GND.

Creating the Lissajous patterns
Signal Wizard windowWe will generate two separate sine waves, one on each pin TP3 and TP6. When they are displayed on an oscilloscope screen they interfere with each other in interesting ways.

Using the main mouse button double click on the box labelled TP3 at which point a new window will open. This is the Signal Wizard window.
The Signal Wizard window can be divided into two parts:
The signal generator settings on the left and the signal display on the right.

If you look to the right (the signal display) you will see three graphs. The top is VDD and should not be altered under any circumstances. The middle graph is TP3 and the bottom graph is TP6.

Signal Wizard window smallClick on the middle graph (TP3) and make the following changes to the Signal Generator settings:
Type: Change from “Const. Voltage” to “Sine”
Amplitude: Change from “2750.6 mV” to “1650 mV”
Zero offset: Change from “2750.6 mV” to “1650 mV”
Period: Change from “1000 ms” to “30ms”
Double check all the settings and click “Apply”

Click on the bottom graph (TP6) and make the following changes to the Signal Generator settings:
Phase: Change from “0” to “3Pi/2”
Type: Change from “Const. Voltage” to “Sine”
Amplitude: Change from “2750.6 mV” to “1650 mV”
Zero offset: Change from “2750.6 mV” to “1650 mV”
Period: Change from “1000 ms” to “45ms”
Double check all the settings and click “Apply”

Nothing will change on the oscilloscope, this is expected.

Do not close the Signal Display window as we will be making changes shortly.

Emulation Active smallSwitch back to the Emulation window and click on “Emulation” on the right hand side. The “Emulation” and “Test mode” buttons will change colour to orange. Switch back to the Signal Display window and look at the bottom.

Signal Wizard Start Pause StopThere is a radio button marked “All” and three buttons marked “Start”, “Pause” and “Stop” respectively.
Click on “All” so the radio box is filled and then click on “Start”.

Oscilloscope CircleThe oscilloscope screen should now show a circle.
If you see an oval you can use the controls on the oscillator to make it the correct position and size.

On my oscilloscope the settings are:
A/Alt/Chop/Add/B: B
AC/DC/DTB/MTB/X Defl/AC/AUTO/DC: X Defl
A Position: Unused
B Position: Used to control Y (vertical) axis
Delay Time: 0:0
Level/Slope: Unused
X Pos: Used to control X (horizontal) axis
Ampl/Div: 0.5v
Time/Div: Off
Hold off: Unused
Trace Sep: Unused
AC/DC: DC
O: Off
Del’d TB: All off
Main TB: A

Once your oscilloscope is correctly showing a circle in the centre of the display we do not need to change any settings.

Lissajous 1We can now generate some Lissajous patterns.
To do this switch to the Signal Wizard window and click on the TP6 graph.

Lissajous patterns are created when there is a difference between the period of two sine waves. By adjusting the Period setting for TP6 we can generate our first one.
Change Period for TP6 to 15ms and click Apply.
This will give you a shape resembling a curved V. Not very exciting is it?
Let’s see it move then.
Change Period for TP6 to 15.10 ms and click Apply.
The lissajous figure will now be rotating.

By making a slight difference to Period we can control the speed of rotation.

Decent figures for TP6 can be found by using TP3/n where n is a whole number eg 2, 3, 4 et cetera.
For example TP6 = TP3/3 = 30/3 = 10ms gives a 3 pointed Lissajous pattern.
To see it move set TP6 to 10.1

After a while you will doubtless get frustrated with clicking “Apply” after every change. If you click on the box next to “Auto Apply” then changes are made simply by pressing the Enter key.

One of my favourite values for TP6 would be 30.1 ms, which is a slowly rotating circle. Make it faster by changing TP6 to 30.3 ms.

Go ahead and impress the people around you. At work use it to convince management you need a bunch of new tech toys, your wife that your kit is actually useful and your children that you are the cleverest person they know.

Secret Santa PHP script

Today I have knocked together a Secret Santa script in PHP.
It takes a list of names and email addresses and randomly assigns people then emails the Secret Santa with their person to buy for.

Feel free to use the script – and if you want to say thanks to me please click on an ad that interests you :)

Change the recipient list, message and you’re all set.

Permalink to the script: secretsanta.php

Merry Christmas
<?php
$santas = array(
array("Alexander 'Scrooge' User", "A.User@example.com"),
array("Barry 'Baubles' User", "B.User@example.com"),
array("Charles 'Tinsel' User", "C.User@example.com"),
array("Dominic 'Rudolph' User", "D.User@example.com"),
array("Ernest 'Humbug' User", "E.User@example.com"),
array("Ferdinand 'Elfie' User", "F.User@example.com"),
array("Georgina 'Santa's Little Helper' User", "G.User@example.com"),
array("Helena 'Born In A Barn' User", "H.User@example.com")
array("Isla 'Mulled Wine' User", "H.User@example.com")
);
$numsantas = count($santas);

$combos = array_fill(0, $numsantas, -1);

echo “There are $numsantas Secret Santas this year.\n”;

$fp = fopen(“santalist.txt”, “w”);
if($fp)
{
fwrite($fp, “Secret Santa Draw ” . date(“r”) . “\n\n”);
}

$x = -1;
foreach($santas as $name => $email)
{
$x++;
$valid = false;
while(!$valid)
{
$r = rand(0, $numsantas – 1);
if($r != $x && $combos[$r] == -1)
{
$combos[$r] = $x;
echo $santas[$x][0] . ” will be buying for ” . $santas[$r][0] . “\n”;
$to = “\”” . $santas[$x][0] . “\” <” . $santas[$x][1] . “>”;
$subject = “Your Secret Santa”;
$headers = “From: \”Your Name, Secret Santa Organiser\” <youremail@example.com>\r\n” .
“Reply-To: \”Your Name, Secret Santa Organiser\” <youremail@example.com>\r\n” .
“Cc: \”Your Name, Secret Santa Organiser\” <youremail@example.com>\r\n” .
“X-Mailer: PHP/” . phpversion();
$message = “Hello ” . $santas[$x][0] . “\r\n” .
“In the random drawing of Your Organisation’s Secret Santa you have been selected to buy a gift for (insert drumroll sound effect here)\r\n” .
$santas[$r][0] . “\r\n” .
“As the aim of this is to be a Secret Santa please do not tell anyone who you have purchased a gift for.\r\n” .
“Please limit the value of the gift to be £1 maximum, and be creative – there will be a prize for the most appropriate gift for the recipient.\r\n” .
“(The cost of wrapping should not be deducted from the gift value – newspapers are free)\r\n”;
mail($to, $subject, $message, $headers);
if($fp)
{
fwrite($fp, $santas[$x][0] . ” will be buying for ” . $santas[$r][0] . “\n”);
}
$valid = true;
}
}
}
if($fp)
{
fclose($fp);
}
?>

Logitech G510 G510s working under Ubuntu

Hi all
After many years with my Logitech G15 keyboard I had to replace the wire once too many times.

I bit the bullet and bought an upgrade, the Logitech G510.

I run Linux (Ubuntu) and I hoped that the G510 would be as straightforward as the G15 to work under Linux. I was wrong. It’s a pain.

After much searching of the internet I found somewhere that had code for the G510 so I amended it to allow me to alter the backlight colours on the fly.

Enjoy, the zip file is attached.
make; sudo make install;sudo g15daemon
Rather than figure out udev rules I prefer the following line in my crontab:
@reboot while true; do if [ “`pidof g15daemon`” == “” ]; then g15daemon; fi; sleep 1; done

If you create a file /.g15colors and give it 3 lines of content with a number on each line between 0 and 255 it will set the keyboard colour to that colour whenever you send
sudo kill -USR2 `pidof g15daemon`

For example:
sudo echo -e “127\n127\n255” > /.g15color
sudo kill -USR2 `pidof g15daemon`

g15daemonsrc