Real-Time Digital Simulator Design for Differential Drive Mobile Robot using FPGA

—This paper presents a real-time simulation of a differential drive mobile robot (DDMR). The permanent magnet DC motors that drive the robot’s left and right wheels were modeled and executed in real-time on a Field Programmable Gate Array (FPGA) based co-simulator platform, interfacing with the Webots robot simulator, which simulates the DDMR on the PC side. The electrical parameters, which are not available in robot simulators, were simulated and measured by the proposed co-simulator system in real-time under various environmental conditions and trajectories of the robot. Parameters such as current, voltage, and torque were measured instantaneously, enabling a more realistic simulation. Additionally, the cycle time of the robot simulator was determined to be 32 ms, and the developed FPGA-based simulation operated at approximately 2000 times the speed of the robot simulator. The results demonstrate the applicability of the developed platform in robotic applications.


I. INTRODUCTION
O VER time mobile robots have increasingly become in- tegrated into our daily lives, taking on different forms and playing significant roles in various sectors [1].They have proven their adaptability in industrial production [2], medical applications [3], agricultural processes [4], space exploration [5], and various other fields.As technology advances, it is evident that mobile robots have the potential to overcome challenges and stimulate innovation in different areas [6].
Mobile robots are typically divided into two main categories: wheeled robots [7] and legged robots [8].Additionally, there are various approaches to combining wheeled and legged components to create different types of robots [9].Wheeled mobile robots exhibit variations in wheel type, quantity, and assembly configuration.Designs range from standard types to mecanum, omni, and spherical wheels, as well as differential and steering wheels, depending on the connection configuration [10].
However, constraints such as time and cost make it impractical to work directly with mobile robots.Many applications require preliminary work to be done in a simulation environment.Various robot simulation platforms, such as Gazebo, Webots, Coppeliasim, and Isaac Sim, have been developed for this purpose.These simulators are considered a practical and effective approach for developing control strategies, but not all simulators are suitable for simulating electrical variables like current and voltage.These simulators typically focus on kinematic and dynamic modeling using physics engines [11].
As an alternative, simulation techniques, especially Hardware-in-the-Loop (HIL) simulations, are becoming increasingly popular in various systems, including robotics [12], automotive [13], power systems [14], and aircraft systems [15].For instance, a backstepping control regulator has been implemented for PUMA 560 using the FPGA-in-the-loop option on the Xilinx Zedboard Zynq FPGA with the Hardware Description Language (HDL) Coder tool [16].Another study focused on optimizing solution times for real-time use of inverse kinematics in articulated robots, developing and testing an optimization algorithm compatible with FPGA architecture [17].Furthermore, a discussion on the application of FPGAbased HIL simulation to computer vision in an unmanned aerial vehicle is presented in [18].
A review of the existing literature shows that there is a significant gap in robot simulators that do not include electrical models.This paper proposes a novel solution using an FPGA architecture to simulate models of electric motors with highspeed processing.In this study, FPGA-based models for the drive motors of a DDMR were designed and executed in real-time with an FPGA-based co-simulator.In the proposed system, the angular velocities and currents of the motors were transmitted to a PC-based robot simulator platform, while voltage and torque information was received as feedback to the FPGA environment.As a result, the motors were operated in the FPGA environment and seamlessly integrated with the PC-operated robot.This innovative approach successfully addresses the gap in traditional robot simulators and improves the existing system by incorporating the previously ignored electrical model component.
This paper is organized as follows: It begins with an introduction that provides information about mobile robots and FPGA-based HIL systems.The next section presents the hardware side of the study, which includes FPGA.In the third section, the robot simulator and control concept are discussed.The experimental results are analyzed in the fourth section.Finally, the paper concludes with a summary section that recaps the main findings and explores their implications for future research.This requires previous simulation step to be completed and the results saved before the evaluation of next step.To compete with required calculation work load, high speed and high performance equipments need to be used.This performance can be achieved by software using high speed µP with combination of real-time operation systems or by hardware approach.
Hardware development is mainly used for Very large-scale integration (VLSI) electronic components.However, VLSI manufacturing is a hard and painful process permitting very limited changes after tape-out process.FPGA-based systems has great advantages for hardware development and permitting hardware changes even after end product is sold.In this study DE10-Nano development board was selected for its popularity.DE10-Nano development board is a Solution on Chip (SoC) development platform produced by Terasic company.Platform designed around Intel Cyclone V 5CSEBA6U23I7 SoC device which contains dual core ARM Cortex-A9 hardware processor and FPGA fabric with resources listed in the Table I [20].
The development board has an onboard Analog-Digital Converter (ADC) system based on Linear Technology LTC2308.The ADC has a resolution of 12 bits, operates at a speed of 500 KSPS, and 8 analog input channels.It supports a 4-wire Serial Peripheral Interface (SPI) connection interface with a maximum operating frequency of 40 MHz.Proposed FPGA-based real-time digital simulator system also includes an interface board for analog signal inputs and outputs.The analog interface board also contains Digital-Analog Converter (DAC) systems which the development board does not include.The DDMR simulated for this study has two DYNAMIXEL XL430-W250-T servo motors with gear ratio of 258.5:1.The proposed real-time simulator was designed to simulate Permanent Magnet Direct-Current (PMDC) motors.To simulate gear box mechanical loading of servo motors used by robot, additional mechanical load was configured with parameter inputs of real-time simulator.The load torque on the shaft of servo motors are simulated by Webots simulator and received as T i signal by real-time simulator.
The real-time simulator was designed to accept eight input signals which four of them are supply voltage and torque

