Post Go back to editing

Fail to recognise cosf/sqrtf during building hex file

Thread Summary

The user encountered an error while building the hex file for the ADE943 in AD-PQMON-SL on a Linux system (Banana Pi BPI-M4). The solution was to add 'CFLAGS += -lm' in the Makefile and 'EXTRA_LIBS += m' in the src.mk to link the math library correctly.
AI Generated Content
Category: Hardware
Product Number: AD-PQMON-SL

Hardware: ADE943 in AD-PQMON-SL

OS: Linux (Installed on Banana Pi BPI-M4)

 

Error Screenshot:

 

 

Coding in pqlib_convert.c:

To measure phase-to-phase voltage

float convert_voltage_three_phase_mag_type(ADI_VOLTAGE_TYPE mag_phase_1, ADI_VOLTAGE_TYPE mag_phase_2, ADI_PHASE_ANGLE_TYPE angle_phase_1, ADI_PHASE_ANGLE_TYPE angle_phase_2)
{

	float converted_voltage_phase_1_mag = (float)mag_phase_1 * ((float)ConversionConstant_Voltage);
	float converted_voltage_phase_2_mag = (float)mag_phase_2 * ((float)ConversionConstant_Voltage);

	float converted_voltage_phase_1_angle = ((float)angle_phase_1 * 0.017578125f) * (M_PI / 180);
	float converted_voltage_phase_2_angle = ((float)angle_phase_2 * 0.017578125f) * (M_PI / 180);
	
	float voltage_three_phase_total_mag = (float)sqrtf((converted_voltage_phase_1_mag * converted_voltage_phase_1_mag) +
		(converted_voltage_phase_2_mag * converted_voltage_phase_2_mag)
		- (2 * converted_voltage_phase_1_mag * converted_voltage_phase_2_mag * cosf(converted_voltage_phase_1_angle - converted_voltage_phase_2_angle)));

	return voltage_three_phase_total_mag;
}

 

Troubleshooting steps that has been taken:

  1. In no-OS/projects/eval-pqmon/src/common/pqlib_convert.c >> Line 63, M_PI constant from math .h has been used and build hex file without abnormal.
  2. Add line below in no-OS/projects/eval-pqmon/Makefile but error persisted
    • LDLIBS += -lm
  3. Passing LDFLAGS+="-lm" on the command line during building hex file but error persisted
    • make PLATFORM=maxim TARGET=max32650 INTERFACE=usb PQLIB_PATH=C:/Users/XXXXXXX/no-OS/projects/eval-pqmon/pqlib_dir LDFLAGS+="-lm" run