Back on an electric motorbike!

It’s been about 2 years since I was involved in a collision on my Zero FXS electric motorbike. I really liked the bike and I had no intention of selling it, but there was a tiny amount if damage to the frame and my insurance company decided they would write it off. I’m sure this was a financially motivated decision, but as it was a category B so I wasn’t allowed to buy it back and put it back on the road.

First – a petrol bike

Once I’d recovered, I decided that I’d go for something different. I went back to a petrol bike – a really nice Ducati Hypermotard 950. One of the main reasons for switching from electric back to petrol was insurance. There were only one or two insurance companies that cover electric bike, so you end up being at their mercy if the decide to randomly increase your insurance one year. All insurance companies seem to do this, but at least if you have a reasonable choice, you can shop around.

Here’s a picture of (someone else’s) Hypermotard 950

I’ve thoroughly enjoyed the Ducati – even though I’m sure I swore I’d never one one again! (I used to have a 748 and then a Monster S4.)

An electric itch…

Just around the time I bought the Hypermotard, Zero Motorcycles really upped their game with the new Zero SR/F for 2019. It had a bigger motor than my old FXS, a bigger battery, a nice colour TFT dash. It was really lovely – but expensive. I’d only paid about £9000 for my ex-demo Ducati, so the list price of £19,500 was a bit steep. I test rode one, but parked it as “maybe one day”.

Once again – someone else’s Zero SR/F

Over the last few months, I’d started seeing the odd SR/F (and faired SR/S) for some slightly more reasonable prices. A few secondhand ones popped up for £15k-ish. I decided to keep an eye on things and made a vague mental note that maybe a £13k secondhand bargain might be the trigger point.

It was meant to be!

Anyway, one weekend whilst camping with the family at the surprisingly good Carfest I received an interesting email. Car’s aren’t really my thing so when I got a email from Zero Motorcycles it took my attention away from the cars. When I read that as a loyal Zero customer they would offer me £2500 off a new SR/F I knew exactly what I would be doing when I got home!

I ended up test riding both a Zero SR/F and an Energica Eva at the excellent and very friendly electic-only Spark Motos near me in Addlestone. It seems that 21St Motor (where I got my FXS) no longer sold electric bikes. I was pleasantly surprised to find I preferred the Zero to the significantly more expensive Energica.

Anyway, I would have been keen to keep my business with the helpful local delaer who provided a test ride, but they just couldn’t get close to the £3000 off a 2019 model from another dealer. Considering the oly difference between the 2019 and 2020 models was teh choice of colours, and the fact that they could combine this with my £2500 voucher, that meant I snagged a Zero SR/F Premium for only £14k!

Electricity and petrol?

Remember hos I said that the Ducati was also a nice bike? Well, it turns out I have a nice wife too. She wasn’t exactly happy about it, but reluctantly agreed to me keeping the Ducati alongside the Zero. So, here they are – in matching red!

This time they are my bikes!

A good reason for not blogging for a while

I realise I haven’t posted much here for a while. Mainly I haven’t blogged much because I have a new job. I’d been stuck in my previous job for almost 10 years. It started out as fun, but I must admit that the last year or so I stuck it out because it was a mile from home and near my kids’ schools. The commute was a real selling point. I liked my colleagues too.

Anyway, I jumped ship and ended up in a new job at a company called Creative Technology where I not only code (as I used to) but the work also covers lots of physical builds and crosses over into embedded development and electronics too. I’m absolutely loving the job because it so different from the usual sort of development I’ve been doing and it also encompasses the stuff I did as a hobby. Basically I’m still doing the sort of things I used to blog about but not it’s for work.

Technically I’m still under NDA so can’t say exactly what I’m working on, but these are a few of the technologies I’ve been working with.

  • .NET Core, Blazor
  • AWS
  • Interfacing with Unreal and Unity game engines
  • Industrial robot programming
  • Embedded development
  • Hardware prototyping

I’ll also find myself doing random stuff like testing VR headsets, evaluating Ultrahaptics (using an array of ultrasound to make you “feel” things in VR that aren’t there), using laser safety scanners.

Basically I’ve been doing lost of cool stuff but I can’t really blog about it at the moment.

I’ve also been getting into FPGAs, but that’s mostly been to do with Element14 so I’ve posted that over there – such as this review of a Spartan-7 development board. or reverse engineering an FPGA-based cryptominer board.

