Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ACC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alfonso Parra Rubio
ACC
Commits
492f21fd
Commit
492f21fd
authored
Jun 16, 2024
by
Alfonso Parra Rubio
Browse files
Options
Downloads
Patches
Plain Diff
stable code motors running
parent
5302a13a
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.DS_Store
+0
-0
0 additions, 0 deletions
.DS_Store
code/.DS_Store
+0
-0
0 additions, 0 deletions
code/.DS_Store
code/motors_accel/motors_accel.ino
+66
-0
66 additions, 0 deletions
code/motors_accel/motors_accel.ino
with
66 additions
and
0 deletions
.DS_Store
0 → 100644
+
0
−
0
View file @
492f21fd
File added
This diff is collapsed.
Click to expand it.
code/.DS_Store
0 → 100644
+
0
−
0
View file @
492f21fd
File added
This diff is collapsed.
Click to expand it.
code/motors_accel/motors_accel.ino
0 → 100755
+
66
−
0
View file @
492f21fd
// Include the AccelStepper Library
#include
<AccelStepper.h>
// Define pin connections
const
int
guillotinedirPin
=
1
;
const
int
guillotinestepPin
=
2
;
const
int
feederdirPin
=
14
;
const
int
feederstepPin
=
15
;
// Define motor interface type
#define motorInterfaceType 1
// outside leads to ground and +5V
int
val
=
0
;
// variable to store the value read
int
analogPin
=
26
;
// potentiometer wiper (middle terminal) connected to analog pin 3
// outside leads to ground and +5V
// Creates an instance
AccelStepper
guillotine
(
motorInterfaceType
,
guillotinestepPin
,
guillotinedirPin
);
AccelStepper
feeder
(
motorInterfaceType
,
feederstepPin
,
feederdirPin
);
void
setup
()
{
// set the maximum speed, acceleration factor,
// guillotine initial speed and target position
guillotine
.
setMaxSpeed
(
10000
);
guillotine
.
setAcceleration
(
5500
);
guillotine
.
setSpeed
(
9000
);
guillotine
.
moveTo
(
200
*
16
*
5
);
//feeder params
feeder
.
setMaxSpeed
(
10000
);
feeder
.
setAcceleration
(
5500
);
feeder
.
setSpeed
(
9000
);
feeder
.
moveTo
(
200
*
16
*
0.5
);
// microstepping the guillotine and the feeder? can they share a bus? we will see
pinMode
(
3
,
OUTPUT
);
pinMode
(
4
,
OUTPUT
);
pinMode
(
5
,
OUTPUT
);
//microstepping the feeder
}
void
loop
()
{
val
=
analogRead
(
analogPin
);
val
=
map
(
val
,
0
,
1023
,
1
,
10
);
guillotine
.
setSpeed
(
val
*
1000
);
Serial
.
println
(
val
);
// debug value
// Change direction once the motor reaches target position
digitalWrite
(
3
,
HIGH
);
digitalWrite
(
4
,
HIGH
);
digitalWrite
(
5
,
HIGH
);
if
(
feeder
.
distanceToGo
()
==
0
)
feeder
.
moveTo
(
-
feeder
.
currentPosition
());
// Move the motor one step
guillotine
.
run
();
feeder
.
run
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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
sign in
to comment