Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
SCPActuatorCoiling
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pooja Patel
SCPActuatorCoiling
Commits
2a7589de
Commit
2a7589de
authored
7 years ago
by
patelpb
Browse files
Options
Downloads
Patches
Plain Diff
Updated coiling code
parent
e41a2dbc
Branches
master
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Final_Coil_Insertion_Code/Final_Coil_Insertion_Code.ino
+68
-0
68 additions, 0 deletions
Final_Coil_Insertion_Code/Final_Coil_Insertion_Code.ino
with
68 additions
and
0 deletions
main/coiling.ino/coiling
.ino
→
Final_Coil_Insertion_Code/Final_Coil_Insertion_Code
.ino
+
68
−
0
View file @
2a7589de
#include
<Stepper.h>
#include
<ESP.h>
const
int
stepsPerRevolution
=
200
;
// change this to fit the number of steps per revolution
const
int
rpm
=
200
;
const
int
MAXSTEPS
=
10
;
// for your motor
//asdfasdfasdf
...
...
@@ -16,34 +18,51 @@ Stepper myStepper(stepsPerRevolution, PIN1, PIN2, PIN3, PIN4);
int
stepCount
=
0
;
// number of steps the motor has taken
void
do_steps
(
int
num_steps
){
int
stepsPerSecond
=
stepsPerRevolution
/
(
60
*
rpm
);
//int run_
int
doSteps
(
int
num_steps
){
int
numRevs
=
0
;
int
do_count
=
num_steps
/
MAXSTEPS
;
int
count_remainder
=
num_steps
%
MAXSTEPS
;
for
(
int
i
=
0
;
i
<
do_count
;
++
i
){
myStepper
.
step
(
-
MAXSTEPS
);
//Serial.print("Increment: ");
if
(
i
%
20
==
0
){
Serial
.
printf
(
"Number of Revolutions: %d
\n
"
,
numRevs
++
);
}
ESP
.
wdtFeed
();
//yield; feeds the watchdog (resets the software timer)
}
myStepper
.
step
(
count_remainder
);
ESP
.
wdtFeed
();
return
numRevs
;
}
void
setup
()
{
wdt_disable
();
ESP
.
wdtDisable
();
pinMode
(
PIN1
,
OUTPUT
);
pinMode
(
PIN2
,
OUTPUT
);
pinMode
(
PIN3
,
OUTPUT
);
pinMode
(
PIN4
,
OUTPUT
);
Serial
.
println
(
"asdfsdF"
);
Serial
.
begin
(
115200
);
myStepper
.
setSpeed
(
rpm
);
// step 1/100 of a revolution:
int
numRevolutions
=
(
int
)
1e5
;
doSteps
(
numRevolutions
*
stepsPerRevolution
);
Serial
.
println
(
stepCount
);
}
void
loop
()
{
// step 1/100 of a revolution:
int
numRevolutions
=
10
;
myStepper
.
step
(
numRevolutions
*
stepsPerRevolution
);
Serial
.
println
(
stepCount
);
delay
(
500
);
ESP
.
wdtFeed
(
);
//
delay(500);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment