You are here

How difficult would it be to add code to read an external EEPROM, and deactivate/activate depending on a value

1 post / 0 new
PaulMakesThings
Offline
Last seen: 3 months 2 weeks ago
Joined: 2021-10-13 08:51
Posts: 1
How difficult would it be to add code to read an external EEPROM, and deactivate/activate depending on a value

I'm working on something for a quick proof of concept. And since I need to customize the code for a BLDC driver I've gotten two VESC based drivers to work with.

I was wondering, how hard would it be to use one of the ports to read an EEPROM, and if a given value is read, don't run, otherwise run as usual. That's all I need it to do. But I don't have the dev toolchain set up. Nor is the same EEPROM library likely to work. Since time is limited I'd just like to feel out how practical this is.

Here is an example of how I read the needed code on Arduino

#include <I2CEEPROM.h>

#define CHIP_ADDRESS 0x51 // Address of EEPROM chip (24LC256->0x50)
#define EEPROM_BYTES 416 // Number of bytes in EEPROM chip

I2CEEPROM i2c_eeprom(CHIP_ADDRESS); // Create I2C EEPROM instance

unsigned int data_length = 4;
unsigned int start_address = 0x6000;
unsigned int end_address = start_address + data_length;
byte data_packet[4] = {0,0,0,0};

And then when I want to read it:

data_packet[0] = i2c_eeprom.read(start_address);

Is there a library that will work with the VESC firmware that I can use to read an EEPROM through pins that are broken out on an connector (I have a VESC 4.12)? And is there a good location in the existing code to block operation of the motor? I would assume adding it in somewhere around where it reads the user input and converts it to a drive command would be best.