Thursday, December 01, 2022

Setting up Windows 10/11 as an NTP Time Server

Instructions to setup a Windows 10 or 11 PC as a NTP time server :

  • Using the Registry Editor change the following two keys

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\W32Time\Config -> AnnounceFlags = 5

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\W32Time\TimeProviders\NtpServer -> Enabled = 1

  • Create inbound firewall rule allowing UDP port 123

  • From admin command prompt run sc triggerinfo w32time delete to clear any triggers which prevent the service from starting

  • Ensure "Windows Time" service is set to Automatic 

  • Restart "Windows Time" service

Wednesday, April 14, 2021

What Brexit really costs


We make fibre optic test systems that are used to monitor the huge power cables connecting offshore windfarms. A typical system costs between £75,000 and £100,000, we sell or rent them to our customers. Most of our customers are based in the EU and are busy building windfarms in UK waters. Before Brexit we could take our equipment in our own vehicle and install it at the customer's site, there was no admin, no costs and no customs delays. It's taken until now, mid-April, to clarify the costs for supplying rental equipment from the UK to the EU.

I've summarised the new costs and admin overhead below.

Staff

Thanks to the Trade and Cooperation Agreement (TCA) staff from the UK can work in the EU to deliver a contract between a UK and EU business. There are restrictions on the staff that can do this work, they must be over 21, have been employed for at least a year and have three years experience doing identical work. Self employed staff need six years experience. Individuals can only stay in the EU Schengen zone for a maximum of 90 days from the previous 180 (it's a personal limit that applies regardless if you are on holiday or working). To avoid having to pay National Insurance in the country you are working in you can apply for a "Certificate of continuing liability for National Insurance" - provided the UK has a reciprocal agreement with the country you are working in. All dates working outside the UK have to be reported to HMRC - all additional admin overhead not necessary previously.

Tools and Equipment

We typically travel with around £25,000 of specialist fibre optic tools and test equipment. To travel to the EU all equipment needs it's own "passport" - an ATA Carnet. The cost for an ATA Carnet is £620.50 per trip, there is a considerable admin overhead as all equipment must be itemised and listed with serial numbers along with a copy of the original invoice. All the equipment you take from the UK to EU must be returned. Nothing can be missed from the list on your return to the UK or you sacrifice the deposit. In this example the deposit is covered by insurance but without that a deposit of 40% of the full retail value (or bank guarantee for that amount) is required to be paid to the Chamber of Commerce who issues the ATA Carnet.

Shipping

Before Brexit goods and staff could travel freely around the EU transporting our own equipment. Now duties (tariffs and VAT) must be paid when crossing to or from the EU. Rules of origin and safety checks are also made as these potentially alter the payable tariff rates. To have the ability to "pre-clear" customs (to avoid sitting in a queue for as long as it takes) you must be a logistics company as only they have the software and VAT status to use the pre-clearance system. The UK government essentially allow DHL, and companies like them, to police the system on their behalf. The logistics companies are therefore quite conservative and won't touch anything that risks complications (like rentals or returns) as an error in a consignment could block or delay a whole lorry load of goods.

The cost of shipping a 300kg pallet to and from the EU by DHL is £1,765.00 and delivery takes around a week. Only logistics companies like DHL have the capability to deal with both the UK and EU customs formalities.

Tariffs and VAT

This is the big one! Being outside the EU and customs union means VAT is payable on delivery when goods are imported from the UK into the EU. In the case of the Netherlands that's at 21%. So the customer must pay 21% of £75,000 (the full retail price even though they are only renting it for a short time) before DHL will deliver the goods. That's £15,750.00 to be paid even if the customer is renting the system for just a few days. When the rental goods are returned to the UK the customer can apply for this VAT to be refunded to them, but they still have to suffer the cashflow impact as it can take a while to arrange the refund.

I've shown in red the new post-Brexit costs for UK companies delivering a project in the EU. These are considerable costs that an EU supplier would not incur.

Can someone please explain the benefit the UK gets from being outside the single market and customs union?

Saturday, March 20, 2021

Replace Changeover Valve on a Dyson DC40 - Dyson P/N 922625-03

This video shows how to replace a damaged changeover valve on a Dyson DC40. It was working OK from the hose but not sucking very well when in carpet cleaning position. The problem turned out to be a ripped changeover valve (see photo below).


I bought a replacement from Amazon for £6 (Dyson P/N 922625-03 "COV HOSE ASSY"). It's fairly easy and cheap to replace and only took about 10 minutes. The full video of the whole repair is shown below. You'll need a Torx T8 and T15 screwdriver bit (something like this).

I reckon I just saved about £300 on a new Dyson!

Please let me know how you got on if you attempted this repair. 




Saturday, March 06, 2021

How to play R'Méribel, la radiostation on an Amazon Alexa (or Echo) by tapping a single iPhone button

This sounds simple but it takes quite a few steps. This is the result, a single "R'Méribel" button on the iPhone Today View screen that you click to play R'Méribel on your Alexa (the screen you see when you swipe right from the left edge of the Home Screen or Lock Screen). I'm using iOS 14.4 in these instructions, hopefully it'll continue to work in newer versions too.


First a little context. Although UK based we have a house in Méribel (a ski resort in France) which we cannot easily visit at the moment thanks to COVID. It's nice to listen to R'Méribel to remind ourselves of the good times skiing, and, for a French station, they play some surprisingly decent music in the evenings without any DJ's or too many adverts.

Step 1) First you need to install the "myTuner Radio Player App" as an Alexa skill. From the Alexa iPhone app tap the "More" button and select "Skills & Games". Tap the "Search" button and search for "myTuner Radio Player App" tap on it in the results list and then click "Enable to use".

