How to Harvest Infinite Power!

By: Henry Wadsworth
Project Engineer

9th May 2019

6 minute read

Home » Insights » Engineering

Wouldn’t it be amazing if an electronic device could run forever, for free, on an unlimited supply of energy? No batteries to replace and no plug socket to be tethered to. This might seem like a flight of fancy, but with modern energy harvesting techniques, it is a much more realisable dream.

Energy harvesting is the capture and storage of energy from the environment which can be used to power an electronic device. This is not a new idea, we are all familiar with the idea of using solar panels to charge a battery, but there are many other energy sources to take advantage of such as kinetic, thermal, and electromagnetic energy. Kinetic energy such as that produced by wind can easily be harvested using a turbine, but even vibrations can be converted into a voltage using a piezo-electric transducer so any form of movement has the potential to power electronics. Thermal energy can be converted into electrical energy using a thermoelectric generator (TEG) which is able to produce energy from heat which would normally be lost to the environment. Electromagnetic energy is present all around us, for example, in the form of radio waves and microwaves which we rely on for wireless communications from WIFI to FM radio. In most circumstances this amount of energy is so small that it cannot readily be captured and stored, however, if a device is located within a reasonable distance of a powerful transmitter, it is possible to provide enough energy to keep a low-power device alive.

This is especially the case with modern integrated circuits designed for power harvesting which are enabling increasingly tiny amounts of energy to be gradually accumulated over time in a battery, or super-capacitor in order to power a low-power device almost indefinitely while the energy source is present. In many cases it is also possible to combine multiple energy harvesting sources, which can be useful in environments where the energy sources may be changing, such as if the device is moving through different environments. For example, solar could be combined with piezo-electric, so that the device can harvest sunlight when the sun is visible, and vibration energy when the device is being moved (perhaps the device is worn by a human, or transported on a vehicle).

Energy harvesting typically refers to small scale harvesting of energy as described above, however, larger power sources can also be harnessed. For example, the power flowing through a cable can be harnessed by placing a current transformer around the cable. We recently developed a system using this technology to supply energy in an underground environment where no other power supply was reliably available. This can be a useful way of retro-fitting a device where power cables already exist, but with no other convenient way to tap the energy from the cables. This method has the potential to supply large amounts of power to a device, depending on the amount of current flowing through the cables.

Energy harvesting is a particularly valuable technique for circumstances where it is not possible to carry out maintenance on a device to replace a battery. For example, the device may be inaccessible or just impractical and expensive to access if there are a large number of devices – which is likely to become an increasingly significant problem as inexpensive IOT devices are used for large monitoring networks.

Energy harvesting techniques are becoming increasingly sophisticated which, coupled with a low power microprocessor makes it possible to power devices with energy sources which previously would be considered impractical.

Further Reading

Making a LiDAR – Part 5

Unity Point Cloud Rendering

By: David
Principal Consultant, Data Exploration

12th April 2019

4 minute read

Home » Insights » Engineering

Unity Point Cloud Rendering

Now we’ve got our LIDAR finished, and our first scan completed, we are left with an SD card with some data on it. The data is a list of several million points (called a point cloud) represented in polar spherical coordinates. Each point represents a target distance from the centre of the LIDAR scan. In its own right, this isn’t very exciting, so we need to find a way to visualise the data. Quite a few people have contacted me to ask how I did this, so unlike the previous “philosophical” LIDAR blogs, this one will go into a little more technical detail. So, if you’re not interested in driving 3D rendering engines, then skip the text and go straight to the video!

I’ve chosen to use the Unity game engine, and this is a software tool targeted at creating 3D video games. It handles the maths and graphics of 3D rendering, it provides a user interface for configuring the 3D world, and it uses the C# programming language for the developer to add “game logic”. If you know Unity, this blog should give you enough information to render a point cloud.

An object in the Unity world is called a GameObject, and each game object represents a “thing” that we can see in the 3D world. We also need to create a camera, and this gives the user the view of the 3D world. It’s straight forward enough to write some C# code that moves and rotates the camera in accordance with mouse and keyboard input. If we fill the world with GameObjects, and we move the camera through the world, then Unity takes care of the rest.

A GameObject is made of a 3D mesh of points to define its shape. The mesh can be anything from a complicated shape like a person, to a simple geometrical shape like a sphere. The developer needs to define a Material which is rendered on the GameObject surface, and a Shader to determine how the Material surface responds to light.

The obvious way to render the LIDAR data is to create a sphere GameObject for each LIDAR data point. This produces wonderful 3D images, and as the user moves through the point cloud each element is rendered as a beautifully shaded sphere. Unfortunately, because each sphere translates into many points of a 3D Mesh, and because we have several million LIDAR data points, that’s a huge amount of work for the computer to get through. The end result is a very slow frame rate which isn’t suitable for real time. For video generation, I configured Unity to generate frames offline, but 1/24th of a second apart in game time. The result is a series of images that can be stitched together to make a fluid video sequence.

I thought it would be fun to view the LIDAR world through the Oculus Rift headset, but here we require very high frame rates so offline rendering isn’t going to work. Rather than plotting each LIDAR point as a GameObject, I used a series of LIDAR points (about 60k worth) to define a single Mesh to make one GameObject. The GameObject then takes the shape defined by the 60K set of scanned LIDAR points. The GameObject Mesh requires a custom Shader to render its surface as transparent, and each Mesh vertices as a flat 2D disk. This allows us to reduce the number of GameObjects by a factor of 60K with a massive drop in CPU workload. The total number of GameObjects is then the number of LIDAR data points divided by 60K. The downside is that we lose the shading on each LIDAR data point. From a distance that still looks great, but if the user moves close to a LIDAR point the image is not quite so good. The advantage is a frame rate fast enough for virtual reality.

As a final node, it is quite a surreal experience to scan an area, and then view it in virtual reality through the Oculus Rift headset. It is quite the shame that the reader can only see the 2D video renders. The best way I can describe it is analogues to stepping into the Matrix to visit Morpheus and Neo!

Now we’ve got our LIDAR finished, and our first scan completed, we are left with an SD card with some data on it. The data is a list of several million points (called a point cloud) represented in polar spherical coordinates. Each point represents a target distance from the centre of the LIDAR scan. In its own right, this isn’t very exciting, so we need to find a way to visualise the data. Quite a few people have contacted me to ask how I did this, so unlike the previous “philosophical” LIDAR blogs, this one will go into a little more technical detail. So, if you’re not interested in driving 3D rendering engines, then skip the text and go straight to the video!

I’ve chosen to use the Unity game engine, and this is a software tool targeted at creating 3D video games. It handles the maths and graphics of 3D rendering, it provides a user interface for configuring the 3D world, and it uses the C# programming language for the developer to add “game logic”. If you know Unity, this blog should give you enough information to render a point cloud.

An object in the Unity world is called a GameObject, and each game object represents a “thing” that we can see in the 3D world. We also need to create a camera, and this gives the user the view of the 3D world. It’s straight forward enough to write some C# code that moves and rotates the camera in accordance with mouse and keyboard input. If we fill the world with GameObjects, and we move the camera through the world, then Unity takes care of the rest.

A GameObject is made of a 3D mesh of points to define its shape. The mesh can be anything from a complicated shape like a person, to a simple geometrical shape like a sphere. The developer needs to define a Material which is rendered on the GameObject surface, and a Shader to determine how the Material surface responds to light.

The obvious way to render the LIDAR data is to create a sphere GameObject for each LIDAR data point. This produces wonderful 3D images, and as the user moves through the point cloud each element is rendered as a beautifully shaded sphere. Unfortunately, because each sphere translates into many points of a 3D Mesh, and because we have several million LIDAR data points, that’s a huge amount of work for the computer to get through. The end result is a very slow frame rate which isn’t suitable for real time. For video generation, I configured Unity to generate frames offline, but 1/24th of a second apart in game time. The result is a series of images that can be stitched together to make a fluid video sequence.

