Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jake Read
ucbus-stepper
Commits
1d328cff
Commit
1d328cff
authored
Oct 14, 2020
by
Jake Read
Browse files
ready to loop roll
parent
baf73a77
Changes
2
Hide whitespace changes
Inline
Side-by-side
firmware/cl-step-controller/src/drivers/step_cl.cpp
View file @
1d328cff
...
...
@@ -106,11 +106,6 @@ void Step_CL::print_table(void){
// the calib routine
boolean
Step_CL
::
calibrate
(
void
){
flash_write_init
();
for
(
uint32_t
i
=
0
;
i
<
ENCODER_COUNTS
;
i
++
){
flash_write_value
(
i
*
1.1
F
);
}
return
true
;
// (1) first, build a table for 200 full steps w/ encoder averaged values at each step
float
phase_angle
=
0.0
F
;
for
(
uint8_t
i
=
0
;
i
<
200
;
i
++
){
...
...
@@ -167,7 +162,7 @@ boolean Step_CL::calibrate(void){
// now to build the actual table...
// want to start with the 0 indice,
flash_write_init
();
for
(
uint16_t
e
=
0
;
e
<
4
;
e
++
){
for
(
uint16_t
e
=
0
;
e
<
ENCODER_COUNTS
;
e
++
){
// find the interval that spans this sample
boolean
bi
=
false
;
int16_t
interval
=
-
1
;
...
...
@@ -258,7 +253,7 @@ boolean Step_CL::calibrate(void){
delay
(
10
);
}
// ok, have the real angle (ra) at the encoder tick (e), now write it
//
flash_write_value(ra); // this just happens in order, we zeroe'd out global counters at the start
flash_write_value
(
ra
);
// this just happens in order, we zeroe'd out global counters at the start
}
// end sweep thru 2^14 pts
sysError
(
"calib complete"
);
return
true
;
// went OK
...
...
log/cl-step-control-log.md
View file @
1d328cff
...
...
@@ -899,7 +899,69 @@ OK this is crazy, I have every fn in the class commented out, and the thing stil
So, tried my way around that, I have honestly no idea what is going on here. I'm going to try writing from the base class again.
OK, did that and seems like I'm writing into the thing.
OK, did that and seems like I'm writing into the thing.
Crazy. Here's the code:
-
neil suggests watching the power rails, flash req
-
nuclear option is asking neil to chat w/ microchip contacts
\ No newline at end of file
```
cpp
#define BYTES_PER_BLOCK 8192
#define FLOATS_PER_BLOCK 2048
const
float
__attribute__
((
__aligned__
(
8192
)))
lut
[
16834
]
=
{};
FlashClass
flashClass
((
const
uint8_t
*
)
lut
);
// write mechanics
const
void
*
block_ptr
;
// write buffer
static
float
buffer
[
FLOATS_PER_BLOCK
];
uint32_t
bfi
=
0
;
// buffer indice
uint32_t
bli
=
0
;
// block indice
//FlashStorage(flash_storage, flts);
void
flash_write_init
(
void
){
block_ptr
=
(
const
uint8_t
*
)
lut
;
bfi
=
0
;
bli
=
0
;
}
void
flash_write_page
(
void
){
sysError
(
"erasing"
);
flashClass
.
erase
(
block_ptr
,
BYTES_PER_BLOCK
);
sysError
(
"writing"
);
flashClass
.
write
(
block_ptr
,
(
const
uint8_t
*
)
buffer
,
BYTES_PER_BLOCK
);
delay
(
100
);
}
void
flash_write_value
(
float
val
){
buffer
[
bfi
++
]
=
val
;
if
(
bfi
>=
FLOATS_PER_BLOCK
){
flash_write_page
();
bfi
=
0
;
bli
++
;
block_ptr
=
((
const
uint8_t
*
)(
&
(
lut
[
bli
*
FLOATS_PER_BLOCK
])));
}
}
void
Step_CL
::
print_table
(
void
){
sysError
(
"reading from lut"
);
for
(
uint32_t
i
=
0
;
i
<
ENCODER_COUNTS
;
i
++
){
float
ra
=
lut
[
i
];
sysError
(
String
(
ra
));
delay
(
5
);
}
}
// the calib routine
boolean
Step_CL
::
calibrate
(
void
){
flash_write_init
();
for
(
uint32_t
i
=
0
;
i
<
ENCODER_COUNTS
;
i
++
){
flash_write_value
(
i
*
1.1
F
);
}
return
true
;
}
```
So I think now I'll carry on actually running the calibration, then see if I can send a 'torque' command down / operate a control loop.
Great, this calibrates, so now I can roll a tiny control loop, yeah?
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment