Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
loadcell
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
Model registry
Operate
Environments
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
Sam Calisch
loadcell
Commits
ddb3c769
There was a problem fetching the pipeline summary.
Commit
ddb3c769
authored
Sep 25, 2017
by
Sam Calisch
Browse files
Options
Downloads
Patches
Plain Diff
added microstepping, current limit, and step speed commands
parent
db2900cd
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
as5013-test/nrf52-as5013/nrf52-as5013.ino
+21
-13
21 additions, 13 deletions
as5013-test/nrf52-as5013/nrf52-as5013.ino
as5013-test/nrf52-drv8825/nrf52-drv8825.ino
+36
-24
36 additions, 24 deletions
as5013-test/nrf52-drv8825/nrf52-drv8825.ino
with
57 additions
and
37 deletions
as5013-test/nrf52-as5013/nrf52-as5013.ino
+
21
−
13
View file @
ddb3c769
...
...
@@ -16,6 +16,9 @@
static
uint8_t
txdata
[
n_tx_bytes
]
=
{
0
};
static
uint8_t
rxdata
[
n_rx_bytes
]
=
{
0
};
//uint16_t step_period = 30000; //microseconds
//uarte
const
uint8_t
pin_rx
=
8
;
const
uint8_t
pin_tx
=
6
;
...
...
@@ -121,28 +124,33 @@ void as5013_read(){
//main
//
void
setup
()
{
Serial
.
begin
(
115200
);
//
uarte_setup();
//
Serial.begin(115200);
uarte_setup
();
twi_setup
();
as5013_setup
();
radio_setup
();
//set step speed
radio_buffer
[
0
]
=
2
;
//set step speed
radio_buffer
[
1
]
=
10000
;
//30ms step period
radio_send_redundant
();
//set full steps
radio_buffer
[
0
]
=
3
;
//set step speed
radio_buffer
[
1
]
=
0
;
//M1,M0 = 0,1
radio_send_redundant
();
//set current limit
radio_buffer
[
0
]
=
4
;
//set step speed
radio_buffer
[
1
]
=
100
;
//M1,M0 = 0,1
radio_send_redundant
();
while
(
1
){
if
(
millis
()
-
last_tx_time
>
tx_period
){
as5013_read
();
radio_buffer
[
0
]
=
1
;
//send a move command
radio_buffer
[
1
]
=
10
;
//move 10 steps forward
radio_send_redundant
();
//send command
Serial
.
println
(
"sent command"
);
//int result = radio_recv(); //wait for response
//test for false positives:
//Serial.print("result: ");
//Serial.println(result);
//if (radio_buffer[1] != 0){
// Serial.print("XXXXX buffer: ");
// Serial.println(radio_buffer[1]);
//}
//NRF_UARTE0->TXD.PTR = (uint32_t)(&rxdata); //reset pointer to start of buffer
//NRF_UARTE0->TASKS_STARTTX = 1; //trigger start task
NRF_UARTE0
->
TXD
.
PTR
=
(
uint32_t
)(
&
rxdata
);
//reset pointer to start of buffer
NRF_UARTE0
->
TASKS_STARTTX
=
1
;
//trigger start task
last_tx_time
=
millis
();
}
}
...
...
This diff is collapsed.
Click to expand it.
as5013-test/nrf52-drv8825/nrf52-drv8825.ino
+
36
−
24
View file @
ddb3c769
#include
"radio.h"
uint16_t
pwms
[
1
]
=
{
0
};
uint16_t
step_period
=
20000
;
//microseconds
const
uint8_t
pin_mode1
=
3
;
//A1
const
uint8_t
pin_mode0
=
0
;
//XL1
...
...
@@ -27,10 +28,10 @@ void stepper_setup(){
NRF_PWM0
->
ENABLE
=
(
PWM_ENABLE_ENABLE_Enabled
<<
PWM_ENABLE_ENABLE_Pos
);
NRF_PWM0
->
MODE
=
(
PWM_MODE_UPDOWN_Up
<<
PWM_MODE_UPDOWN_Pos
);
NRF_PWM0
->
PRESCALER
=
(
PWM_PRESCALER_PRESCALER_DIV_1
<<
PWM_PRESCALER_PRESCALER_Pos
);
//16MHz tick
NRF_PWM0
->
COUNTERTOP
=
(
1600
<<
PWM_COUNTERTOP_COUNTERTOP_Pos
);
//1 kHz pwm freq.
NRF_PWM0
->
COUNTERTOP
=
(
1600
<<
PWM_COUNTERTOP_COUNTERTOP_Pos
);
//1
0
kHz pwm freq.
NRF_PWM0
->
LOOP
=
(
PWM_LOOP_CNT_Disabled
<<
PWM_LOOP_CNT_Pos
);
NRF_PWM0
->
DECODER
=
(
PWM_DECODER_LOAD_Common
<<
PWM_DECODER_LOAD_Pos
)
|
(
PWM_DECODER_MODE_RefreshCount
<<
PWM_DECODER_MODE_Pos
);
pwms
[
0
]
=
1
5
00
;
//
50% duty cycle to tes
t
pwms
[
0
]
=
1
600
-
1
00
;
//
100/1600 * 3.3v = .2V = 200 mA limi
t
NRF_PWM0
->
SEQ
[
0
].
PTR
=
((
uint32_t
)(
pwms
)
<<
PWM_SEQ_PTR_PTR_Pos
);
NRF_PWM0
->
SEQ
[
0
].
CNT
=
(
1
<<
PWM_SEQ_CNT_CNT_Pos
);
NRF_PWM0
->
SEQ
[
0
].
REFRESH
=
0
;
...
...
@@ -51,27 +52,47 @@ void parse_command(){
}
for
(
i
=
0
;
i
<
radio_buffer
[
1
];
i
++
){
NRF_GPIO
->
OUTSET
=
(
1
<<
pin_step
);
delay
(
10
);
delay
Microseconds
(
step_period
);
NRF_GPIO
->
OUTCLR
=
(
1
<<
pin_step
);
delay
(
1
);
delayMicroseconds
(
10
);
}
}
else
if
(
radio_buffer
[
0
]
==
2
){
//change step speed
step_period
=
radio_buffer
[
1
];
}
else
if
(
radio_buffer
[
0
]
==
3
){
//change microstepping
if
(
radio_buffer
[
1
]
&&
1
){
NRF_GPIO
->
OUTSET
=
(
1
<<
pin_mode0
);
}
else
{
NRF_GPIO
->
OUTCLR
=
(
1
<<
pin_mode0
);
}
if
(
radio_buffer
[
1
]
&&
2
){
NRF_GPIO
->
OUTSET
=
(
1
<<
pin_mode0
);
}
else
{
NRF_GPIO
->
OUTCLR
=
(
1
<<
pin_mode0
);
}
}
else
if
(
radio_buffer
[
0
]
==
4
){
pwms
[
0
]
=
1600
-
radio_buffer
[
1
];
//100/1600 * 3.3v = .2V = 200 mA limit
NRF_PWM0
->
SEQ
[
0
].
REFRESH
=
1
;
}
else
{
}
//unrecognized command, set radio buffer to all -1
//for(int i=0; i<PACKET_LENGTH; i++){
// radio_buffer[i] = -1;
//}
//reset radio buffer
for
(
i
=
0
;
i
<
PACKET_LENGTH
;
i
++
){
radio_buffer
[
i
]
=
0
;
}
}
else
{
//unrecognized command, set radio buffer to all -1
for
(
int
i
=
0
;
i
<
PACKET_LENGTH
;
i
++
){
radio_buffer
[
i
]
=
-
1
;
}
}
}
void
setup
()
{
Serial
.
begin
(
115200
);
//
Serial.begin(115200);
//Switch to internal LFCLK to disconnect from XL1 and XL2
NRF_CLOCK
->
LFCLKSRC
=
0
;
//disconnect XL1 AND XL2 FROM LFCLK?
...
...
@@ -86,16 +107,7 @@ void setup() {
while
(
true
)
{
int
result
=
radio_recv
();
//wait until recieve
//if (result==0){
//no crc error
parse_command
();
//} else{
//incoming crc error, set radio buffer to all -2
// for(int i=0; i<PACKET_LENGTH; i++){
// radio_buffer[i] = -2;
// }
//}
//radio_send(); //send back radio buffer when done
parse_command
();
//todo: move stepping to non-blocking so can receive commands during moves
}
}
...
...
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