I thought it would be fun to view the LIDAR world through the Oculus Rift headset, but here we require very high frame rates so offline rendering isn’t going to work. Rather than plotting each LIDAR point as a GameObject, I used a series of LIDAR points (about 60k worth) to define a single Mesh to make one GameObject. The GameObject then takes the shape defined by the 60K set of scanned LIDAR points. The GameObject Mesh requires a custom Shader to render its surface as transparent, and each Mesh vertices as a flat 2D disk. This allows us to reduce the number of GameObjects by a factor of 60K with a massive drop in CPU workload. The total number of GameObjects is then the number of LIDAR data points divided by 60K. The downside is that we lose the shading on each LIDAR data point. From a distance that still looks great, but if the user moves close to a LIDAR point the image is not quite so good. The advantage is a frame rate fast enough for virtual reality.

As a final node, it is quite a surreal experience to scan an area, and then view it in virtual reality through the Oculus Rift headset. It is quite the shame that the reader can only see the 2D video renders. The best way I can describe it is analogues to stepping into the Matrix to visit Morpheus and Neo!

Further Reading

Making a LiDAR – Part 4

Electronics Prototyping, and getting a graduate job at Plextek

By: David
Principal Consultant, Data Exploration

11th April 2019

3 minute read

Home » Insights » Engineering

Electronics Prototyping, and getting a graduate job at Plextek

Since I first picked up a soldering iron I’d say there have been two significant changes in electronics; the parts have got smaller, and my eyesight has got worse. With the advent of surface mount, I did fear we were entering an educational dark age. It became beyond the scope of the hobbyist to create PCBs and solder the parts. Luckily, I think all that’s changed, and there has never been a better time for both commercial prototyping and hobbyist experimentation.

As I described in the previous blog, I’m very much a fan of the STM32 platform, and ST Microelectronics have produced some terrific prototyping boards. In fact, the same is true for every major player in the microcontroller market. All these boards have in common low cost and bring out fine pitch surface mount packages to user-friendly headers.

For around £10 I can visit RS components, and buy a very capable STM32 prototyping board with all of the microcontroller’s features our LIDAR will need. With the addition of a few breakout boards, we can test and prototype all the electronics for our LIDAR without ever having to touch a soldering iron or make a PCB.

We do still have one problem, and that’s because our initial prototype can end up a bit of a mess. All those prototype and breakout boards can leave a “rats nest” of wires, it’s fragile, and it’s probably too big. Luckily, rapid and low-cost PCB production has also come a long way. We’ll take advantage of this for our LIDAR electronics.

A quick visit to one of the far Eastern PCB prototyping houses shows I can get 10 copies of a small custom two-layer PCB for $5 plus shipping. Pushing to 4 layers and it’s only $49 plus shipping. I really have no idea how they make it commercially viable! If you’re concerned about quality and security, a European PCB house isn’t that much more expensive. Of course, you still have to design and solder the PCB, but with a copy of Eagle, a visit to YouTube, a low-cost USB microscope, and a rework gun, you’d be surprised how easy it is. Surface tension is your friend!

So what’s my message from this Blog? Well, over the years I’ve become more and more involved with graduate recruitment, and it’s often a long and frustrating process. I’ve become very impressed by the extent of knowledge and understanding our young potential recruits have, but they generally are not so confident about demonstrating these abilities. So, if you’re keen on a career in embedded electronics, then my challenge to you is to get yourself noticed. Buy yourself some prototyping boards, build some embedded projects, and look on the internet to find out how to do it. Bring them with you to your interview, and show us what you’ve done. I promise if you do that, you will stand head and shoulders above the crowd.

Since I first picked up a soldering iron I’d say there have been two significant changes in electronics; the parts have got smaller, and my eyesight has got worse. With the advent of surface mount, I did fear we were entering an educational dark age. It became beyond the scope of the hobbyist to create PCBs and solder the parts. Luckily, I think all that’s changed, and there has never been a better time for both commercial prototyping and hobbyist experimentation.

