|
AMK_motor_drive_software 1.0.0
|
#include <Arduino.h>#include <CANSAME5x.h>#include "AMKUtils.hpp"#include "Inverter.hpp"#include "CANMessage.hpp"#include "CANCommunication.hpp"#include "DebugFlags.hpp"#include "Potentiometer.hpp"Functions | |
| void | setup () |
| void | loop () |
| void | initDevice () |
| Initializes the device settings, such as serial communication and CAN bus. | |
| void | startCANBus (long speed) |
| Initializes the CAN bus with a given speed. | |
| void | receiveMessage (int packetSize) |
| Callback function to handle received CAN messages. | |
| bool | sendMessage (CANMessage canMsg) |
| Sends a CAN message over the CAN bus. | |
| void | updateInverter (uint16_t nodeAddress, uint16_t baseAddress, CANMessage canMsg) |
| Updates inverter data based on received CAN message information. | |
Variables | |
| CANSAME5x | CAN |
| CANMessage | canMsg |
| Inverter | inverters [2] |
| Potentiometer | pot |
| void initDevice | ( | ) |
Initializes the device settings, such as serial communication and CAN bus.
This function sets up the serial port and initializes the CAN bus at a specified baud rate.
| void loop | ( | ) |
| void receiveMessage | ( | int | packetSize | ) |
Callback function to handle received CAN messages.
| packetSize | The size of the incoming packet. |
Processes incoming CAN messages by extracting the CAN ID and data, updating inverter information, and handling errors for unknown nodes or invalid packet sizes.
| bool sendMessage | ( | CANMessage | canMsg | ) |
Sends a CAN message over the CAN bus.
| canMsg | The CAN message object containing the ID and data to be sent. |
Initiates the sending of a CAN message with the specified ID and data.
| void setup | ( | ) |
| void startCANBus | ( | long | speed | ) |
Initializes the CAN bus with a given speed.
| speed | The CAN bus speed in bits per second (bps). For example, 500E3 for 500 kbps. |
Configures the CAN bus speed and manages necessary pin settings to enable the CAN module. If initialization fails, an error message is displayed, and the built-in LED flashes.
| void updateInverter | ( | uint16_t | nodeAddress, |
| uint16_t | baseAddress, | ||
| CANMessage | canMsg ) |
Updates inverter data based on received CAN message information.
| nodeAddress | The address of the inverter node to be updated. |
| baseAddress | The base address used to identify the type of message. |
| canMsg | The CAN message containing the data to update the inverter. |
Parses data from the received CAN message to update specific inverter parameters, such as status, velocity, and temperature.
| CANSAME5x CAN |
| CANMessage canMsg |
| Inverter inverters[2] |
| Potentiometer pot |