Interacting with the Rover using Simulink

Simulink is a crucial software tool in the automotive realm, offering engineers a visual platform to model vehicle systems via block diagrams. Engineers leverage this versatile software to simulate and refine control algorithms for engines, transmissions, and critical vehicle functions like suspension and braking. Its integration with Hardware-in-the-Loop (HIL) setups allows real hardware testing alongside simulated components, aiding in the validation of electronic control units (ECUs). In the context of electric vehicles and autonomy, Simulink proves particularly useful in modeling battery systems, motor controls, and self-driving algorithms.

 

This post delves into a practical example of using Simulink to communicate with the Rover via the Vehicle Network Toolbox. We’ll focus on sending and receiving CAN messages and implementing a control system for a steering servo within the Rover, which we can simulate in real-time. It’s assumed the reader has a basic understanding of Simulink, control theory, and CAN.

 

An important point to note is that the servo we’re using already incorporates a controller within its internal circuitry. In practice, we’re not directly manipulating the servo motor itself; instead, we’re controlling its internal controller. Therefore, for the sake of this example, we’ll consider the servo as a plant with an unknown transfer function.

 

Most digital servos feature three pins for Pulse Width Modulation (PWM) control. Here, we’ll use a specialized servo that provides position feedback on a fourth pin, connecting it to a servo board found in the Demo Rover. Our objective is to design a closed-loop control system where the input is a steering angle and the output is a pulse width to control the servo. The position feedback helps measure and compensate for errors. Here’s a simplified version of the control system:

 

And here’s the final diagram in Simulink:

The final Simulink diagram showcases three main steps from left to right:

  1. CAN message reception and decoding.
  2. Control algorithm with signal conversion.
  3. CAN message encoding and transmission.

 

The CAN blocks in steps 1 and 2 are provided by the Vehicle Network Toolbox, requiring a CAN interface to communicate with the Rover’s CAN bus. We employ a Kvaser USBcan 2, although any device compatible with Simulink should suffice. This interface, along with the toolbox, enables sending, receiving, encoding, and decoding CAN messages within Simulink. Consequently, we can extract values from a CAN message and utilize them as input in our Simulink model, then use the model’s output to transmit a CAN message to the servo board.

In this example, we use two messages:

  1. ID 0x30D, containing the actual servo position in degrees.

  2. ID 0x100, where we send the output pulse width to the servo board.

 
 

The Vehicle Network Toolbox provides Simulink blocks facilitating the filtering of these messages and their decoding/encoding. The CAN configuration block configures the Kvaser CAN interface with the correct bitrate of 125 kbit/s. For message reception, the CAN Receive block connects to a CAN Unpack block to decode signals for Simulink use. For transmission, the CAN Pack block encodes signals in a CAN message, and the CAN Transmit block sends the message on the bus. These blocks are configurable with CAN Database (DBC) files, allowing message selection from a drop-down list, where we utilize the Rover’s DBC file.

 

The servo control logic sits between the CAN reception and transmission logic. We generate a reference signal for controlling the servo via a sine wave generator, moving the servo from left to right by 45 degrees in each direction with a frequency of 1.5 rad/s. To visualize the sine wave, we send it to a scope block named “Signal viewer” along with the position feedback obtained from the CAN bus. This way we can gauge the control system’s response. We calculate the error in degrees by subtracting the position signal from the reference signal, converting it to a pulse width in microseconds before inputting it to the PID controller.

 

The PID controller’s output signal is limited to a pulse width between -1000 and 1000 microseconds. Since digital servos operate within a pulse width range of 1000 to 2000, with 1500 representing a neutral position, we add an offset of 1500 microseconds to the PID controller’s output before sending the signal to the CAN message encoder. The PID controller is configured in discrete-time mode, and we obtain its parameters by manual tuning: P=0.1, I=3.9, and D=0.005.

 

To run the simulation on real hardware, initial setup of simulation pacing parameters is crucial. Refer to the below images for these settings.

 

Upon connecting the servo board to the servo and the CAN interface to the servo board, the simulation can be executed. Here are the results:

As we can see, the actual position of the servo nicely follows the sine wave with a constant phase difference due to the simulation speed.

 

In summary, utilizing Simulink in conjunction with the Vehicle Network Toolbox allows for a hands-on exploration of Rover communication, focusing on CAN message handling and the implementation of a steering servo control system. This example illustrates the intricate steps, from decoding and encoding messages to interfacing with real hardware. The simulation effectively demonstrates the servo’s response to a sine wave input, showcasing its tracking capability. Overall, this practical demonstration underscores the Rover’s versatility and its utility for simulating and verifying models in a real-world context.

 

Using the Rover in education

Greetings to all educators, students, and technology enthusiasts! We are excited to present the potential of our Rover, featuring a programmable car as an engaging learning tool in various educational settings.