As I described in the previous blog, I’m very much a fan of the STM32 platform, and ST Microelectronics have produced some terrific prototyping boards. In fact, the same is true for every major player in the microcontroller market. All these boards have in common low cost and bring out fine pitch surface mount packages to user-friendly headers.

For around £10 I can visit RS components, and buy a very capable STM32 prototyping board with all of the microcontroller’s features our LIDAR will need. With the addition of a few breakout boards, we can test and prototype all the electronics for our LIDAR without ever having to touch a soldering iron or make a PCB.

We do still have one problem, and that’s because our initial prototype can end up a bit of a mess. All those prototype and breakout boards can leave a “rats nest” of wires, it’s fragile, and it’s probably too big. Luckily, rapid and low-cost PCB production has also come a long way. We’ll take advantage of this for our LIDAR electronics.

A quick visit to one of the far Eastern PCB prototyping houses shows I can get 10 copies of a small custom two-layer PCB for $5 plus shipping. Pushing to 4 layers and it’s only $49 plus shipping. I really have no idea how they make it commercially viable! If you’re concerned about quality and security, a European PCB house isn’t that much more expensive. Of course, you still have to design and solder the PCB, but with a copy of Eagle, a visit to YouTube, a low-cost USB microscope, and a rework gun, you’d be surprised how easy it is. Surface tension is your friend!

So what’s my message from this Blog? Well, over the years I’ve become more and more involved with graduate recruitment, and it’s often a long and frustrating process. I’ve become very impressed by the extent of knowledge and understanding our young potential recruits have, but they generally are not so confident about demonstrating these abilities. So, if you’re keen on a career in embedded electronics, then my challenge to you is to get yourself noticed. Buy yourself some prototyping boards, build some embedded projects, and look on the internet to find out how to do it. Bring them with you to your interview, and show us what you’ve done. I promise if you do that, you will stand head and shoulders above the crowd.

Further Reading

Making a LiDAR – Part 3

Embedded Software and Platform Choice

By: David
Principal Consultant, Data Exploration

10th April 2019

3 minute read

Home » Insights » Engineering

Embedded Software and Platform Choice

Do you remember as a child counting how long it took for thunder to arrive after the lightning flash, and then working out how far away the storm was? Well, a LIDAR uses the same principle but with light rather than sound. I think that’s amazing. Imagine switching a torch on, pointing it at the wall in front of you, and using a stopwatch to time how long it takes for the light to get reflected back to you. That seems ludicrous, but that’s exactly what our laser range finder is doing. (Did you know that one light Nanosecond is approximately one foot in length? So, I’m about 5.66 light Nanoseconds tall.)

Now, at the back of our laser range finder we have some wires that carry the measured distance data (I2C for the technically minded), so the first job of our software is to read the data, and just like a digital camera we need to write it back to an SD card. We also need to worry about controlling the scanning stepper motors. If you’ve no experience of stepper motor control, it’s quite straight forward; each time you generate a pulse the motor moves a tiny fraction. If you generate a continuous pulse train the motors spins. If you count the number of pulses you know how far the motor has moved. It’s all very straight forward, and just the sort of task a microcontroller was made far.

However, before we get started we need to pick a microcontroller, and this is where it can get contentious. Whatever you choose; somebody else will tell you that you should have done it their way instead. In my opinion, that’s frustrating, and they are usually wrong. I’ll defend that by saying only one thing matters. You need to pick a technical solution that’s within your capability to deliver to, and ideally exceed, the expectations of the people paying you. The great thing about engineering is that there will be many equally good ways of doing that, so you’re only wrong if your way isn’t one of them!

