-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
basic speed control is working for both motors
- Loading branch information
Showing
4 changed files
with
113 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,28 @@ | ||
#include <Arduino.h> | ||
#include <TMC7300IC.h> | ||
#include <TMC7300.h> | ||
|
||
/* | ||
* https://github.com/joshua-8/TMC7300 | ||
*/ | ||
|
||
const byte ENpin = A1; // EN pin of driver, pulling it low until setup is complete prevents a short twitch on start | ||
TMC7300IC driver = TMC7300IC(5, 0, 10000); // uartPin, chipAddress, baudrate | ||
|
||
TMC7300IC a = TMC7300IC(); | ||
void setup() | ||
{ | ||
pinMode(ENpin, OUTPUT); | ||
digitalWrite(ENpin, LOW); | ||
driver.begin(); | ||
digitalWrite(ENpin, HIGH); | ||
} | ||
void loop() | ||
{ | ||
} | ||
driver.writeField(TMC7300_PWM_A, -230); | ||
delay(1000); | ||
driver.writeField(TMC7300_PWM_B, 150); | ||
delay(1000); | ||
driver.writeField(TMC7300_PWM_A, 250); | ||
delay(1000); | ||
driver.writeField(TMC7300_PWM_B, -230); | ||
delay(1000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef TMCSERIAL_H | ||
#define TMCSERIAL_H | ||
#include <Arduino.h> | ||
|
||
#define SYNC_BYTE 0x55 | ||
#define WRITE_BIT 0x80 | ||
|
||
// from https://github.com/bread-wolf/TMCSerial/blob/cb87877ab4f3c39ed7a5b1ec99cf73eb0f4d5a6c/TMCSerial.cpp#L181C1-L206C2 | ||
uint8_t calcCRC(uint8_t data[], uint8_t dataLength) | ||
{ | ||
uint8_t crc, currentByte; | ||
|
||
/* Initialize crc at 0 */ | ||
crc = 0; | ||
for (uint8_t j = 0; j < dataLength; j++) { | ||
currentByte = data[j]; | ||
for (uint8_t k = 0; k < 8; k++) { | ||
if ((crc >> 7) ^ (currentByte & 0x01)) { | ||
/* Use 0b100000111 as polynomial */ | ||
crc = (crc << 1) ^ 0x07; | ||
} else { | ||
crc = (crc << 1); | ||
} | ||
currentByte >>= 1; | ||
} | ||
} | ||
return crc; | ||
} | ||
#endif // TMCSERIAL_H |