Tuesday, 24 April 2018

Controlling DC motors with the TB6612FNG

I bought this H-bridge module containing the TB6612FNG chip (datasheet)

It is an interesting chip.

Points to note:

Tie the standby pin high

Otherwise you're going nowhere. It was not clear that there is no internal pull-up in the standby pin - it will float low, which turns everything off. 

PWM is not what it seems

There are three input signals per channel (x2 channels). These are labelled IN1, IN2 and PWM. All is not as it seems.
 I initially assumed that if the PWM pin is low, it would drive the output high-impedence (open-circuit) to allow a motor to run freely. This is not the case.

The free-running setting is actually PWM=high, IN1, IN2 = low.

This means, that when we drive it with a pulse-width modulation duty cycle, we don't want to be pulsing the PWM pin (which is counter-inutitve).

To drive in either direction, set PWM=high, and one of the inputs high, the other low.
To drive with <100 high="" in1="" in2="" leaving="" low.="" one="" or="" other="" p="" power="" pulse="" the="">
To activate the brake, set PWM=low, and the value of the other signals doesn't seem to matter.
To leave it free-running, set PWM=high and the other inputs low.

 We could pulse the PWM signal, but that would be activating the brake during the off duty-cycle.

 Raspberry Pi - some GPIO outputs are high on boot

A surprise to me was that on the Pi, some of the GPIO pins (not many) are high on boot. It is a (somewhat) documented behaviour. I didn't know about that, so I've managed to wire up the robot so that one of the motors runs on boot. This is undesirable as it means the robot tries to drive away while we connect the battery.

(NB: GPIO 7 is high on boot)

It's possible, however, to make it go low very early during the boot process. It seems that this is approximately 1 second after power-on on my Zero W.

It may be that there is a weak pull-up enabled at boot, and I could fix it by installing a resistor to provide a stronger "pull down", and still allow the pin to be high when I want it high.

Saturday, 14 April 2018

Eroadarlanda / Elways / Electric charging road in Sweden

What is it?

The world's first electric charging road "opens**" in Sweden. Near Arlanda airport. It can "charge***" "electric" cars while they are driving.
It is a massive press-release that appears to have hit a lot of mainstream media in the last couple of days (12 April 2018)


"Stretch of road outside Stockholm transfers energy from two tracks of rail in the road, recharging the batteries of electric cars and trucks"

They certainly seem to have an excellent PR agency.

Can it do what it says?

 Mostly, no.

They have a truck which apparently can run from this scalextric-type road. It is not clear whether the truck is electric. The truck is electric. Most of the video I can find shows a diesel truck with a dummy electrical load. They also have a test-car (which is, I suspect, petrol-powered, at least it sounds like it in the video) which carries a 17kw dummy load powered from the track. It is not clear whether the car is road-legal with the dummy load (I can only find video of the car being used on a test-track)

Could it possibly work, ever?

Maybe, yes. If it can actually deliver 17kw to a moving vehicle, that is approximately enough to run a car at motorway-type speed and charge at a modest rate simultaneously. 

They made various claims about its safety and robustness etc, which seem at least vaguely plausible. They obviously did some testing in various conditions. There is video of the truck driving in snow.

So what's the problem?

No normal electric car could ever charge from the track while driving. The electrics system would have to undergo major modifications. That's ignoring the major software updates.

That's to say - EVs can recharge while driving - it's called regenerative braking. 

The electric system in an electric car is fairly complex and needs to handle a lot of power in several directions. Most electric cars can charge at up to 50kw, and many will discharge even faster in some conditions. Moreover, they can switch from one to the other in a very short time while driving.

EVs usually have an onboard charger for charging from AC (Level 1 and 2) sources. This is part of the power electrics which can't operate at the same time as the drive.

Rapid charging (Level 3) is done by an external charger, which communicates with the car in a rather complex way, and provides DC at the correct voltage / current for the specific charging requirements of the vehicle. The external charger is a big heavy box which would be prohibitively heavy to put on a light vehicle. They usually take an industrial 3-phase supply.