The Rover is designed to deliver a hands-on experience with the CAN protocol, a standard extensively used in the automotive and industrial sectors. But its applications go well beyond that. With its versatility and endless customization possibilities, it serves as a rich resource for educators across a range of fields. Let’s explore these creative applications.

  • STEM Education: The Rover serves as an excellent tool for teaching Science, Technology, Engineering, and Mathematics (STEM) concepts. It provides students with an in-depth understanding of the CAN protocol and its real-world applications. Whether it’s writing code to perform tasks, understanding how physical components interact, or designing a control system, it’s a comprehensive introduction to practical tech applications.
  • Collaborative Learning: The use of the Rover inherently promotes teamwork. Students can form teams to work on various aspects of the project – from coding to assembly to testing. This collaborative approach cultivates communication and cooperation skills, crucial competencies in today’s interconnected world.
  • Problem-Solving Skills: Working with the Rover involves encountering and overcoming challenges. Whether it’s troubleshooting code, figuring out why a component isn’t working, or strategizing the most efficient route for the Rover, students are encouraged to employ critical and creative thinking to solve problems.
  • Coding Clubs and Competitions: The Rover can serve as an engaging focal point for coding clubs or programming competitions. Imagine a contest where teams compete to program their Rovers to navigate a maze in the fastest time. This not only makes learning enjoyable but also introduces a healthy level of competition, pushing students to refine their coding skills further.
  • Cross-curricular Learning: The Rover isn’t restricted to computer science or engineering classes. It can be used in physics to demonstrate principles of motion or in mathematics to visualize concepts such as angles, speed, and distance. Even in arts, it can be incorporated into creative projects, such as designing a Rover-based performance or transforming the Rover into an artistic installation.
  • Real-World Relevance: One of the most exhilarating aspects of the Rover is its direct relevance to real-world scenarios. Students can firsthand experience how their learning applies to industries like automotive, aerospace, and industrial automation that widely use the CAN protocol.

By integrating the Rover into your educational activities, you’re not only teaching your students about technology – you’re fostering critical thinking, collaboration, creativity, and a deeper understanding of the world they inhabit. As the adage goes, the best way to predict the future is to invent it – and we are eager to see what our young inventors will create!

How to get started with the Rover

There are various projects that can be realized using the CanEduDev Rover, but the simplest way to get started is to set up the Rover like any regular radio-controlled model car. To start with, you should familiarize yourself with the Rover by understanding its different components. In the standard Rover package, the following components are included:

  • Aluminum chassis
  • Wheels
  • Brush-less electric motor
  • Brush-less electric steering servo
  • Electronic speed controller (ESC)
  • Battery holder

In addition to these components, you need a radio control kit and a 3-4 cell LiPo battery, with a charge/discharge rate of 25C or more. You also need a battery charger capable of charging LiPo batteries. These components are sold by hobby shops and can also be found on Amazon. For this example, we have used a JH-Power 3500 mAh 75C LiPo battery and the RadioLink RC6GS.

First of all, unbox your Rover and identify the different components included. The motor, ESC and the steering servo come pre-assembled on the chassis. You’ll have to install the wheels and the radio receiver yourself, and put a battery in the battery holder.

After assembling the Rover, the next step is to connect the components. First, connect the ESC to the motor, then connect the servo to channel 1 on the radio receiver, and connect the ESC to channel 2. The channels are labeled on the radio receiver. Finally, the battery should be connected to the ESC. To start the Rover, click the on/off button. The battery should be left disconnected when not in use. Of course, this is a general overview of the assembly process. For detailed instructions as well as images and videos of the assembly, see the Documentation.

Now, you should be able to take the Rover for a test drive to ensure everything works as intended. What’s next is up to your imagination. Create a battery monitoring system, a lane assist feature, or just drive for fun. Check out our electronics kit for a complete CAN system in the Rover, which you can use to integrate various components for your next project!

Introducing the Rover: Unleash Innovation, Unveil Excellence

Are you ready to revolutionize your corporate showcasing and educational experiences? Look no further than the Rover, the ultimate model car that’s not just a vehicle—it’s a canvas for your creativity and a vessel for your ideas!

Eye-Catching Appeal: Attracting attention is key, and the Rover is designed to stand out in any environment. Whether it’s a bustling trade show floor or an interactive classroom, the Rover’s striking presence draws people in, creating an instant focal point that sparks curiosity and conversations.

Cutting-Edge Design: The Rover isn’t just a model car; it’s a well-crafted piece of engineering. With its sleek and captivating design, this 1:5 scale, 10 kg marvel is a true attention magnet. Crafted with meticulous attention to detail, the Rover’s aesthetics will leave onlookers awestruck.

Flexibility Redefined: We understand that every corporation has its unique story to tell. The Rover’s flexibility is its superpower—customize and mount your own electronics or hardware seamlessly. This adaptability ensures that your brand’s narrative takes center stage, aligning perfectly with your message and objectives.

Corporate Showcase: Elevate your presence at trade shows and exhibitions with the Rover. Make a lasting impact by bringing your products to life in a tangible and captivating way. Let potential clients experience the innovation firsthand and forge memorable connections that go beyond words.

Empower Educators: In the realm of education, the Rover becomes an invaluable tool. Give your students a hands-on experience that bridges the gap between theory and practice. Allow them to explore concepts in electronics, programming, and robotics, fostering a deeper understanding that will last a lifetime.

Endless Possibilities with CAN Bus: The Rover isn’t just a static display piece—it’s a dynamic platform for innovation. With our electronics kit, you get built-in CAN bus integration that allows you to seamlessly incorporate electronics and hardware, turning the Rover into a living demonstration of your products’ capabilities. Showcase your technology like never before, creating an interactive experience that resonates with your audience.

Unleash Open Source: Elevate your Rover experience with our open-source applications for the CAN electronics kit, built on the versatile FreeRTOS framework. Dive into a world of creativity and customization, all under the MIT and BSD 3-Clause licenses.

The Rover isn’t just a model car—it’s a gateway to endless possibilities. Captivate, educate, and innovate with a single, dynamic solution. Seize the opportunity to showcase, teach, and inspire like never before. Choose the Rover and drive your success today!