Hello,
While the final layout of my board is not ready.
I decided to buy a test board (follow link)
en.aliexpress.com/.../32955526756.html a2g03.search0104.3.207.2263376bMTd8Uc & ws_ab_test = searchweb0_0 2Csearchweb201602_3_10065_10068_10547_319_5730915_317_10548_10696_453_10084_454_10083_10618_10307_538_537_536_5729815_10059_10884_10887_100031_321_322_10103%%% 2Csearchweb201603_2 2CppcSwitch_0 & algo_pvid = 1a563b4d-fe92-4379-8b5b-ce7e5db47fbe & algo_expid = 1a563b4d-fe92-4379-8b5b-32-ce7e5db47fbe
The (.c) and (.h) driver files as well as the schematic of the board are attached. And most importantly a scan of the AD values passed to the serial in the file screen.jpg.
The problem is that even using the battery in power in conjunction with the REF5025 I'm seeing a big change in the last 8 bits of the AD and I believe something is wrong.
Here's the AD reading function:
// READ
void Read (void)
{
unsigned int data = 0;
while (DOUT_READ_BIT);
Num ++;
for (char count = 0; count <25; count ++)
{
SCLK (1);
date = date << 1;
if (DOUT_READ_BIT)
date = date | 0x000001;
else
data = date & 0xFFFFFE;
SCLK (0);
}
Value = data >> 1;
Sum + = Value;
}
Here are the tasks to read and the average read
/ * StartDefaultTask function * /
void StartDefaultTask (void const * argument)
{
/ * USER CODE BEGIN 5 * /
/ * Infinite loop * /
for (;;)
{
osDelay (5); // EVERY 5ms
Read ();
}
/ * USER CODE END 5 * /
}
/ * StartTask02 function * /
void StartTask02 (void const * argument)
{
/ * USER CODE BEGIN StartTask02 * /
/ * Infinite loop * /
for (;;)
{
osDelay (500);
Avg = (float) Sum / Num;
Ad = (int) Avg;
Range = (Avg-Offset);
Weight = Range / Factor;
if (EAS_GetOffset) {
Offset = Avg;
EAS_GetOffset = 0;
}
if (EAS_GetFactor) {
Factor = (float) (Avg-Offset) / EAS_Weight;
EAS_GetFactor = 0;
}
snprintf (Vector, sizeof (Vector), "Avg:% f, AD:% x, Sum:% d, nReadings:% d, Weight:% f \ r \ n"
Avg, Ad, Sum, Num, Weight);
while (HAL_UART_Transmit_IT (& huart1, (uint8_t *) Vector, strlen (Vector)) = HAL_OK);
Num = 0;
Sum = 0;
}
/ * USER CODE END StartTask02 * /
}
[RELATED]