Personally, I’m not too keen on Arduino. It’s great for hobbyists and proof of concepts, but I do find its “simple educational” environment constraining. Likewise, the thought of days wading through thousands of pages of data sheets is equally unattractive. I want to write the embedded code to make the LIDAR work; I’m not interested in writing the code to make the microcontroller work. That’s why my own choice is the STM32 microcontroller family and the STM32CubeMx tool. It lets me “auto-generate” the framework to configure the microcontroller, I don’t have to read every minutia of detail in the datasheet, and it gives me a professional IDE development chain with full visibility of exactly what the hardware is doing if I should need it..

To sum up, with an STM32 I can get the job done, and I can meet all expectations. But importantly, if a BeagleBone running a Python interpreter lets you get the job done, and leads your customers to success, then don’t let anyone tell you that you’re wrong. Of course, don’t be closed to new ideas either. Learning and exploration are what makes life interesting!

Do you remember as a child counting how long it took for thunder to arrive after the lightning flash, and then working out how far away the storm was? Well, a LIDAR uses the same principle but with light rather than sound. I think that’s amazing. Imagine switching a torch on, pointing it at the wall in front of you, and using a stopwatch to time how long it takes for the light to get reflected back to you. That seems ludicrous, but that’s exactly what our laser range finder is doing. (Did you know that one light Nanosecond is approximately one foot in length? So, I’m about 5.66 light Nanoseconds tall.)

Now, at the back of our laser range finder we have some wires that carry the measured distance data (I2C for the technically minded), so the first job of our software is to read the data, and just like a digital camera we need to write it back to an SD card. We also need to worry about controlling the scanning stepper motors. If you’ve no experience of stepper motor control, it’s quite straight forward; each time you generate a pulse the motor moves a tiny fraction. If you generate a continuous pulse train the motors spins. If you count the number of pulses you know how far the motor has moved. It’s all very straight forward, and just the sort of task a microcontroller was made far.

However, before we get started we need to pick a microcontroller, and this is where it can get contentious. Whatever you choose; somebody else will tell you that you should have done it their way instead. In my opinion, that’s frustrating, and they are usually wrong. I’ll defend that by saying only one thing matters. You need to pick a technical solution that’s within your capability to deliver to, and ideally exceed, the expectations of the people paying you. The great thing about engineering is that there will be many equally good ways of doing that, so you’re only wrong if your way isn’t one of them!

Personally, I’m not too keen on Arduino. It’s great for hobbyists and proof of concepts, but I do find its “simple educational” environment constraining. Likewise, the thought of days wading through thousands of pages of data sheets is equally unattractive. I want to write the embedded code to make the LIDAR work; I’m not interested in writing the code to make the microcontroller work. That’s why my own choice is the STM32 microcontroller family and the STM32CubeMx tool. It lets me “auto-generate” the framework to configure the microcontroller, I don’t have to read every minutia of detail in the datasheet, and it gives me a professional IDE development chain with full visibility of exactly what the hardware is doing if I should need it..
To sum up, with an STM32 I can get the job done, and I can meet all expectations. But importantly, if a BeagleBone running a Python interpreter lets you get the job done, and leads your customers to success, then don’t let anyone tell you that you’re wrong. Of course, don’t be closed to new ideas either. Learning and exploration are what makes life interesting!

Further Reading

Making a LiDAR – Part 2

The Holistic Design Problem

By: David
Principal Consultant, Data Exploration

9th April 2019

3 minute read

Home » Insights » Engineering

The Holistic Design Problem

I’m tempted to say that designing software for a word processor is easy, and whilst many will quite rightly disagree, my point is that a word processor software architect doesn’t have to think about anyone other than themselves and a few well published APIs (and perhaps the user interface if we are lucky, but that’s perhaps the subject of a different Blog!). It all gets far more complicated when we are designing something with electronics and moving parts. That’s because we have a set of disciplines with circular dependencies. The mechanical design team need to understand the limitations and requirements of the electronics and software, but that’s hard to do until the electronics and software teams understand the mechanics. In other words, we have a chicken and egg problem to solve.