I don't think it's plausible to use a level 3 charger in the track:
  • There aren't enough pins for a level 3 charger, which needs at least an AC supply AND a DC supply.
  • There would not be time on a 50m section (or even 200m section) of track, for the charger to get the correct voltage, current etc for the specific vehicle
  • The large number of complex level 3 charger boxes would be prohibitively expensive.

There is a lot of difference between delivering some power to the vehicle (which has been demonstrated) and charging an EV traction battery (which has not).

But those things could be solved?

Yes, in principle, but no car maker is going to want to do that. Modern vehicles are not designed for a single market, it's not cost-effective. Cars designed now (without elways support) are going to continue to be made for 20 years without a major redesign of their drive train.

It's not remotely viable to redesign the electrics of an EV for a feature which is available only in one country, as the weight / performance / space penalty would exist in the design everywhere else.

Why else am I sceptical?

 Most of the videos that I've seen seem to be on the test-track (not on the airport highway). I saw one 12-second clip which appears to show a slightly less hacky pickup (maybe on an electric truck) looking like it might be powering the real truck.  But otherwise, all the media seem to be from the test-track, or with dummy loads.

The Guardian's funky video obviously shows a diesel truck with the test-load running some bright lights - this is presumably on the test-track because it won't be road-legal.

The PR is certainly very strong. There is a lot of marketing wank that makes very big promises, but is very light on details.

There is basically no detail whatsoever about any of the vehicles that they have to use on this "open" road.  I understood from the various press releases that there was one truck which would be regularly using the road, which is a 2km section. Again, it's not clear whether the truck actually takes useful traction power from the road (whether charging or just driving), or just drives a dummy load.

* I wish they would spend more money on developing the tech instead of making mockup videos and writing PR stuff

 Anything positive?

Yes a few things
  • The tech for getting the track and pickup working seems well developed, they've shown it working back in 2013
  • It has been demonstrated working in bad weather.
  • If we forget about charging electric cars and just consider an extra power system for (ICE powered) commercial vehicles, it starts looking a lot more sensible.
  • Heavier, slower vehicles pay a lower weight and aerodynamics penalty for having the tech installed.
  • Delivering 17kw to an electric motor on an otherwise-diesel truck would save it a great deal of fuel, it would also extend the range of an electric one (but not much if you only have 2km)

** opens to the single vehicle it's designed to work with. But other traffic can still use the road, so I suppose that's open?
***  well, not actually charge. But deliver power to. Perhaps?

Sunday, 8 April 2018

Strange RC terminology

Here are some terms used in RC models

"Electronic speed contoller" aka ESC

What does it do?

It converts RC servo pulses (pulse width only matters, 1500us = centre, approx 1000 = left, 2000 = right) into a speed, often with reverse, so that it can drive between full speed reverse, stopped, full forward. These usually control brushed (DC) motors, but versions for the "brushless" motors are available too (which often only drive in one direction, they are intended for RC aircraft).

 
Why is it called "electronic" speed controller? Surely that's redundant?

No. Originally RC models used either a petrol engine (in which case, the engine is the speed controller, and servo operates its throttle) - or a second battery with a primitive electro-mechanical speed controller - essentially a variable resistor with a servo attached.

So the "electronic" means that it's fully solid state - no moving parts.

"Battery eliminator circuit" aka BEC

WTF? It is apparently the RC term for a voltage regulator. Just a voltage regulator.

So why is it called a BEC?

Because originally models used two batteries, one for the radio receiver and servos, another for the main drive. The traction battery was much bigger and generally rechargable (NiCd chemistry was common before lithium cells were good). The radio batteries sometimes used primary cells, or a different form of rechargable e.g. AA or standard cells.

The BEC essentially eliminates the secondary, or RC receiver battery, by regulating the voltage from the traction battery down to a stable voltage for the receiver (the receiver will probably want 5v, but the traction batteries are often 7v or higher)

The two-batteries scheme is probably somewhat obsolete, especially on flying models (the BEC is generally a lot lighter than a second battery).