- Code: Select all
uint8_t SearchAndDestroy(void)
{
uint32_t newpower = voltage * current;
if(newpower > oldpower && direction == UP)
{
incrementREF();
oldpower = newpower;
return 0;
}
if(newpower > oldpower && direction == DOWN)
{
decrementREF();
oldpower = newpower;
return 0;
}
if(newpower < oldpower && direction == UP)
{
decrementREF();
direction = DOWN;
oldpower = newpower;
return 0;
}
if(newpower < oldpower && direction == DOWN)
{
incrementREF();
direction = UP;
oldpower = newpower;
return 0;
}
if(newpower == oldpower)
{
incrementREF();
oldpower = newpower;
return 0;
}
return 0;
}
The tracking routine is executed 10 times a second. Every increment/decrement step shifts the reference up or down 0.2 of a volt.
Ill upload schematics in the next few days.