Anyway, sorry I’ve not been posting, but I have still been having fun. I’m sure I’ll write some of it up one day when I’m allowed to.

NFC antenna tuning without a VNA

Recently I started work on a new board. This one will be a front door entry system, so I decided to go with something that could read my NFC implant but also had a numeric keypad for the kids (and anyone else) to use. Not everyone wants to be chipped. Crazy, isn’t it? I’ll write more up on the board when it gets closer to completion, but for this post I’m going to concentrate on a small PCB antenna that’s intended for use with a tiny implanted tag. I’ve successfully used a wirewound inductor before, but I decided it was time to try a PCB trace antenna. This is the most common way to make an NFC reader, but nobody seems to have tried to tune one for an implant – probably because it means it will be worse at reading larger tags. Anyway, this is about creating a small PCB antenna and more importantly tuning it so that it read well.

IMG_20181025_215846So, this is the PCB. It’s based around a MSP430FR2633 for it’s great capacitive sensing for the buttons. There is also a TRF7970A NFC transceiver as I’m familiar with this. You may also notice that I’ve gone for a reverse mount RGB LED that shines through that unmasked piece of the board. I’m really pleased with how that works. Check out this video of the buttons in action to see if you agree.

No VNA?

The NFC part also worked fine, but I must admit the range and sensitivity wasn’t great. I had calculated that the PCB antenna should have an inductance of about 1μH so I just used the same matching components that worked well previously. What I really needed to tune the matching circuit was a Vector Network Analyser (VNA). Unfortunately these are very expensive and I’d likely only ever use one for this. Is there another way? Well, luckily I came across an article entitled “Impedance matching for 13.56 MHz NFC antennas without VNA” which seemed to be just what I was after. Then only slight problem was that I needed an accurate measurement of the impedence of the PCB trace – by which I mean it’s inductance and resistance. I needed to buy a slightly less expensive piece of equipment – an LCR meter. I went for the DER DE-5000 which I must say I’m extremely happy with.

Measuring and calculating

So it turns out that the PCB trace I expected to be about 1μH turned out to be 0.627μH with a resistance of 0.867Ω – otherwise expressed as 0.867 + j53.42Ω. The article suggested a parallel resistor of 362Ω so i went with the closest I had of 470Ω. Calculating the parallel and series capacitances seemed trickier. I ended up using some Smith Chart software from Fritz Dellsperger. and to be honest I sort of went with trial, error and adjustment to try to get the final point as near to 50Ω as possible. I managed a theoretical 54.973 – j1.455Ω

Smith chart

I approximated the parallel  capacitance to 100μF + 47μF = 147μF and the serial to 68μF + 15μF = 83μF. With the measured value of my PCB trace and the matching components I had it had been 8.847-j135Ω. No wonder it wasn’t great!

The end result

Whilst reworking the board I measured the lowish tolerance capacitors I was using and by selecting the most appropriate ones I ended up a little bit closer to my goal. Did it work? You bet it did. I must admit I was surprised how well. Just as I was surprised when the reader and keypad worked too. Maybe I should have a bit more confidence in these things (and myself).

Getting into FPGAs

minized20reset20corner20viewSo, I obviously decided that my world wasn’t already filled with enough random stuff. I decided that it would be a good idea to get my head around FPGAs. I’m sure many of you know what FPGAs are but just in case you don’t I’ll give you a quick summary. A Field Programmable Gate Array is user defined hardware. If you decide that you need some logic (e.g. an AND gate) you could use a discrete logic gate – hello 74LS08. You could of course use a microcontroller which might even be cheaper than the logic gate. Weird, but it’s starting to be true.

The other way is to have a big ball of programmable logic that you can configure however you want. Powerful, flexible, fast. Bizarrely, you can even program enough logic to create an processor. Yes, you can create (via software) some hardware that will run software. This is just a taste of how strange the world of FPGAs can get.

I asked a few questions about the easiest way in and got loads of different answers. Anyway, someone was kind enough to send me an Arty S7 FPGA board that he’d finished with. There is a course going on at Element 14 all about programming FPGA SoCs – that’s a chip with a microprocessor and some FPGA in one. So I bought a MiniZed.

I’ve only just started, but already it’s quite a trip. An FPGA is usually programmed in either VHDL or Verilog. They’re both languages that look a bit like a programming language but really aren’t. I’ve heard the learning curve described as “the cliff of insanity” and I’m starting to know how that feels. Anyway, the journey so far is strange but I’m enjoying it. I never did ask if you start at the bottom of the cliff and climb it or if you start at the top and fall off.

Rohde & Schwarz RTM3004 review

I finally finished my review and road test of the Rohde & Schwarz RTM3004 oscilloscope. For those that don’t know, that’s a very high-end 1GHz oscilloscope. It’s a mixed signal oscilloscope (4 analog and 16 digital channels). It’s also got a built-in function and pattern generator. There’s also some really nice FFT and Spectrum Analysis functionality. It’s got a great 10″ touch screen.

RM3K with Keysight and RigolBasically it’s amazing compared to the Keysight DSOX1102G and Rigol DS1074Z that I’ve been used to. There’s nothing wrong with these two ‘scopes of course. It’s just that if they’re a nice family car, then I feel I’ve just been asked to drive around in a Ferrari for a month and write about it. Oh yeah – and you can keep the Ferrari when you’re done. As you can imagine, I’m quite happy about it.

I won’t reproduce the full road test here on the blog. If you’re interested in reading all about it then you can head over to Element14. If you’re after a video summary of the features then here you go.

Working on a oscilloscope review

You know how it can be sometimes. You’re working on one project, then it gets bumped by another. Sometimes that one gets bumped by a higher priority one. Your life is like a nested interrupt handler.

My latest project is moving my MSP430-based NFC reader over to the CC1310. It’s been competing with converting a garage into the noisy, smelly power tools and CNC side of my workshop setup.

img_20180603_112827638539278.jpgI’m very pleased to tell you than something more urgent had come up that has stalled these two. Rohde & Schwarz have asked me (via Element14) to road test one of their latest oscilloscopes – the incredible RTM3004. Even better, I get to keep it afterwards. This is a high end 1GHz 4 channel ‘scope with a 16 channel logic analyser, signal and pattern generator, spectrum analyser and loads of other features.

As you can imagine I feel obliged to put a reasonable amount of effort into this, although to do it in a fair and unbiased way. I’ve already started but I expect to spend at least another month of my free time on it. Stay tuned for the results which will appear on full over on Element14 but have a summary and link here too.

It’s been quiet here!

So, it’s been very quiet here on the blog for a while. It’s fairly likely that nobody had noticed, and very likely that nobody was too bothered. Anyway, I’m going to try to get back to it.

home

Getting ready for Christmas

The reason is simply that a few months ago we moved house. On the plus side we’ve moved to somewhere quite a bit bigger. On the down side it means that my lovely workshop that I spent months getting just how I liked it is no more. More accurately it’s someone else’s.

In theory I have more space for my geeky stuff, but it’s different space. Currently the desk-based stuff (coding, soldering) has moved inside. Much warmer in this cold “spring that thinks it’s winter” weather. The noisy smelly stuff like the CNC mill and laser are still in the garage and right now are still in boxes. General DIY and moving stuff means that it’s likely to stay there for a little bit longer too.

new workspace

My new electronics / coding space

Anyway, I am going to get back on the case. Coming soon – shifting my focus from MSP430 16 bit microcontrollers to TI’s 32 bit ARM offerings. I think I’ve decided that the home stuff I build need to be networked and our new place seems to be very unfriendly to 2.4GHz. The CC1310 may become my “go to” device. It’s a Cortex M3 with built-in sub 1GHz radio (on an M0 core) and even has a little 16-bit microcontroller on the side just to do sensor stuff with the main cores asleep. Very nice. Of course, that means RF stuff and more QFN soldering, but you have to progress.

Philips Hue – control anything hack

To be honest, my recent simple relay hack wasn’t really all that great. It just used the high power constant current output to drive a SSR. It wasn’t ideal, but it worked. I decided that it was worth the effort to track down some more useful outputs and properly detect the desired state of the bulb.

b22_closeupAll it took was a little bit of poking around and probing the pins of the SAM R21 microcontroller with an oscilloscope. It wasn’t actually that hard. On the B22 bayonet fitting version of the bulb I found some.

PA16 (pin 17 of the microcontroller) has a simple on/off output. It’s high (3.3V) if the light is on  at all and low if not. This is the perfect output to use to drive a simple output for a relay. It can be run straight to a SSR if that’s appropriate for your load. Or it can be used as an input to another microcontroller, a transistor to drive a relay, etc. This is probably the easiest one to use for a simple load. A slightly easier place to access it is on the end of diode D3 nearest the micro. It’s still some fiddly soldering, but it’s easier that a QFN pad on the SAM R21 itself.

