summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSudhakarKuma2021-05-04 00:35:29 +0530
committerSudhakarKuma2021-05-04 00:35:29 +0530
commit2c38e8e0c21106d231ce1496109486a4d54267c9 (patch)
treebeb69ead8dab502df48f509b1314a416d0413a60
parent7080068e30db8bac72b209cddf9746c63f6c1535 (diff)
downloadFLOSS-Arduino-Book-2c38e8e0c21106d231ce1496109486a4d54267c9.tar.gz
FLOSS-Arduino-Book-2c38e8e0c21106d231ce1496109486a4d54267c9.tar.bz2
FLOSS-Arduino-Book-2c38e8e0c21106d231ce1496109486a4d54267c9.zip
Maintain consistency in DC motor code
-rw-r--r--user-code/dcmotor/OpenModelica/dcmotor-both.mo9
-rw-r--r--user-code/dcmotor/OpenModelica/dcmotor-clock.mo10
-rw-r--r--user-code/dcmotor/OpenModelica/dcmotor-loop.mo14
-rw-r--r--user-code/dcmotor/arduino/dcmotor-both/dcmotor-both.ino18
-rw-r--r--user-code/dcmotor/arduino/dcmotor-clock/dcmotor-clock.ino14
-rw-r--r--user-code/dcmotor/arduino/dcmotor-loop/dcmotor-loop.ino20
-rw-r--r--user-code/dcmotor/julia/dcmotor-both.jl10
-rw-r--r--user-code/dcmotor/julia/dcmotor-clock.jl6
-rw-r--r--user-code/dcmotor/julia/dcmotor-loop.jl10
-rw-r--r--user-code/dcmotor/python/dcmotor-both.py31
-rw-r--r--user-code/dcmotor/python/dcmotor-clock.py29
-rw-r--r--user-code/dcmotor/python/dcmotor-loop.py27
-rw-r--r--user-code/dcmotor/scilab/dcmotor-both.sce13
-rw-r--r--user-code/dcmotor/scilab/dcmotor-both.zcosbin4370 -> 4397 bytes
-rw-r--r--user-code/dcmotor/scilab/dcmotor-clock.sce10
-rw-r--r--user-code/dcmotor/scilab/dcmotor-clock.zcosbin3998 -> 4048 bytes
-rw-r--r--user-code/dcmotor/scilab/dcmotor-loop.sce20
-rw-r--r--user-code/dcmotor/scilab/dcmotor-loop.zcosbin4868 -> 4941 bytes
18 files changed, 120 insertions, 121 deletions
diff --git a/user-code/dcmotor/OpenModelica/dcmotor-both.mo b/user-code/dcmotor/OpenModelica/dcmotor-both.mo
index 066ca4f..e855c3c 100644
--- a/user-code/dcmotor/OpenModelica/dcmotor-both.mo
+++ b/user-code/dcmotor/OpenModelica/dcmotor-both.mo
@@ -6,11 +6,11 @@ model dcmotor_both "Rotate DC Motor in both directions"
Integer c_ok(fixed = false);
algorithm
when initial() then
- ok := sComm.open_serial(1, 0, 115200) "COM port is 0 and baud rate is 115200";
+ ok := sComm.open_serial(1, 2, 115200) "COM port is 2 and baud rate is 115200";
+ sComm.delay(2000);
if ok <> 0 then
strm.print("Unable to open serial port, please check");
else
- sComm.delay(2000);
sComm.cmd_dcmotor_setup(1, 3, 1, 9, 10) "Setup DC motor of type 3 (L293D), motor 1, pin 9 and 10";
sComm.cmd_dcmotor_run(1, 1, 100) "Motor 1 runs at PWM 100";
sComm.delay(3000) "for 3 seconds";
@@ -20,5 +20,6 @@ algorithm
end if;
c_ok := sComm.close_serial(1) "To close the connection safely";
end when;
- annotation(experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
-end dcmotor_both; \ No newline at end of file
+ annotation(
+ experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
+end dcmotor_both;
diff --git a/user-code/dcmotor/OpenModelica/dcmotor-clock.mo b/user-code/dcmotor/OpenModelica/dcmotor-clock.mo
index ffc3bba..4631532 100644
--- a/user-code/dcmotor/OpenModelica/dcmotor-clock.mo
+++ b/user-code/dcmotor/OpenModelica/dcmotor-clock.mo
@@ -6,11 +6,12 @@ model dcmotor_clock "Rotate DC Motor clockwise"
Integer c_ok(fixed = false);
algorithm
when initial() then
- ok := sComm.open_serial(1, 0, 115200) "COM port is 0 and baud rate is 115200";
+ ok := sComm.open_serial(1, 2, 115200) "COM port is 2 and baud rate is 115200";
+ sComm.delay(2000);
if ok <> 0 then
strm.print("Unable to open serial port, please check");
else
- sComm.delay(2000);
+ sComm.delay(1000);
sComm.cmd_dcmotor_setup(1, 3, 1, 9, 10) "Setup DC motor of type 3 (L293D), motor 1, pin 9 and 10";
sComm.cmd_dcmotor_run(1, 1, 100) "Motor 1 runs at PWM 100";
sComm.delay(3000) "This is allowed to continue for 3 seconds";
@@ -18,5 +19,6 @@ algorithm
end if;
c_ok := sComm.close_serial(1) "To close the connection safely";
end when;
- annotation(experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
-end dcmotor_clock; \ No newline at end of file
+ annotation(
+ experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
+end dcmotor_clock;
diff --git a/user-code/dcmotor/OpenModelica/dcmotor-loop.mo b/user-code/dcmotor/OpenModelica/dcmotor-loop.mo
index 979a098..6c643c4 100644
--- a/user-code/dcmotor/OpenModelica/dcmotor-loop.mo
+++ b/user-code/dcmotor/OpenModelica/dcmotor-loop.mo
@@ -6,22 +6,24 @@ model dcmotor_loop "Rotate DC Motor in both directions in a loop"
Integer c_ok(fixed = false);
algorithm
when initial() then
- ok := sComm.open_serial(1, 0, 115200) "COM port is 0 and baud rate is 115200";
+ ok := sComm.open_serial(1, 2, 115200) "COM port is 2 and baud rate is 115200";
+ sComm.delay(2000);
if ok <> 0 then
strm.print("Unable to open serial port, please check");
else
+ sComm.cmd_dcmotor_setup(1, 3, 1, 9, 10) "Setup DC motor of type 3 (L293D), motor 1, pins 9 and 10";
for i in 1:4 loop
- sComm.cmd_dcmotor_setup(1, 3, 1, 9, 10) "Setup DC motor of type 3 (L293D), motor 1, pins 9 and 10";
sComm.cmd_dcmotor_run(1, 1, 100) "Motor 1 runs at PWM 100";
- sComm.delay(2000) "for 3 seconds";
+ sComm.delay(3000) "for 3 seconds";
sComm.cmd_dcmotor_run(1, 1, 0) "Halt the motor";
sComm.delay(2000) "for 2 seconds";
sComm.cmd_dcmotor_run(1, 1, -100) "Run it at PWM 100 in reverse direction";
sComm.delay(2000) "for 2 seconds";
- sComm.cmd_dcmotor_release(1, 1) "Motor 1 is released";
end for;
+ sComm.cmd_dcmotor_release(1, 1) "Motor 1 is released";
end if;
c_ok := sComm.close_serial(1) "To close the connection safely";
end when;
- annotation(experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
-end dcmotor_loop; \ No newline at end of file
+ annotation(
+ experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
+end dcmotor_loop;
diff --git a/user-code/dcmotor/arduino/dcmotor-both/dcmotor-both.ino b/user-code/dcmotor/arduino/dcmotor-both/dcmotor-both.ino
index 1781c1d..bd75f7c 100644
--- a/user-code/dcmotor/arduino/dcmotor-both/dcmotor-both.ino
+++ b/user-code/dcmotor/arduino/dcmotor-both/dcmotor-both.ino
@@ -1,15 +1,15 @@
void setup() {
-Serial.begin(115200); // set the baudrate=115200
-pinMode(9,OUTPUT); // use pins 10 and 11 for motor output
-pinMode(10,OUTPUT);
-analogWrite(9,100); // Motor runs at a low speed
-analogWrite(10,0);
+Serial.begin(115200); // set the baudrate
+pinMode(9, OUTPUT); // use pins 9 and 10 for motor output
+pinMode(10, OUTPUT);
+analogWrite(9, 100); // Motor runs at a low speed
+analogWrite(10, 0);
delay(3000); // 3 second delay
-analogWrite(9,0); //
-analogWrite(10,100); // Motor runs in the reverse direction for
+analogWrite(9, 0); //
+analogWrite(10, 100); // Motor runs in the reverse direction for
delay(2000); // 2 seconds
-analogWrite(9,0); // Motor is stopped
-analogWrite(10,0); //
+analogWrite(9, 0); // Motor is stopped
+analogWrite(10, 0); //
}
void loop(){
// Code here runs in an infinite loop
diff --git a/user-code/dcmotor/arduino/dcmotor-clock/dcmotor-clock.ino b/user-code/dcmotor/arduino/dcmotor-clock/dcmotor-clock.ino
index b31f8fd..2b8c385 100644
--- a/user-code/dcmotor/arduino/dcmotor-clock/dcmotor-clock.ino
+++ b/user-code/dcmotor/arduino/dcmotor-clock/dcmotor-clock.ino
@@ -1,12 +1,12 @@
void setup() {
-Serial.begin(9600); // set the baudrate=9600
-pinMode(9,OUTPUT); // use pins 9 and 10 for motor output
-pinMode(10,OUTPUT);
-analogWrite(9,100); // PWM 100 on pin 9 makes the motor rotate
-analogWrite(10,0);
+Serial.begin(115200); // set the baudrate
+pinMode(9, OUTPUT); // use pins 9 and 10 for motor output
+pinMode(10, OUTPUT);
+analogWrite(9, 100); // PWM 100 on pin 9 makes the motor rotate
+analogWrite(10, 0);
delay(3000); // This is allowed to continue for 3 seconds
-analogWrite(9,0); // 0 on pin 9 stops the motor
-analogWrite(10,0);
+analogWrite(9, 0); // 0 on pin 9 stops the motor
+analogWrite(10, 0);
}
void loop() {
// what is put here will run in an infinite loop
diff --git a/user-code/dcmotor/arduino/dcmotor-loop/dcmotor-loop.ino b/user-code/dcmotor/arduino/dcmotor-loop/dcmotor-loop.ino
index 7b87334..057d983 100644
--- a/user-code/dcmotor/arduino/dcmotor-loop/dcmotor-loop.ino
+++ b/user-code/dcmotor/arduino/dcmotor-loop/dcmotor-loop.ino
@@ -1,20 +1,20 @@
int i;
void setup() {
-Serial.begin(115200); // set the baudrate=115200Hz
+Serial.begin(115200); // set the baudrate
pinMode(9,OUTPUT); // use pins 9 and 10 for motor output
pinMode(10,OUTPUT);
-for(i=0; i<4; i++){
- analogWrite(9,100); // Motor runs at a low speed
- analogWrite(10,0);
+for(i = 0; i < 4; i++){
+ analogWrite(9, 100); // Motor runs at a low speed
+ analogWrite(10, 0);
delay(3000); // 3 second delay
- analogWrite(9,0);
- analogWrite(10,0); // Motor stops for
+ analogWrite(9, 0);
+ analogWrite(10, 0); // Motor stops for
delay(2000); // 1 seconds
- analogWrite(9,0); //
- analogWrite(10,100); // Motor runs in the reverse direction for
+ analogWrite(9, 0); //
+ analogWrite(10, 100); // Motor runs in the reverse direction for
delay(2000); // 2 seconds
- analogWrite(9,0); // Stop the
- analogWrite(10,0); // motor rotating
+ analogWrite(9, 0); // Stop the
+ analogWrite(10, 0); // motor rotating
delay(1000); // for 1 second
}
}
diff --git a/user-code/dcmotor/julia/dcmotor-both.jl b/user-code/dcmotor/julia/dcmotor-both.jl
index 98bb633..b843b7c 100644
--- a/user-code/dcmotor/julia/dcmotor-both.jl
+++ b/user-code/dcmotor/julia/dcmotor-both.jl
@@ -2,10 +2,10 @@ using SerialPorts
include("ArduinoTools.jl")
ser = ArduinoTools.connectBoard(115200)
-ArduinoTools.DCMotorSetup(ser,3,1,9,10)
-ArduinoTools.DCMotorRun(ser,1,100)
+ArduinoTools.DCMotorSetup(ser, 3, 1, 9, 10)
+ArduinoTools.DCMotorRun(ser, 1, 100)
sleep(3)
-ArduinoTools.DCMotorRun(ser,1,-100)
-sleep(3)
-ArduinoTools.DCMotorRelease(ser,1)
+ArduinoTools.DCMotorRun(ser, 1, -100)
+sleep(2)
+ArduinoTools.DCMotorRelease(ser, 1)
close(ser)
diff --git a/user-code/dcmotor/julia/dcmotor-clock.jl b/user-code/dcmotor/julia/dcmotor-clock.jl
index 464fb5b..d0bf58c 100644
--- a/user-code/dcmotor/julia/dcmotor-clock.jl
+++ b/user-code/dcmotor/julia/dcmotor-clock.jl
@@ -2,8 +2,8 @@ using SerialPorts
include("ArduinoTools.jl")
ser = ArduinoTools.connectBoard(115200)
-ArduinoTools.DCMotorSetup(ser,3,1,9,10)
-ArduinoTools.DCMotorRun(ser,1,100)
+ArduinoTools.DCMotorSetup(ser, 3, 1, 9, 10)
+ArduinoTools.DCMotorRun(ser, 1, 100)
sleep(3)
-ArduinoTools.DCMotorRelease(ser,1)
+ArduinoTools.DCMotorRelease(ser, 1)
close(ser)
diff --git a/user-code/dcmotor/julia/dcmotor-loop.jl b/user-code/dcmotor/julia/dcmotor-loop.jl
index decbf5c..7281df3 100644
--- a/user-code/dcmotor/julia/dcmotor-loop.jl
+++ b/user-code/dcmotor/julia/dcmotor-loop.jl
@@ -2,14 +2,14 @@ using SerialPorts
include("ArduinoTools.jl")
ser = ArduinoTools.connectBoard(115200)
-ArduinoTools.DCMotorSetup(ser,3,1,9,10)
+ArduinoTools.DCMotorSetup(ser, 3, 1, 9, 10)
for i = 1:4
- ArduinoTools.DCMotorRun(ser,1,100)
+ ArduinoTools.DCMotorRun(ser, 1, 100)
sleep(3)
- ArduinoTools.DCMotorRun(ser,1,0)
+ ArduinoTools.DCMotorRun(ser, 1, 0)
sleep(2)
- ArduinoTools.DCMotorRun(ser,1,-100)
+ ArduinoTools.DCMotorRun(ser, 1, -100)
sleep(2)
end
-ArduinoTools.DCMotorRelease(ser,1)
+ArduinoTools.DCMotorRelease(ser, 1)
close(ser)
diff --git a/user-code/dcmotor/python/dcmotor-both.py b/user-code/dcmotor/python/dcmotor-both.py
index 1db2463..286dcdb 100644
--- a/user-code/dcmotor/python/dcmotor-both.py
+++ b/user-code/dcmotor/python/dcmotor-both.py
@@ -1,8 +1,7 @@
import os
import sys
-cwd=os.getcwd()
-(setpath,Examples)=os.path.split(cwd)
-#print setpath
+cwd = os.getcwd()
+(setpath, Examples) = os.path.split(cwd)
sys.path.append(setpath)
from Arduino.Arduino import Arduino
@@ -10,31 +9,31 @@ from time import sleep
class DCMOTOR_ROTATION:
def __init__(self,baudrate):
- self.baudrate=baudrate
+ self.baudrate = baudrate
self.setup()
self.run()
self.exit()
def setup(self):
- self.obj_arduino=Arduino()
- self.port=self.obj_arduino.locateport()
- self.obj_arduino.open_serial(1,self.port,self.baudrate)
+ self.obj_arduino = Arduino()
+ self.port = self.obj_arduino.locateport()
+ self.obj_arduino.open_serial(1, self.port, self.baudrate)
def run(self):
- self.pin1=9
- self.pin2=10
- self.obj_arduino.cmd_dcmotor_setup(1,3,1,self.pin1,self.pin2)
- self.obj_arduino.cmd_dcmotor_run(1,1,100)
+ self.pin1 = 9
+ self.pin2 = 10
+ self.obj_arduino.cmd_dcmotor_setup(1, 3, 1, self.pin1, self.pin2)
+ self.obj_arduino.cmd_dcmotor_run(1, 1, 100)
sleep(3)
- self.obj_arduino.cmd_dcmotor_run(1,1,-100)
- sleep(3)
- self.obj_arduino.cmd_dcmotor_release(1,1)
+ self.obj_arduino.cmd_dcmotor_run(1, 1, -100)
+ sleep(2)
+ self.obj_arduino.cmd_dcmotor_release(1, 1)
def exit(self):
self.obj_arduino.close_serial()
def main():
- obj_dcmotor=DCMOTOR_ROTATION(115200)
+ obj_dcmotor = DCMOTOR_ROTATION(115200)
-if __name__=='__main__':
+if __name__ == '__main__':
main()
diff --git a/user-code/dcmotor/python/dcmotor-clock.py b/user-code/dcmotor/python/dcmotor-clock.py
index 0a66f10..5b944f7 100644
--- a/user-code/dcmotor/python/dcmotor-clock.py
+++ b/user-code/dcmotor/python/dcmotor-clock.py
@@ -2,9 +2,8 @@ import os
import sys
import os
import sys
-cwd=os.getcwd()
-(setpath,Examples)=os.path.split(cwd)
-#print setpath
+cwd = os.getcwd()
+(setpath, Examples) = os.path.split(cwd)
sys.path.append(setpath)
from Arduino.Arduino import Arduino
@@ -12,26 +11,24 @@ from time import sleep
class DCMOTOR_ROTATION:
def __init__(self,baudrate):
- self.baudrate=baudrate
+ self.baudrate = baudrate
self.setup()
self.run()
self.exit()
def setup(self):
- self.obj_arduino=Arduino()
- self.port=self.obj_arduino.locateport()
- self.obj_arduino.open_serial(1,self.port,self.baudrate)
+ self.obj_arduino = Arduino()
+ self.port = self.obj_arduino.locateport()
+ self.obj_arduino.open_serial(1, self.port, self.baudrate)
def run(self):
- self.pin1=9
- self.pin2=10
- self.obj_arduino.cmd_dcmotor_setup(1,3,1,self.pin1,self.pin2)
- self.obj_arduino.cmd_dcmotor_run(1,1,100)
- sleep(2)
- self.obj_arduino.cmd_dcmotor_release(1,1)
-
-
-
+ self.pin1 = 9
+ self.pin2 = 10
+ self.obj_arduino.cmd_dcmotor_setup(1, 3, 1, self.pin1, self.pin2)
+ self.obj_arduino.cmd_dcmotor_run(1, 1, 100)
+ sleep(3)
+ self.obj_arduino.cmd_dcmotor_release(1, 1)
+
def exit(self):
self.obj_arduino.close_serial()
diff --git a/user-code/dcmotor/python/dcmotor-loop.py b/user-code/dcmotor/python/dcmotor-loop.py
index dffbbb1..ee2f9cc 100644
--- a/user-code/dcmotor/python/dcmotor-loop.py
+++ b/user-code/dcmotor/python/dcmotor-loop.py
@@ -2,9 +2,8 @@ import os
import sys
import os
import sys
-cwd=os.getcwd()
-(setpath,Examples)=os.path.split(cwd)
-#print setpath
+cwd = os.getcwd()
+(setpath, Examples) = os.path.split(cwd)
sys.path.append(setpath)
from Arduino.Arduino import Arduino
@@ -12,26 +11,26 @@ from time import sleep
class DCMOTOR_ROTATION:
def __init__(self,baudrate):
- self.baudrate=baudrate
+ self.baudrate = baudrate
self.setup()
self.run()
self.exit()
def setup(self):
- self.obj_arduino=Arduino()
- self.port=self.obj_arduino.locateport()
- self.obj_arduino.open_serial(1,self.port,self.baudrate)
+ self.obj_arduino = Arduino()
+ self.port = self.obj_arduino.locateport()
+ self.obj_arduino.open_serial(1, self.port, self.baudrate)
def run(self):
- self.pin1=9
- self.pin2=10
+ self.pin1 = 9
+ self.pin2 = 10
for i in range(4):
- self.obj_arduino.cmd_dcmotor_setup(1,3,1,self.pin1,self.pin2)
- self.obj_arduino.cmd_dcmotor_run(1,1,150)
+ self.obj_arduino.cmd_dcmotor_setup(1, 3, 1, self.pin1, self.pin2)
+ self.obj_arduino.cmd_dcmotor_run(1, 1, 100)
sleep(3)
self.obj_arduino.cmd_dcmotor_run(1,1,0)
sleep(2)
- self.obj_arduino.cmd_dcmotor_run(1,1,-150)
+ self.obj_arduino.cmd_dcmotor_run(1,1,-100)
sleep(2)
self.obj_arduino.cmd_dcmotor_release(1,1)
@@ -39,7 +38,7 @@ class DCMOTOR_ROTATION:
self.obj_arduino.close_serial()
def main():
- obj_dcmotor=DCMOTOR_ROTATION(115200)
+ obj_dcmotor = DCMOTOR_ROTATION(115200)
-if __name__=='__main__':
+if __name__== '__main__':
main()
diff --git a/user-code/dcmotor/scilab/dcmotor-both.sce b/user-code/dcmotor/scilab/dcmotor-both.sce
index 04f4ff8..4b03772 100644
--- a/user-code/dcmotor/scilab/dcmotor-both.sce
+++ b/user-code/dcmotor/scilab/dcmotor-both.sce
@@ -1,9 +1,8 @@
-ok = open_serial(1,2,115200) //COM port is 2 and baud rate is 115200
-cmd_dcmotor_setup(1,3,1,10,11) // Setup DC motor of type 3 (L293D), motor 1, pin 9 and 10
-cmd_dcmotor_run(1,1,100) // Motor 1 runs at PWM 100
+ok = open_serial(1, 2, 115200) //COM port is 2 and baud rate is 115200
+cmd_dcmotor_setup(1, 3, 1, 9, 10) // Setup DC motor of type 3 (L293D), motor 1, pin 9 and 10
+cmd_dcmotor_run(1, 1, 100) // Motor 1 runs at PWM 100
sleep(3000) // for 3 seconds
-cmd_dcmotor_run(1,1,-100) // Motor 1 runs at PWM -100 in reverse
-direction
+cmd_dcmotor_run(1, 1, -100) // Motor 1 runs at PWM -100 in reverse direction
sleep(2000) // for 2 seconds
-cmd_dcmotor_release(1,1) // Motor 1 is released
-close_serial(1)
+cmd_dcmotor_release(1, 1) // Motor 1 is released
+close_serial(1);
diff --git a/user-code/dcmotor/scilab/dcmotor-both.zcos b/user-code/dcmotor/scilab/dcmotor-both.zcos
index 9af1541..dc0428c 100644
--- a/user-code/dcmotor/scilab/dcmotor-both.zcos
+++ b/user-code/dcmotor/scilab/dcmotor-both.zcos
Binary files differ
diff --git a/user-code/dcmotor/scilab/dcmotor-clock.sce b/user-code/dcmotor/scilab/dcmotor-clock.sce
index 9a32392..d50bbee 100644
--- a/user-code/dcmotor/scilab/dcmotor-clock.sce
+++ b/user-code/dcmotor/scilab/dcmotor-clock.sce
@@ -1,6 +1,6 @@
-ok = open_serial(1,2,115200) //COM port is 2 and baud rate is 115200
-cmd_dcmotor_setup(1,3,1,9,10) // Setup DC motor of type 3 (L293D), motor 1, pin 9 and 10
-cmd_dcmotor_run(1,1,100) // Motor 1 runs at PWM 100
+ok = open_serial(1, 2, 115200) //COM port is 2 and baud rate is 115200
+cmd_dcmotor_setup(1, 3, 1, 9, 10) // Setup DC motor of type 3 (L293D), motor 1, pin 9 and 10
+cmd_dcmotor_run(1, 1, 100) // Motor 1 runs at PWM 100
sleep(3000) // This is allowed to continue for 3 seconds
-cmd_dcmotor_release(1,1) // Motor 1 is released
-close_serial(1)
+cmd_dcmotor_release(1, 1) // Motor 1 is released
+close_serial(1);
diff --git a/user-code/dcmotor/scilab/dcmotor-clock.zcos b/user-code/dcmotor/scilab/dcmotor-clock.zcos
index 79f185b..9539a2a 100644
--- a/user-code/dcmotor/scilab/dcmotor-clock.zcos
+++ b/user-code/dcmotor/scilab/dcmotor-clock.zcos
Binary files differ
diff --git a/user-code/dcmotor/scilab/dcmotor-loop.sce b/user-code/dcmotor/scilab/dcmotor-loop.sce
index ceee5a2..87b74e8 100644
--- a/user-code/dcmotor/scilab/dcmotor-loop.sce
+++ b/user-code/dcmotor/scilab/dcmotor-loop.sce
@@ -1,13 +1,13 @@
-ok = open_serial(1,2,115200)//COM port is 2 and baud rate is 115200
-if ok~=0, error('Serial port is not accesible'); end
-cmd_dcmotor_setup(1,3,1,9,10) // Setup DC motor of type 3 (L293D), motor 1, pins 9 and 10
-for x=1:4
- cmd_dcmotor_run(1,1,100) // Motor 1 runs at PWM 100
+ok = open_serial(1, 2, 115200)//COM port is 2 and baud rate is 115200
+if ok ~= 0, error('Serial port is not accesible'); end
+cmd_dcmotor_setup(1, 3, 1, 9, 10) // Setup DC motor of type 3 (L293D), motor 1, pins 9 and 10
+for i = 1:4
+ cmd_dcmotor_run(1, 1, 100) // Motor 1 runs at PWM 100
sleep(3000) // for 3 seconds
- cmd_dcmotor_run(1,1,0) // Halt the motor
- sleep(2000) // for 2 seconds
- cmd_dcmotor_run(1,1,-100) // Run it at PWM 100 in reverse direction
+ cmd_dcmotor_run(1, 1, 0) // Halt the motor
+ sleep(2000) // for 2 seconds
+ cmd_dcmotor_run(1, 1, -100) // Run it at PWM 100 in reverse direction
sleep(2000) // for 2 seconds
end
-cmd_dcmotor_release(1,1) // Motor 1 is released
-close_serial(1)
+cmd_dcmotor_release(1, 1) // Motor 1 is released
+close_serial(1);
diff --git a/user-code/dcmotor/scilab/dcmotor-loop.zcos b/user-code/dcmotor/scilab/dcmotor-loop.zcos
index 1f3ff68..cb6f95a 100644
--- a/user-code/dcmotor/scilab/dcmotor-loop.zcos
+++ b/user-code/dcmotor/scilab/dcmotor-loop.zcos
Binary files differ