Electric Vehicle Drive Motor
Electric Motion Systems (EMS) wanted to create the world’s most efficient electric bicycle. Dr. Ziaur Rahman, Director of Electrical Controls at EMS, had worked at Ford's Ecostar and GM's Hybrid Vehicle Divisions which gave him the design expertise to create a sophisticated space vector control with regenerative braking for a permanent magnet synchronous motor (PMSM). However, he did not have low-level C and assembler experience, nor did he have bit-level product knowledge of the TI F2801 digital signal controller that he wanted to use as his controller.
The Design Challenge
Initially, Rahman thought he would need to hire several embedded programmers to help him with his design. Engineering colleagues, however, recommended VisSim/Embedded Controls Developer (VisSim/ECD) based on their success with the product. Convinced, Rahman decided to give VisSim/ECD a try and see how far it would take him.
Rahman fully expected that the motor control would be relatively easy to implement in VisSim, but he was concerned about the implementation of his RS485 packet based command and information protocol. Likewise, he wanted to track motor information to EEPROM using the on-chip SPI interface; and he wanted to use I2C to read and write system values like serial number, min, max and average bus voltages, inverter temperatures, hours of use, etc.
VisSim is an essential tool for us in developing motor controls for electric bicycles. Code development time is greatly reduced with VisSim’s ready-to-use block sets and efficient debugging capability. The best of VisSim is its support team. They respond quickly, go an extra mile to solve issues, and suggest efficient ways in implementations. For example, we asked the Visual Solutions engineers to help us in implementing a serial communication interface (SCI) protocol for our electric bicycle system. We had the system running flawlessly three weeks later.
Dr. Ziaur Rahman, Director Electrical Controls at Electric Motion Systems
- Ph.D. EE Texas A&M University
- Engineer at Ford Ecostar electric drive systems
- Design Engineer at GM Hybrid Vehicle Division
- Senior member IEEE
- Member SAE
Efficient Code Generation
In fact, the automatic C code generation from the VisSim block diagram was so accurate and efficient that Rahman was able to program his entire application in VisSim. Once compiled, the entire diagram fit into 10k flash and 4k RAM, with enough RAM left over for seven interactive input gains, six controller debug outputs, and 1k of signal buffering (for VisSim digital scope display) and the VisSim debug background task. This allowed Rahman to use the lowest cost chip available for the job.
What pleased Rahman even more was how easily he could debug his algorithms using waveform analysis with VisSim’s digital scope capability. Rahman was able to trigger waveform capture at the full sample rate of 20kHz using his own custom trigger conditions. This allowed him to play with filter parameters and PID gains, and instantly see the results in VisSim plots on the PC.
Extensive Peripheral Support
Rahman wanted to use the ePWM in a simple BLDC Hall sensored mode, then switch to a space vector mode once the bike hit a speed threshold, as well as put the ePWM into a locked motor phase mode for security. In addition, he needed to monitor bus voltage and inverter temperature, read and write EEPROM data via the F2801 I2C interface, and read and write RS485-based data packets to the main control panel. Both of the data I/O links were handled easily in VisSim/ECD using the built-in I2C and serial I/O block support with interrupt-driven soft queueing. To track protocol packet state, Rahman used the built-in state transition block.
It was important that Rahman's main control task run at 20kHz with no jitter, but he also needed to read and write RS485 packets, and read and write EEPROM via I2C. To avoid impacting performance of the main motor control loop, Rahman made the RS485 and I2C code background tasks running at 100Hz with occasional preemption by the control task. This was easily accomplished in VisSim/ECD: Rahman simply selected the Local Time Step option on the block containing the I/O subsystems and set them to 0.01 seconds; then he activated the Codegen as Separate Thread option to schedule them to run periodically from the background idle loop.