-
Scilab Delay
02/16/2022 at 23:27 • 0 commentsI originally planned to use Scilab to generate to interact with the Arduino and get "Block Simulation experience." The code was working originally, however I began to get the "You have to load the toolbox_arduino_v5-x.ino sketch with the arduino software in the Arduino board" error any time I tried to upload the .zcos model, even though the toolbox sketch was already loaded. I proceeded to take the steps to rectify the error as stated in the comments section of https://atoms.scilab.org/toolboxes/arduino. Eventually even the .sce code to brighten and dim an LED from a potentiometer input would work intermittently. Using "cmd_analog_out" would cause the program to timeout. Even when the function did work the value it returned would sometimes incorrectly jump to the highest or lowest.
Due to the unreliability of Scilab's Arduino Toolbox, I have decided to use MATLAB/Simulink instead.
-
Corrected Direction of Motors and PID
02/07/2022 at 22:58 • 0 commentsSwitched power terminals of Motor B and Motor A to test if Motor B was defective as it was unstable for a lot of the PID values.
Then commented out Direction = true/false in setMotor(A/B)(Reverse/Forward). This removed the instability issue. This is because Direction is a state of the motor, not a command. Instructing the motor to reverse or rotate forward doesn't mean it will do so instantaneously, it needs to slow down first.
Function logic for wheel(A/B) direction of the motor didn't reflect the true direction of the motor and/or conditions for changing direction. Therefore Direction(A/B) didn't change accordingly, leading to errors in the number of pulses counted, as they weren't incrementing/decrementing correctly.
-
PID Control
02/07/2022 at 04:13 • 0 commentsAdded a PID Control System
Unfortunately Motor B is much less stable (oscillates for many input types) over the s-domain when compared to Motor A. In order to to not have any unstable outputs form ramp an step inputs all PID values must be very low
Final Values:
Kp = 1.0, Ki = 1.0, Kd = 0.001
A sampling rate of 20 milliseconds was used
-
Basic Control
02/05/2022 at 04:14 • 0 commentsMotors and encoders of both wheels are fully connected and operational. An ISR is used to count the pulses for each encoder.
Can enter the speed at which the motors rotation (0-255) and direction of rotation
Motor A seems to consistently rotate faster than Motor B for the same PWM value. I will investigate this issue at a later date.
Ghani Lawal