Float Value
Fig. 1.PMDC motor simulator module of digital twin system inputs for both left and right motors.Other input signals are parameter inputs for simulator assumed to be same for both motors which are B L , J L , K M , and K B .ADC inputs for supply voltages and torque inputs were privileged and configured to be read at every ADC read sequence.
The real-time simulator has eight channels to be read and with the read speed of 500 Kilo samples per Second (KSPS) each channel will have a 62.5 KSPS of speed.To increase sampling ratio a privilege system was used.The system read sequence has four privileged inputs and the only one of the four parameter input channels in ADC read sequence.This asymmetric read sequence enables a speed rate of 100 KSPS for privileged channels and only 25 KSPS speed for parameter inputs.All required ADC channels were read in 10 µs and after this read sequence was completed and a signal asserted within simulator as simulation step signal.
FPGA hardware development was made by using Intel Quartus Prime Lite edition software freely available from manufacturers web page.For hardware development Verilog hardware description language (HDL) is used and Intel floating point IP library was used for floating calculations.The development board generate a clock signal of 50 MHz and fed FPGA at three different pins.A hardware Phase Locked Loop (PLL) unit was used to generate required clock signals required by proposed real-time simulator.To configure and read from ADC system an SPI module was developed to communicate with LTC2308 ic.This module requires 40 MHz clock signal to operate which was generated by PLL module.A module was also designed to control reset signal.The analog interface board contain DAC channels which use parallel interface to communicate with development board.A module was developed with in FPGA for PI interface used by DAC channels.
The real-time simulator contains three main modules which operate at 50 MHz required for simulation.There was two motor simulator modules as depicted in Fig. 1 operating in parallel to simulate right and left motors of robot.The realtime simulator also contains a module as depicted in Fig. 2 as parameter module which is used to calculate required coefficients for motor simulator modules from parameter input The motor simulator modules get main input signals and calculate output signals I a and ω m by using coefficients calculated by Parameter Calculation module.Both modules were designed to perform calculations with in 10 µs as it is also one ADC read cycle.However the changes in main input signals can be seen after one simulation cycle, the change in parameter inputs were using an additional simulation cycle to be ready for use by main simulator module which means at least two cycles were required for the the change of parameters to effect the output signals.

III. ROBOT SIMULATOR AN CONTROL CONCEPT
In this study, the Webots robot simulator was employed for the physical calculations of the robot.Open Dynamics Engine (ODE) was employed as the default physics engine in WEBOTS to perform physics calculations.Additionally, the definitions of the Turtlebot3 were utilized in the predefined PROTO file, created from WEBOTS components.The connection between this simulator (PC-side) and the Real Time Digital Simulator (RTDS) (FPGA-side) co-simulator was established using Python, which utilized the pydwf library to facilitate communication with Analog Discovery 2 devices.Within the Python program, a subprogram generated angular velocity information to be applied to the motors for robot movement.As illustrated in Fig. 3  The angular velocity values generated by the robot control algorithm were transmitted to the Webots robot simulator.Torque and angular velocity references from Webots were combined with armature current and angular velocity feedback information from the real-time co-simulator.These inputs were then used to calculate the supply voltage value for the digital motors.To derive this voltage value, in Eq. 2. is formulated by substituting the load torque, T L (t), for the input torque, T i (t), in Eq. 1.The calculation of the supply voltage value, crucial for motor application, involves a fixed value of 128 ms for ∆t, as specified in the equation.However, given that ∆t can vary during the simulation, it is treated as a variable and measured for use in the calculations.
The calculations, as depicted in Eq. 2, are executed within the motor voltage control system illustrated in Fig. 4.These computations were performed to generate the supply voltage values applied to the motors.The obtained voltage and load torque values were transmitted to the real-time simulator through the Analog Discovery 2 device.Utilizing this information, the real-time simulator simulated the motors, generating