PA17 (pin 18 of the microcontroller) has a decent PWM output. Unlike the one I found on TP5 of the E27 bulb, this stays high when the bulb is 100% on. It’s a 3.3V signal. It doesn’t seem to be quite linear – i.e. 50% brightness isn’t a 50% duty cycle but this may be deliberate to compensate for how bright it actually looks.

TP25 has a DC voltage of about 14V which is fed to the LM2204 3.3V regulator. This seemed handy for driving the coil of a 12V relay.

I rigged up a simple relay circuit – using the 3.3V PA16 output to drive a NPN transistor that can then drive the relay. Add the usual flyback diode (and a MOV across the relay contacts for the benefit of inductive loads) and all is g0od!

Poor post sales service from Zero Motorcycles

If you want the tldr version

I’m now a Zero owner, but not yet a Zero rider. I paid for a Zero FXS 8 weeks ago. Due to Zero’s errors, the process of registering it in my name hasn’t even started yet. In that time the price dropped £900. Zero won’t talk directly to me but have said via the dealer that it’s tough luck. They’ve got my money and don’t really care about either.

The full story…

After my test ride of a Zero FXS it was only a matter of time before I got one. The things up in the air back then were:

  1. What’s going to happen with the long-promised UK electric motorcycle grant?
  2. What have Zero up their sleeves for 2017?

In October the grant was announced as starting from 1st Jan 2017. And in November Zero announced that there were a few changes to the 2017 line up, but nothing huge. For the FXS it was really just a wider drive belt and a higher amperage controller. No battery or motor changes.

This was enough for me to order and pay for a FXS on 17th December. Zero listed the 2017 as £9890 (after grant) and had a £1500 off offer on the remaining 2016 models. The 2017 models were going to be available for a few months but the 2016s were in stock. Let me see… £1500 cheaper and available immediately? Easy decision. I went for the 2016 FXS and paid my £8390. The dealer told me I’d have it by early to mid January just after the grant came into force. Perfect.

Balls-up #1

So. Early in January my shiny new bike arrived at the dealers. Yay! But the paperwork didn’t. What? How can a letter take longer than a huge crate? Zero hadn’t sent it, that’s why. Why not put it in the crate FFS? It eventually arrived a few days later.

Balls-up #2

Now, in the UK you need insurance to register a vehicle so I transferred the insurance over from the Aprilia Dorsoduro that I was trading in. Registration normally takes a week or so. I picked 21st January to allow 2 weeks to make sure the DVLA did their stuff. The dealer was happy to let me do this because – well why not? It was only after I’d done this that Zero revealed that well… they hadn’t actually sorted out eligibility for the UK grant at all. No way I’d get my FXS registered by the 21st. This left me uninsured on my Dorsoduro from that date.

My insurance company (Wicked Quotes) only wanted about £100 a year to insure either bike, but admin fees to change things were a different matter. As if the £50 to change it over wan’t bad enough, changing it back for a bit would cost at least £100 and they couldn’t guarantee that my premium on the final change wouldn’t increase. Considering they had quoted me £238 a year at an earlier date, I sense a trap. Anyway, it just wouldn’t be practical to change it. I was now insured on a Zero I couldn’t have and uninsured on an Aprilia that I did.

Oh well, bikeless for a week or two and riding uninsured on the swap-over trip to the dealers. I can live with that I suppose. Just need to make sure I avoid any cameras.

Balls-up #3

So on the 23rd January the grant was finally sorted. Registration underway! A week later I got a call. Registration rejected! What??? Apparently the “certificate of arrival” that is part of the import process had a US formatted date on it. Instead of saying 7th January (07/01/2017), it said 1st July (01/07/2017). The DVLA couldn’t handle this, and better yet, it was an official document that couldn’t be altered. It had to be redone. More delays. Now I don’t know exactly what this form is all about, but as Zero are the only Americans in the whole chain I have my suspicions as to who got it wrong.

Slap in the face #1

Just as this was happening I got a lovely promotional email from Zero. A 2017 FXS for the great price of… £8990. What? Only £600 more than I paid for the £1500-discounted 2016. Now we’ve all bought something that goes on sale later. That’s life. I wouldn’t complain about that. What really irks me is that this price drop is before the 2017s even available – they never were £9390. And it’s before I’ve even registered (due to Zero’s mistakes) my 2016.

