Midnight Sun Firmware
Loading...
Searching...
No Matches
current_acs37800_defs.h
1#pragma once
2
3/************************************************************************************************
4 * @file current_acs37800_defs.h
5 *
6 * @brief Current Sensor ACS37800 Defs
7 *
8 * @date 2025-07-30
9 * @author Midnight Sun Team #24 - MSXVI
10 ************************************************************************************************/
11
12/* Standard library Headers */
13
14/* Inter-component Headers */
15
16/* Intra-component Headers */
17
24// Table value formula, NEED the Rsense and Riso resistor values for line voltage calculation
25#define VOLTAGE_SCALE ((0.84 * 1.19) / 32768.0)
26
27#define CURRENT_SCALE ((0.84 * 1.19) / 32768.0)
28#define POWER_SCALE ((0.704 * 1.42) / 32768.0)
29#define ACS37800_MASK_FAULTOUT 0x02 // Bit 1
30#define ACS37800_MASK_OVERVOLTAGE 0x08 // Bit 3
31#define ACS37800_MASK_UNDERVOLTAGE 0x10 // Bit 4
32
33// register map is on pg.38
34// https://www.allegromicro.com/-/media/files/datasheets/acs37800-datasheet.ashx
35typedef enum {
36 ACS37800_REG_VRMS_IRMS = 0x20, // Voltage and Current RMS
37 ACS37800_REG_VCODES_ICODES = 0x2A, // Voltage and Current Instantaneous
38 ACS37800_REG_PINSTANT = 0x2C, // Power Instantaneous
39 ACS37800_REG_PACTIVE_PIMAGE = 0x21, // Active & Reactive Power Output
40 ACS37800_REG_PAPPARENT_PFACTOR = 0x22, // Apparent power & Power factor output
41 ACS37800_REG_NUMPTSOUT = 0x25, // number of points for RMS calculation
42 ACS37800_REG_VI_RMSAVGONESEC = 0x26, // Voltage & Current average RMS (seconds)
43 ACS37800_REG_VI_RMSAVGONEMIN = 0x27, // Voltage & Current average RMS (minutes)
44 ACS37800_PACTAVGONESEC = 0x28, // Power average RMS (seconds)
45 ACS37800_REG_PACTAVGONEMIN = 0x29, // Power average RMS (minutes)
46 ACS37800_REG_STATUS = 0x2D // ZEROCROSSOUT, OVERVOLTAGE, UNDERVOLTAGE, FAULTOUT, FAULTLATCHED
47} ACS37800_Registers;
48