Commit 1d328cff authored by Jake Read's avatar Jake Read
Browse files

ready to loop roll

parent baf73a77
......@@ -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.1F);
}
return true;
// (1) first, build a table for 200 full steps w/ encoder averaged values at each step
float phase_angle = 0.0F;
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
......
......@@ -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.1F);
}
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment