Programmable SoC keep e-bike wheels turning

3rd March 2016
Posted By : Caroline Hayes
Programmable SoC keep e-bike wheels turning


Design techniques and challenges to implement an electronic bike (e-bike) are explored by Ronak Desai, Cypress Semiconductors.

Current e-bike systems use external ADC and external amplifiers for different sensor inputs, relay driver circuitry for brake lights, headlights, and directional lights, temperature measurement sensors and LEDs/LCDs and external signal conditioning and comparator circuitry to drive the three-phase motor. The microcontroller also forms part of the central locking system.

Programmable SoCs devices can be used as a single board system for motor control, analogue measurement, and direct drive LCD. Capable of supporting capacitive sensing technology, programmable SoC devices also use internal PWM, mux, and comparators. These internal features enable the driving and controlling of the three-phase motor, internal ADC and PGA for sensor inputs, battery monitoring and temperature sensing; when a temperature sensing device is present. The SoC can also directly drive the relays for the brake light, headlight, and directional lights, as well as driving the LCD for temperature, battery status, speed, distance travelled, and any error/warning messages.

The role of microcontroller

Currently, 16- and 32bit microcontrollers are used for e-bike systems to control and manage the functions and features of the vehicle depending on input from the user. Turning the ignition key starts the vehicle and an input is sent to the microcontroller to start the three-phase brushless automotive motor. The driving speed of the motor is dependent on the speed selected by the user.

Figure 1: E-bike system and theory

The microcontroller uses either internal or external serial EEPROM (I²C/SPI based) for storing data like distance readings and uses a real-time clock.

Using different sensors, the microcontroller can take measurements and monitor information for various inputs and outputs. For example temperature measurements are made using an on-board RTD, while obstacle sensors provide information about nearby vehicles, and parking and fuel sensors obtain information on fuel in the engine.

Within an e-bike system, the power supply consists of a rechargeable lead acid or lithium battery as the power source, making provisions for a battery charger. The power from the battery input is converted to a DC voltage to power the microcontroller and other circuitry.

Implementation of an e-bike

This design example is based on Cypress’ PSoC 4, a combination of a microcontroller with digital programmable logic, high-performance ADC, op-amps with comparator mode, and standard communication and timing peripherals. The microcontroller is a 32bit ARM Cortex M0, operating at up to 48MHz, and has up to 32kbyte flash with up to 4kbyte SRAM and 2kbyte internal EEPROM.

This implementation uses an on-board six p-channel MOSFET and gate driver circuitry to drive a three-phase brushless motor. The PSoC 4 has an internal PWM, clock, multiplexer, and comparators for driving and controlling the three-phase brushless motor. In addition, an internal 16bit PWM will be used to drive the FET-based gate driver circuitry controlling the motor. The duty cycle of the PWM varies, based upon the speed required as set by the user.

The PSoC 4 has an internal op-amp, PGA, comparators, and 12bit 1Msample/s SAR ADC with differential and single-ended modes including sample-and-hold capability. This ADC controls the speed of the motor by varying the PWM duty cycle as well as measures different sensor inputs for battery monitoring, low-cost temperature sensing, obstacle sensing, and fuel sensing. Thus, the system does not require any external amplifies, ADCs, or comparators.

With two current DACs, the system has general-purpose sensing capabilities or the ability to use capacitive sensing technology on any pin. The PSoC 4 architecture supports a capacitive sensing component enabling both manual and auto-tuning. With an operating range of 1.71 to 5.5V, it can interface with external peripherals for other functionality. It also supports two, independent, run-time reconfigurable serial communication blocks (SCBs) with re-configurable I²C, SPI, or UART functionality useful for internal and external peripheral communication.

This implementation uses a rechargeable lead acid or lithium battery as a power source. The input voltage is converted by an on-board step-down regulator. The low operating voltage, low power operation and hibernate/deep sleep support battery life.

The PSoC 4’s comparator-based triggering of PWM kill signals can be used to terminate motor-driving when an over-current condition is detected. The input to this block is from the bus current. The cut-off reference to this block is set to the maximum current that can be drawn by the motor. The bus current input is given to the comparator and the configurable cut-off reference is set by the DAC. The comparator output is set high if the bus current is lower than the reference threshold. The comparator output is connected to the kill signal input of the PWM. When this input is high, the PWM output is turned off, thus preventing the motor from being damaged.

Sensorless motor control

Figure 2: PSoC-based e-bike block diagram

Sensorless motor control uses a back-EMF zero-crossing detection technique to control motor movement, without the need for Hall sensors. When the motor rotates, each winding generates back electromotive force (EMF) that opposes the main voltage supplied to the windings. Back EMF polarity is directly proportional to the motor speed.

For example, back EMF signals from the three phases terminate and the DC bus is scaled and routed to the PSoC. The PSoC will switch the terminate input to the comparator using the mux, and then compare it with the DC bus voltage. Cascaded digital logic will filter out the PWM signal to get the real zero-crossing signal for the microcontroller to decide the commutation.

An optional current control applied to the PWM output control regulates the motor current. This inner loop is based on a comparator. The feedback bus current is compared with the reference current value that is provided by a 12bit DAC. Changing the DAC output will modify the output current value.

Sensor-based brushless motor control uses a Hall sensor input to detect the rotor position and control movement. It provides Hall sensor inputs to the microcontroller and works as a closed loop system. This is helpful for automatic speed locking for longer drives.

Design challenges

A high-performance, intelligent microcontroller is required to perform key functions like analogue measurement, CAN interface, three phase motor control, LCD drive, low power operation, RTC, and which interfaces with different external protocols.

The system can have a low-cost, front-panel design with buttons and LED/ LCD interfaces or capacitive sensing can implement button, slider and proximity sensors on the front-panel. Meeting capacitive sensing performance requirements (i.e. signal-to-noise ratio) with nearby LEDs (PWM-based) on the front panel can be a design challenge.

Designing the board with high-power MOSFET driver circuitry, and handling high on-board current from a battery input is another design challenge. In addition, the electro-mechanical construction needs to be cost-effective, while achieving greater mileage.

Other challenges are the requirement for a power supply design with battery protection, over-current, over-heating, and start-up fail condition protection, and possibly the use of a one-time programmable device to prevent reverse engineering of the firmware.

System limitations

The PSoC 4 supports capacitive sensing technology to replace mechanical buttons. An interface for external devices like iPod/iPhone can be added so the system can communicate to media players across a UART or USB interface.

One of the single largest limitations of this embedded system is that increasing the number of internal and external interfaces on the board increases the number of ways that an intruder can access the system.

You must be logged in to comment

Write a comment

No comments

Sign up to view our publications

Sign up

Sign up to view our downloads

Sign up

Startups Magazine Launch Party: Financing a Startup
24th July 2018
United Kingdom WeWork Waterhouse Square, London
European Microwave Week 2018
23rd September 2018
Spain Ifema Feria De Madrid
IoT Solutions World Congress 2018
16th October 2018
Spain Barcelona
Engineering Design Show 2018
17th October 2018
United Kingdom Ricoh Arena, Coventry
Maintec 2018
6th November 2018
United Kingdom NEC, Birmingham