We are going to build our Lidar with a laser range finder, and we will want to spin the range finder around on the azimuth, and after every 360 degrees, we will need to bump it in elevation. We could use DC motors, we could use gimbal motors, we could use stepper motors, or we could even use servos. Whatever we pick, we can be sure that we face choices that make things easier for one discipline and harder for another. We need to make the choice that is best for the design.

Our electronic designers might decide that the simplicity of a DC motor is rather attractive, but we have to ask if our software engineers are going to be grateful when they have to start counting rotary encoder pulses to figure out how much a DC motor has moved. Equally, the mechanical engineers will thank nobody when they have to add a rotary encoder to the design. In fact, everybody apart from the electronics engineers will much prefer a stepper motor (the precise movement of a stepper motor is implicit, so they are great for applications like 3D printers). So, with that all said, we will make a decision for our Lidar and use stepper motors. We’ve made our electronics more complicated, but we’ve saved on software effort, we’ve simplified mechanical design, and we have reduced the bill of materials.

With the stepper motor decision made, the mechanical design can start. We can also start writing our embedded control software and designing our PCBs – or can we? If you’re familiar with embedded microcontrollers you’ll likely know they are software configurable with a multitude of different functions, and with a choice as to which, functions appear on which pins. So here is our cross disciple problem again; we need to make sure the software engineers don’t make a bad decision. A wrong software decision at that start could force our PCB designers to try and route four signal lines between two 0.5 mm pitch pins. Equally, a bad decision on pinout by the PCB designers might have subtle but severe consequences to our software engineers.

Needless to say, my examples are of course tongue in cheek, but I’m sure you’ll understand the point I’m making. It’s a really important concept that design needs to be multidisciplinary and that success only comes with cross-domain decisions made by people that understand the complete picture.

I’m tempted to say that designing software for a word processor is easy, and whilst many will quite rightly disagree, my point is that a word processor software architect doesn’t have to think about anyone other than themselves and a few well published APIs (and perhaps the user interface if we are lucky, but that’s perhaps the subject of a different Blog!). It all gets far more complicated when we are designing something with electronics and moving parts. That’s because we have a set of disciplines with circular dependencies. The mechanical design team need to understand the limitations and requirements of the electronics and software, but that’s hard to do until the electronics and software teams understand the mechanics. In other words, we have a chicken and egg problem to solve.

We are going to build our Lidar with a laser range finder, and we will want to spin the range finder around on the azimuth, and after every 360 degrees, we will need to bump it in elevation. We could use DC motors, we could use gimbal motors, we could use stepper motors, or we could even use servos. Whatever we pick, we can be sure that we face choices that make things easier for one discipline and harder for another. We need to make the choice that is best for the design.

Our electronic designers might decide that the simplicity of a DC motor is rather attractive, but we have to ask if our software engineers are going to be grateful when they have to start counting rotary encoder pulses to figure out how much a DC motor has moved. Equally, the mechanical engineers will thank nobody when they have to add a rotary encoder to the design. In fact, everybody apart from the electronics engineers will much prefer a stepper motor (the precise movement of a stepper motor is implicit, so they are great for applications like 3D printers). So, with that all said, we will make a decision for our Lidar and use stepper motors. We’ve made our electronics more complicated, but we’ve saved on software effort, we’ve simplified mechanical design, and we have reduced the bill of materials.

With the stepper motor decision made, the mechanical design can start. We can also start writing our embedded control software and designing our PCBs – or can we? If you’re familiar with embedded microcontrollers you’ll likely know they are software configurable with a multitude of different functions, and with a choice as to which, functions appear on which pins. So here is our cross disciple problem again; we need to make sure the software engineers don’t make a bad decision. A wrong software decision at that start could force our PCB designers to try and route four signal lines between two 0.5 mm pitch pins. Equally, a bad decision on pinout by the PCB designers might have subtle but severe consequences to our software engineers.

Needless to say, my examples are of course tongue in cheek, but I’m sure you’ll understand the point I’m making. It’s a really important concept that design needs to be multidisciplinary and that success only comes with cross-domain decisions made by people that understand the complete picture.