summaryrefslogtreecommitdiff
path: root/src/c/scilab-arduino/cmd_dcmotor_run
diff options
context:
space:
mode:
authorsiddhu89902015-12-17 14:48:36 +0530
committersiddhu89902015-12-23 11:26:29 +0530
commit329613eb48542f24bb9014a0a617b05199726e99 (patch)
treebf571563bb735fc2ccd9a300a952f8557667fd77 /src/c/scilab-arduino/cmd_dcmotor_run
parent96b51a5ded447676d493be9721e4480065a5ae7e (diff)
downloadscilab2c-329613eb48542f24bb9014a0a617b05199726e99.tar.gz
scilab2c-329613eb48542f24bb9014a0a617b05199726e99.tar.bz2
scilab2c-329613eb48542f24bb9014a0a617b05199726e99.zip
Code generation for Arduino changed. DC motor added to Arduino.
Diffstat (limited to 'src/c/scilab-arduino/cmd_dcmotor_run')
-rw-r--r--src/c/scilab-arduino/cmd_dcmotor_run/u8cmd_dcmotor_runs.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/c/scilab-arduino/cmd_dcmotor_run/u8cmd_dcmotor_runs.c b/src/c/scilab-arduino/cmd_dcmotor_run/u8cmd_dcmotor_runs.c
new file mode 100644
index 00000000..93905c94
--- /dev/null
+++ b/src/c/scilab-arduino/cmd_dcmotor_run/u8cmd_dcmotor_runs.c
@@ -0,0 +1,59 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008 - INRIA - Arnaud TORSET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "cmd_dcmotor_run.h"
+
+uint8 u8cmd_dcmotor_runs(uint8 board_no, uint8 motor_no, int16 duty)
+{
+ uint8 direction = 1;
+ if(duty >= 0)
+ {
+ direction = 1;
+ }
+ else
+ {
+ direction = 0;
+ duty = -duty;
+ }
+
+ if(duty > 255) duty = 255;
+
+ if (dcm_mode[motor_no] == 3) //L293
+ {
+ if(direction == 1)
+ {
+ analogWrite(dcm_pin_1[motor_no],duty);
+ analogWrite(dcm_pin_2[motor_no],0);
+ }
+ else
+ {
+ analogWrite(dcm_pin_2[motor_no],duty);
+ analogWrite(dcm_pin_1[motor_no],0);
+ }
+ }
+ else
+ {
+ if(direction == 1)
+ {
+ digitalWrite(dcm_pin_1[motor_no],HIGH);
+ digitalWrite(dcm_pin_2[motor_no],LOW);
+ }
+ else
+ {
+ digitalWrite(dcm_pin_2[motor_no],HIGH);
+ digitalWrite(dcm_pin_1[motor_no],LOW);
+ }
+ }
+
+ return 0;
+}
+