Electric Motion Systems (EMS) wanted to create the world’s most efficient electric bicycle. But while the company’s director of electrical controls, Ziaur Rahman, had the design expertise to create a sophisticated space vector control with regenerative braking for a permanent magnet synchronous motor, he did not have low-level C and assembler experience. Nor did he have bit-level product knowledge of the new TI F2801 digital signal controller that he wanted to use as his controller.
Initially, Dr Rahman thought he would have to hire several embedded coders to help him with his design. Engineering colleagues, however, recommended VisSim/Embedded Controls Developer based on their success with the product. Convinced, Rahman decided to give it a try and see how far it would take him.
The automatic C code generation from the VisSim block diagram was accurate and efficient, but what pleased Mr Rahman even more, was how easily he could debug his algorithms using waveform analysis with VisSim’s digital scope capability. He was able to trigger a waveform capture at the full sample rate of 20kHz using his own custom trigger conditions. This allowed him to play with parameters for filters and PID gains, and get instant results via VisSim plots on the PC.
Peripheral support
Mr Rahman needed to use the ePWM in a simple BLDC Hall sensor mode, then switch to a space vector mode once the bike hit a speed threshold, as well as put the ePWM into a locked 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/Embedded Controls Developer using the built-in I2C and serial I/O block support. Mr Rahman used the built-in state transition block to track protocol packet state.
The main control had to run at 20kHz with no jitter, while the background tasks - which monitor the RS485 data packets and I2C - could run at 100Hz; tasks easily accomplished in VisSim/Embedded Controls Developer. Mr 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.
As the project neared completion, the worry was that not everything would fit into the 4K of RAM available on the F2801. Because the controller boards had already been designed and built, it was not cost effective to move to a more expensive higher RAM part. Fortunately, the new version 7.0 of VisSim/Embedded Controls Developer has a significantly reduced RAM requirement, which, in the end, gave Mr Rahman an extra 1K of RAM for signal buffering for debugging purposes.