A. Linear trajectory
The results shown in Fig. 5 are obtained for a robot carrying a 2 kg payload on a plane with a positive slope of 0.1 rad in the x-axis.As depicted in Fig. 5a, the robot travels approximately 4 meters linearly along the x-axis.The robot covered the distance between the start point and the end point in approximately 24 seconds.5f.As seen, the torque values are negative as the robot descends the ramp.In this case, both motors should operated in forward-braking (regenerating) mode.However the total load torque of motor is the sum of both servo systems load torque and the load of the gearbox inside servo system.For lower speed of robot, the motors were operating in forward-braking mode and the armature current is reversed.But for higher speeds of robot, the required torque for the gearbox increased and motors needs to compensate additional torque by working at forward-motor quarter.The

B. Circular trajectory
As a different operation, the plane is set to a 0.1 rad slope in the y-axis.Subsequently, the robot is operated on a circular trajectory with a radius of 0.5m under the same load conditions.The graphs obtained under these conditions are presented in Fig. 6.The circular trajectory along which the robot moves is shown in Fig. 6a.Since the robot moves counter-clockwise, Fig. 6b illustrates that the left wheel rotates slower than the right wheel.In Fig. 6c, between 12-19 seconds, the left motor operates in regenerative mode, drawing negative current.This is because, at that moment, the motor continues to run at a positive speed.Fig. 6d depicts the robot rotating on the z-axis for a total of one revolution, oriented in the same direction.The error signals are presented in Fig. 6e, and voltage and torque signals are given in Fig. 6f.

C. Infinite symbol trajectory
Finally, the robot is moved along a trajectory that resembles an infinity symbol.In Fig. 7, the robot is unloaded, and the plane is rotated on the x-axis by 0.1 rad in the positive direction to obtain a slope.The starting position of the robot is (0,-1), and the end position is (0,0.75).The trajectory of the robot is shown in Fig. 7a.Examining Fig. 7b reveals that the angular velocities of the motors are driven by sine and cosine references.In Fig. 7c, it can be observed that, at some points, the motor operates the generator mode by drawing negative current, performing a braking operation.In this case, the position and angle information of the robot is given in Fig. 7d.Additionally, control error signals are shown in Fig. 7e.Fig. 7f illustrates the voltages applied to the motor and the measured torque signals.Notably, both the left and right motors brake by producing negative torque in different regions.

V. CONCLUSION
A study is presented to address a missing aspect of robot simulators, namely the electrical modeling of motors.In the proposed system, motor models were developed in real-time within the FPGA environment.This model was integrated with a PC-based robot simulator, introducing a new method to address deficiencies in robot simulation.In the study, the PC side of the robot simulator was responsible for the robot's dynamic features, while the FPGA-based co-simulator side took on the real-time operation of the electrical and mechanical models of the motors.
Upon examining the results of the study, it can be said that satisfactory outcomes were achieved.This work demonstrates the real-time feasibility of electrical analyses through the development of an additional module for robot simulators.As a future study, there are plans to create an FPGA-based robot simulator by establishing a system similar to the physical motor of the robot simulator discussed in this study.

Fig. 5 .
Fig. 5. Results for robot simulation for linear trajectory on a surface with inclination of 0.1 for x = 0 axis rad and 2 kg of payload; a) trajectory followed by robot, b) speed references and simulated speed value for motors, c) armature currents for both motors, d) position and orientation of robot, e) error values for both motors angular speed values, f) simulated load torque and supply voltages for motors Fig. 5b demonstrates that the left and right motors accurately follow the reference velocity signals.The armature currents of the motors are illustrated in Fig. 5c.The robot's x, y position, and rotation information on the z-axis θ are presented in Fig. 5d.Since the robot moves linearly, its rotation on the z-axis is zero.The error signals at angular velocities are shown in Fig. 5e.The high values in the error signals in the acceleration and deceleration regions are attributed to the control step time of the Webots simulator, which is 130 ms.The voltage signals obtained at the controller output and the torque values measured from the robot wheels are analyzed in Fig.

Fig. 7 .
Fig. 7. Results for robot simulation for infinite symbol trajectory on a surface with inclination of 0.1 rad for x = 0 axis; a) trajectory followed by robot, b) speed references and simulated speed value for motors, c) armature currents for both motors, d) position and orientation of robot, e) error values for both motors angular speed values, f) simulated load torque and supply voltages for motors

Control System Speed Feedback Load Torque Armature Current Motor Voltage Speed Reference
, Analog Discovery 2