I went for a 2016 because it was £1500 cheaper (not really) and available straight away (again no). I dropped Zero an email and copied in my dealer – the totally faultless 21st Moto in Swanley, Kent.

Slap in the face #2

Zero didn’t think it necessary to reply to me. After the dealer chased them Zero Europe said they’d see what they could sort out with Zero USA. After yet more chasing, I got a reply via the dealer.

  • Could I drop this 2016 (with a serious known issue I discovered described here) and take a 2017 instead? No.
  • Would they do anything about the price I paid or the problems they caused? No. Tough.

I was very close to seeing if I could cancel this whole thing, but decided this would be cutting off my nose to spite my face. I’d paid for it so probably couldn’t. And anyway, if anything the dealer would probably end up losing out.

I had also agreed to do some promotional stuff with the Motorcycle Industry Association to publicize the UK grant. I was after all the first person to make use of it. (Free publicity for Zero too!) It would seem unfair to let them down.

Something nice to say at last

Well, after all that ranting I can at least add some positive things to the mix. As I said, 21st Moto have been great throughout all this. Rob was dealing with all this and I know the problems weren’t anything to do with them. Even so, they felt bad about it all and have offered to drop £250 off the price out of their pocket. I kinda feel bad taking this as I have no problem with the dealer at all. As Rob said though, the buck does stop with them from a consumer’s point of view. They are they ones that have to deal with Zero.

Thanks, Rob and 21st Moto. Despite all the hassle I’ve had I can thoroughly recommend them. If the awesome silent power of an electric motor ever gets stale and I feel the need for a roar of a petrol engine, then I’d definitely be heading there with my cash for a Honda.

Hopefully only a few more weeks to go. (It’s now so close to the new 17 registration on 1st March I decided to go for that.) Once I’m on the bike I’m sure this will be a dim memory. And the weather’s not exactly been bike-friendly lately – below freezing with snow and ice.

Philips Hue – simple relay hack

img_20170102_162008OK, so I said I’d start simple but this is about as simple as it gets. I’m almost embarrassed it’s not a little more complicated. I’ve done a teardown of a LBW010 bayonet fitting bulb and thought I’d take a look at its E27 screw-in cousin. (I’ll post this teardown later, but here’s a photo to give you the gist of it.) You can see the main board in the centre and the LED board that I’ve removed. It was similar to the B22 but quite different too.

Coming in from the left in the main photo below are the Hue mains connections – blue neutral and red live. My apologies about the mixed colour schemes but those were the wires I had to hand. Heading out on the right are the positive (red) and negative (black) that normally run to the LED PCB. All I’ve done is connect these directly to the input of a solid state relay. That’s it.img_20170104_212708

So why is this hack a little blunt? Well the four wires you see that aren’t connected are my far more sophisticated attempt to dig out some useful logic signal from test point on the PCB. There’s some nice stuff there. I thought I’d use a PWM output I found on TP5 to drive the SSR. It was almost enough but I hit a small snag. (Currently it works as expected between 1 and 100% but irritatingly switched the SSR on when at 0%.) I thought about leading these to a logic circuit, maybe even another microcontroller.

Then I saw the 3-32V input on the SSR. 32V?? That’s a little bit more that the Hue puts out the the LEDs. Could I? Yes, I could. The Hue outputs are used to driving 260mA at about 31V so with minimal load it actually reached about 37V, but it seemed to work fine. I’m using a constant current driver to drive a low impedance and just getting lucky that the voltage limit is being hit. I know that’s not sensible.

So basically , rip the bulb apart, connect it to a SSR and you can now drive any mains lighting you like! It should work with the B22 and maybe even the GU10 bulbs too, but these single colour bulbs are the cheapest.

Things can certainly be done a little better and it will be. For instance:

  • I could use a voltage divider to tame that 37V a bit.
  • I could drive a normal relay if I added a  suitable series resistor and a flyback diode. SSR have problems driving some loads – ironically LED drivers being one of them.
  • I could dig further into that PWM signal and properly detect the power level of the light, maybe driving more than one relay or SSR.

Anyway, all this will come but I thought this simple hack was worth sharing as-is.

UPDATE: A better way to get to a decent signal to control anything (using a B22 bulb) here.