Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set RPMs on slave VESC through CAN #8

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions examples/getDieBieMSCellsVoltage/getDieBieMSCellsVoltage.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
Name: getDieBieMSCellsVoltage.ino
Created: 04-08-2019
Author: Peemouse
Description: This example is made using a Arduino Micro (Atmega32u4) that has a HardwareSerial port (Serial1) seperated from the Serial port.
A Arduino Nano or Uno that only has one Serial port will not be able to display the data returned.
*/

#include <VescUart.h>

/** Initiate VescUart class */
VescUart UART;

char DieBieMS_CANID = 10; //CAN ID of DieBieMS. Default is 10.

void setup() {

/** Setup Serial port to display data */
Serial.begin(115200);

/** Setup UART port (Serial1 on Atmega32u4) */
Serial1.begin(115200);

while (!Serial) {;}

/** Define which ports to use as UART */
UART.setSerialPort(&Serial1);
}

void loop() {

/** Call the function getDieBieMSCellsVoltage() to acquire data from DieBieMS */
if ( UART.getDieBieMSCellsVoltage(DieBieMS_CANID) ) {

Serial.print("Num of cells ");
Serial.println(UART.DieBieMScells.noOfCells);

for (uint8_t i=0;i<=UART.DieBieMScells.noOfCells;i++){
Serial.print("cell #");
Serial.print(i);
Serial.print(" ");
Serial.print(UART.DieBieMScells.cellsVoltage[i]);
}
}
else
{
Serial.println("Failed to get DieBieMS cells voltage!");
}

delay(200);
}
44 changes: 44 additions & 0 deletions examples/getDieBieMSValues/getDieBieMSValues.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Name: getDieBieMSValues.ino
Created: 04-08-2019
Author: Peemouse
Description: This example is made using a Arduino Micro (Atmega32u4) that has a HardwareSerial port (Serial1) seperated from the Serial port.
A Arduino Nano or Uno that only has one Serial port will not be able to display the data returned.
*/

#include <VescUart.h>

/** Initiate VescUart class */
VescUart UART;

char DieBieMS_CANID = 10; //CAN ID of DieBieMS. Default is 10.

void setup() {

/** Setup Serial port to display data */
Serial.begin(115200);

/** Setup UART port (Serial1 on Atmega32u4) */
Serial1.begin(115200);

while (!Serial) {;}

/** Define which ports to use as UART */
UART.setSerialPort(&Serial1);
}

void loop() {

/** Call the function getDieBieMSValues() to acquire data from DieBieMS */
if ( UART.getDieBieMSValues(DieBieMS_CANID) ) {

Serial.println(UART.DieBieMSdata.soc);

}
else
{
Serial.println("Failed to get DieBieMS data!");
}

delay(50);
}
45 changes: 45 additions & 0 deletions examples/getFWversion/getFWversion.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
Name: getVescValues.ino
Created: 19-08-2018
Author: SolidGeek
Description: This example is made using a Arduino Micro (Atmega32u4) that has a HardwareSerial port (Serial1) seperated from the Serial port.
A Arduino Nano or Uno that only has one Serial port will not be able to display the data returned.
*/

#include <VescUart.h>

/** Initiate VescUart class */
VescUart UART;

void setup() {

/** Setup Serial port to display data */
Serial.begin(115200);

/** Setup UART port (Serial1 on Atmega32u4) */
Serial1.begin(115200);

while (!Serial) {;}

/** Define which ports to use as UART */
UART.setSerialPort(&Serial1);

}

void loop() {

/** Call the function getVescValues() to acquire data from VESC */
if ( UART.getFWversion()) {
Serial.print("FW v");
Serial.print(UART.fw_version.major);
Serial.print(".");
Serial.println(UART.fw_version.minor);

}
else
{
Serial.println("Failed to get data!");
}

delay(100);
}
42 changes: 42 additions & 0 deletions examples/getLocalVescNun/getLocalVescNun.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Name: getVescValues.ino
Created: 19-08-2018
Author: SolidGeek
Description: This example is made using a Arduino Micro (Atmega32u4) that has a HardwareSerial port (Serial1) seperated from the Serial port.
A Arduino Nano or Uno that only has one Serial port will not be able to display the data returned.
*/

#include <VescUart.h>

/** Initiate VescUart class */
VescUart UART;

void setup() {

/** Setup Serial port to display data */
Serial.begin(115200);

/** Setup UART port (Serial1 on Atmega32u4) */
Serial1.begin(115200);

while (!Serial) {;}

/** Define which ports to use as UART */
UART.setSerialPort(&Serial1);
}

void loop() {

/** Call the function getVescValues() to acquire data from VESC */
if ( UART.getLocalVescNun() ) {

Serial.println(UART.data.throttle);

}
else
{
Serial.println("Failed to get data!");
}

delay(100);
}
42 changes: 42 additions & 0 deletions examples/getLocalVescPPM/getLocalVescPPM.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Name: getVescValues.ino
Created: 19-08-2018
Author: SolidGeek
Description: This example is made using a Arduino Micro (Atmega32u4) that has a HardwareSerial port (Serial1) seperated from the Serial port.
A Arduino Nano or Uno that only has one Serial port will not be able to display the data returned.
*/

#include <VescUart.h>

/** Initiate VescUart class */
VescUart UART;

void setup() {

/** Setup Serial port to display data */
Serial.begin(115200);

/** Setup UART port (Serial1 on Atmega32u4) */
Serial1.begin(115200);

while (!Serial) {;}

/** Define which ports to use as UART */
UART.setSerialPort(&Serial1);
}

void loop() {

/** Call the function getVescValues() to acquire data from VESC */
if ( UART.getLocalVescPPM() ) {

Serial.println(UART.data.throttle);

}
else
{
Serial.println("Failed to get data!");
}

delay(100);
}
43 changes: 43 additions & 0 deletions examples/getMasterVescNun/getMasterVescNun.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
Name: getVescValues.ino
Created: 19-08-2018
Author: SolidGeek
Description: This example is made using a Arduino Micro (Atmega32u4) that has a HardwareSerial port (Serial1) seperated from the Serial port.
A Arduino Nano or Uno that only has one Serial port will not be able to display the data returned.
*/

#include <VescUart.h>

/** Initiate VescUart class */
VescUart UART;
uint8_t masterVescCANID = 0;

void setup() {

/** Setup Serial port to display data */
Serial.begin(115200);

/** Setup UART port (Serial1 on Atmega32u4) */
Serial1.begin(115200);

while (!Serial) {;}

/** Define which ports to use as UART */
UART.setSerialPort(&Serial1);
}

void loop() {

/** Call the function getVescValues() to acquire data from VESC */
if ( UART.getMasterVescNun(masterVescCANID) ) {

Serial.println(UART.data.throttle);

}
else
{
Serial.println("Failed to get data!");
}

delay(100);
}
43 changes: 43 additions & 0 deletions examples/getMasterVescPPM/getMasterVescPPM.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
Name: getVescValues.ino
Created: 19-08-2018
Author: SolidGeek
Description: This example is made using a Arduino Micro (Atmega32u4) that has a HardwareSerial port (Serial1) seperated from the Serial port.
A Arduino Nano or Uno that only has one Serial port will not be able to display the data returned.
*/

#include <VescUart.h>

/** Initiate VescUart class */
VescUart UART;
uint8_t masterVescCANID = 0;

void setup() {

/** Setup Serial port to display data */
Serial.begin(115200);

/** Setup UART port (Serial1 on Atmega32u4) */
Serial1.begin(115200);

while (!Serial) {;}

/** Define which ports to use as UART */
UART.setSerialPort(&Serial1);
}

void loop() {

/** Call the function getVescValues() to acquire data from VESC */
if ( UART.getMasterVescPPM(masterVescCANID) ) {

Serial.println(UART.data.throttle);

}
else
{
Serial.println("Failed to get data!");
}

delay(100);
}
9 changes: 8 additions & 1 deletion keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,11 @@ printVescValues KEYWORD2
setCurrent KEYWORD2
setBrakeCurrent KEYWORD2
setRPM KEYWORD2
setDuty KEYWORD2
setDuty KEYWORD2
getLocalVescPPM KEYWORD2
getMasterVescPPM KEYWORD2
getLocalVescNun KEYWORD2
getMasterVescNun KEYWORD2
getFWversion KEYWORD2
getDieBieMSValues KEYWORD2
getDieBieMSCellsVoltage KEYWORD2
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name=VescUart
version=1.0.0
author=SolidGeek
maintainer=SolidGeek
maintainer=Pimousse
sentence=Library offering UART communication for VESC
paragraph=VESC UART library
category=Device Control
Expand Down
Loading