In theory this is enough to allow you to say "Alexa, ask mytuner radio to play R'Méribel". In practice I find the apostrophe and é (accent aigu) confuse the voice recognition at least on my Alexa which is set to UK English.

The problem is the station name "R'Méribel" is a play on words, it should really be something like "Radio de Méribel" but it's been shortened to make it look and sound cooler. However, this abbreviation totally confuses the Alexa voice recognition as anything but an exact database match fails to find the station in the mytuner database of stations. I should really pop down and speak to the Alexa software developers as they are just down the road from me in Cambridge. 

Anyway, to work around this problem we'll add an Alexa "Routine" to bypass the voice recognition so the action can be triggered with a simpler phrase which is hopefully a little easier for Alexa to understand.

Step 2) Adding an Alexa Routine: From the Alexa iPhone app tap the "More" button and select "Routines". Tap the "+" button (top right). You should see this screen :
Tap on "Enter routine name" and call it anything you like, I called mine Say 'Alexa, Meribel' to remind me what the trigger phrase is.

Tap on "When this happens" and tap on "Voice". This allows you to enter a phrase to start the routine. I called mine simply "Meribel" but you can choose any phrase you prefer.

Tap on "Add action" and scroll down to "Customised". Enter the specific text "Alexa, ask mytuner radio to play R'Méribel". I've found it's critical to enter the single vertical apostrophe between the R and M (press and hold on the ' key in the iPhone keyboard to get different options) and the e as é (press and hold the e on the iPhone keyboard to get various accents). If you don't enter this precisely as shown it doesn't match to the station name and offers three almost random selections. It took me ages to work this out. Please enter it exactly as shown.

This step is important as it essentially sends the raw command "Alexa, ask mytuner radio to play R'Méribel" directly to myTuner avoiding the utterly unreliable and inconsistent voice recognition part of Alexa (which rarely works well with my grumpy voice even on a good day).

Finally tap "Choose Device" to select which device it will play on.

With these steps complete you should see this screen.

You can tap on the blue play button to trigger any of your routines. Alternatively you can say "Alexa, Meribel" to trigger the routine with a simple voice command.

I have found that occasionally nothing will play. I think this is due to a problem sending the audio feed from R'Méribel because the myTuner web page also fails to play anything at the same time. I've found there is nothing you can do other than waiting for it to start working again.

If, like me, you struggle to get Alexa to understand what you are saying it's a bit of a pain having to go into the Alexa app, press "More" then "Routines" just to tap the play button. Wouldn't it be much nicer to have a single button on the iPhone main screen?

TL;DR (too long; didn't read)
To make it really easy to setup the Alexa Routine above simply click here or point your camera at this QR Code (or tap it) and it'll do everything described above automatically.

If you're happy with this method so far you can stop at this point. If you want to trigger the Alexa action with a single tap of an iPhone button please continue.

Steps to add a button on an iPhone to trigger an Alexa routine

We need to install another Alexa skill but before we can do this you need an active https://www.patreon.com/ account. Patreon is a payment system for making small regular payments and mainly used for paying musicians or podcast creators. Don't worry, this process is FREE for a single button (you can support the developers by paying a small monthly amount if you want multiple buttons to trigger multiple Alexa actions - this can be helpful for various home automation projects). However, register a Patreon account using your email address and create a new password (don't even think of using the same password everywhere!!!). Once you've completed the registration page don't forget to click on the button at the top of the Patreon web page to send yourself a verification email. Once your Patreon account is fully verified you can continue.

Next, we need to add the "Virtual Buttons" skill to Alexa. From the Alexa iPhone app tap the "More" button and select "Skills & Games". Tap the "Search" button and search for "Virtual Buttons" tap on it in the results list and then tap "Enable to use". Right after you enable the Virtual Buttons skill you must link it to your Patreon account by entering your email address and Patreon password. At his point Virtual Buttons will send you an email with a long URL in it (from info@virtualbuttons.com - make sure it's not sent to your spam folder). You can use this URL to trigger your Alexa routine from anywhere. Keep it secret as anyone with the URL will be able to trigger the routine. The email will look something like this. We'll need the bit in yellow later.

We now need to create another Alexa routine to "Alexa, ask mytuner radio to play R'Méribel" but this time when the "Virtual Button 01" is pressed.

TL;DR
You can follow along below with the manual instructions, click here or simply point your iPhone camera at this QR code (or tap it) to automatically setup the "Virtual Buttons" routine described below.

Launch the Alexa app on your mobile device. Tap the more icon (usually lower right part of screen) and select "Routines". Tap the "+" icon in the top right corner. Tap "Enter routine name" and choose a name, I called mine "Virtual Button 01 is pressed". Tap "When This Happens", then tap "Smart Home" and choose the "Virtual Button 01" device and tap "Save". Select "Add action", then select "Customised" and enter "Alexa, ask mytuner radio to play R'Méribel". Tap "Next" in the top right corner. Tap "Choose Device", and then select the Alexa device you want to play on. Tap "Save" in the top right corner.


You can now click on the blue "Play" button next to "Virtual Button 01 is pressed" to test the new routine. It should start playing R'Méribel again.

Adding an Apple Shortcut

Finally, we are going to use the Apple Shortcuts app to create a button using the "unique access code" URL that was emailed to us from info@VirtualButtons.com (the bit in yellow in the email). The URL can be used from any device so you could for example start the R'Méribel routine by clicking on the link in the email or adding it as a favourite button in your web browser.

However, we are going to use the Apple Shortcuts app to create an iPhone button. Start the "Shortcuts" app on your iPhone and click on "All Shortcuts". We are going to add a "R'Méribel" shortcut like this (top left).


Tap on the "+" (top right) and tap "Add Action" then tap "Apps". You should have a screen something like this (the icons will depend on which apps you have on your phone) :
Scroll down and tap "Safari" and then tap "Open URLs".

You need to copy the long URL sent in the Virtual Button email and paste it where it says URL in blue. It'll look something like this when you've pasted the URL in.
Remember this URL is "secret", anyone who has it can trigger the routine on your Alexa.

Tap "Next" and enter a name for the shortcut. I called mine R'Méribel and finally tap "Done". You should have a button in the Shortcuts app that you can click on. 
When you click on the button you should see the following in the browser which confirms the action has been triggered.
The Virtual Button website does it's magic and triggers the "Virtual Button 01 is pressed" Alexa routine. This routine in turn sends "Alexa, ask mytuner radio to play R'Méribel" to the mytuner skill which should start the station playing.

One final step. Tap and hold on the "R'Méribel" shortcut button in the Shortcuts app and select "Details" from the menu at the bottom (I've found you need to tap and hold directly on top of the shortcut icon, not the three dots, to get the menu to appear). You can now tap "Add to Home Screen" to change the name and possibly the icon (as I did here - I grabbed an image from https://laradiostation.fr/r-meribel/), finally press "Add" to add the icon as a normal iPhone app button.

You can now tap on the button and all the magic happens in the background.

To get the button on the "Today View" page you need to add the "Shortcuts Widget". Scroll to the bottom of the "Today View" and tap "Edit" then the "+" top right. Search for "Shortcuts" and then "Add Widget", you can swipe to select a single, four or eight shortcut buttons. This will add a widget to the Today View which can then be customised to include multiple shortcuts.

That's it. Easy when you know how. Swipe right and tap on one button for R'Méribel!

You can use this Virtual Button technique to trigger any number of Alexa Routines. Because the shortcut is added to your iPhone you can even get Siri to trigger the routine with a voice command on your phone. I'll leave it to you to figure that one out.

You can now enjoy the view whilst listening to R'Méribel.












Sunday, September 20, 2020

Dremel 3D45

Well, here's my first 3D designed project printed with a Dremel 3D45 over the weekend. Setup was a bit annoying. It's not clear that by selecting "UK" during the initial setup it prevents use of the online remote printing tool (as the Dremel's About screen does not show the Token needed to setup the online connection). Switching the Dremel from "UK" to "US" is the trick you need to get this working.

Apart from that it takes a little bit of practice to work out what prints well and which orientation you need for best results. In the photo below I made the two trays separately and designed them to click into the moon shaped parts.

I started using Autodesk Fusion but quickly switched to Sketchup 2020 for speed. I'd not really used Sketchup much but after a weekend of playing I'm getting pretty quick at new designs.

Overall I've been impressed with the printer. The parts produced (here in standard print quality mode) are perfectly useable. Standard mode is perfectly good enough for non-seen parts. You might want to use high quality mode for visible surfaces.

The biggest learning curve is finding a design tool that you can use. 


Wednesday, July 25, 2018

How to close a RDP session but leave original user logged on

It's annoying when you make a Remote Desktop Connection (RDP) to a PC that it does not automatically reconnect the original user once your remote session has finished. I often need to do this to remotely control a Windows based bit of test equipment. I developed this script to place a button on the Taskbar of the controlled machine to close the RDP session. Provided you use this button the desktop is returned to the original user as the remote session terminates. However, if you simply close the session (as you do normally by closing the RDC window) this code does not help and the machine will, as normal,  prompt for a password before returning to the desktop.

Firstly you need to create this .bat file. I've Created mine in a folder called C:\Temp\Shutdown RDP and named my .bat file "CloseRDP.bat".

set MY_SESSION_ID=unknown
for /f "tokens=3-4" %%a in ('query session') do @if "%%b"=="Active" set MY_SESSION_ID=%%a
tscon %MY_SESSION_ID% /DEST:console /Password:YourTopSecretPassword

Firstly let me explain what this does. The second line runs the command 'query session' and extracts the session ID that is active. It puts the session ID into an environment variable called MY_SESSION_ID. The third line closes the active session (based on it's session ID number from line 2) and redirects to the console. You will have to replace YourTopSecretPassword with the password for the desktop user. Now, this is a bit of a security risk as the password is in plain text inside the .bat file but I'm afraid it does not work if you leave it out.

However there is a problem with this .bat file...it must be run with Administrator privileges otherwise it does not work. So from File Explorer right click on CloseRDP.bat and select "Copy". Then right click in some empty space in the same folder and select "Paste Shortcut". My shortcut is now called "CloseRDP.bat - Shortcut". Right click on this and select "Properties", click on the "Advanced" button and tick "Run as administrator" and click OK twice to return to File Explorer. You have now created a shortcut that runs as Administrator. You can click on this to close the RDC session and return to the desktop. Because it runs as an Administrator you will be prompted to enter the Administrator password.

In an ideal world you would be able to drag this shortcut directly to the Taskbar for it to appear as a clickable program. However for some weird reason this does not work.

To fix this a second shortcut is required! Don't ask me why just do it! In File Explorer right click on "CloseRDP.bat - Shortcut" and select "Copy". Now right click in some empty space again and select "New > Shortcut". In the "Type the location of the item box" manually type "explorer " and then press Ctrl+V to paste the name copied earlier. It should look like this:
Click "Next" and give the shortcut a name. I've called mine "Pinable CloseRDP". There are now three files in the folder that should look like this

Now the icon for "Pinable CloseRDP" has the normal boring File Explorer icon. I like to change this to something that stands out better so right click on "Pinable CloseRDP" and select "Properties". Click on the "Change Icon..." button and select one of the default icons. I normally go with the red cross. Click OK twice to return to File Explorer. File Explorer should now have three files that look like this:

Now, after all these steps, you can finally drag the "Pinable CloseRDP" and drop it onto the Taskbar. You should now have a nice clear button that you can click to close the remote session and return the desktop to the original user.

If you are really keen you could design a custom icon to make it even clearer. When you click on you new icon you will be prompted for the Administrator password, the remote session will close and the desktop will return to the local user session without any password prompt.

Good luck, there are quite a few steps but it does work well if you follow them carefully.


Friday, March 02, 2018

WPF Blurry Pixels

Today I needed to create a small control for the status bar of my app. It needs to be small to show the pass/fail status of 96 items.

I had an ItemControl displaying the 96 items as 4 rows of 24. I started with this code but it was horribly blurry and irregularly spaced.

<Rectangle Width="4" Height="4" Margin="1,1,0,0" Fill="Green" />





 
To get it to display nicely with no blurry edges I changed the code to this...
<Rectangle Width="3.84" Height="3.84" Margin="0.96,0.96,0,0" Fill="Green" />
 
 
 
 
 
It's because WPF assumes 96 pixels per inch. By changing the size to be multiple of 0.96 you can trick WPF into drawing complete pixels.