Hi Brandon!
Sorry for the long delay. I was trying to troubleshoot the issue and complete my project before the Thanksgiving.
In the process I figure out that the issue was not like I first reported. Although the first two boards burned when I pressed reset, I had a couple of apparently random burns, including from the L6410. I included pictures of the diode and the burned chip.
So I decided to go back to basics and connected just one AutoDriver to an Artemis ATP board or an Arduino Mega and wrote some code to print the contents of the the STATUS register while moving the motor.]I also runned the I also runned the sparkfunGetSetParamTest.ino from library examples.
The results suggest me that may be some issue with the artemis SPI, but I couldn’t figure out exactly what. In one artemis board (the one that I was using in the prototype and burned the drivers) the register bits seems to be right shifted by 1 and in the other artemis board values are mostly wrong and the motor doesn’t run at all.
Regretfully I will have to switch over to an arduino mega for complete my project, although I had high hopes for the artemis board. Hopefully this issue is resolved in the future.
Arduino IDE version: 1.8.1
Sparkfun Apollo3 boards version 1.2.0
OS: linux mint 19.2 Cinnamon
#include "Arduino.h"
#include "SPI.h"
#include "SparkFunAutoDriver.h"
const int SERIAL_SPEED = 9600;
//AutodDriver configuration
const byte AD_RST_PIN = 48; //28 on Artemis and 48 on arduino mega
const byte AD_CS_PIN = 49; //13 on Artemis and 49 on arduino mega
const int AD_MAXIMUM_SPEED = 1500;
const int AD_MINIMUM_SPEED = 100;
const int AD_ACCEL_RATE = 100;
const int AD_DECEL_RATE = 100;
const int STEPS_PER_REV = 200;
AutoDriver driver(0, AD_CS_PIN, AD_RST_PIN);
unsigned int statusRegister;
void setup() {
Serial.begin(SERIAL_SPEED); //initialize Serial
// ###### AUTODRIVER CONFIGURATION ######
// INITIALIZING PINS
pinMode(MOSI, OUTPUT); // 51=MOSI on arduino mega
pinMode(MISO, INPUT); // 50=MISO on arduino mega pinMode(SCK, OUTPUT); //52 on arduino mega
pinMode(SCK, OUTPUT); // 52=SCK on arduino mega
pinMode(AD_CS_PIN, OUTPUT);
pinMode(AD_RST_PIN, OUTPUT);
digitalWrite(AD_CS_PIN, HIGH);
digitalWrite(AD_RST_PIN, LOW); // This low/high is a reset of the L6470 chip on the
digitalWrite(AD_RST_PIN, HIGH); // Autodriver board.
SPI.begin();
SPI.setDataMode(SPI_MODE3);
//driver.resetDev();
driver.SPIPortConnect(&SPI); // Before doing anything else, we need to tell the object which SPI port to use.
// Some devices may have more than one
//Serial.println("Communication test: ");
//Serial.println(driver.getStatus(), HEX);
driver.configSyncPin(BUSY_PIN, 0); // BUSY pin low during operations; second paramter ignored.
driver.configStepMode(STEP_FS_128); // 128 microsteps per step
driver.setMaxSpeed(10000); // 10000 steps/s max
driver.setFullSpeed(200); // microstep below 10000 steps/s
driver.setAcc(500); // accelerate at 10000 steps/s²
driver.setDec(500);
driver.setSlewRate(SR_530V_us); // Upping the edge speed increases torque.
driver.setOCThreshold(OC_750mA); // OC threshold 2250mA
driver.setOscMode(INT_16MHZ_OSCOUT_16MHZ); // ATTENTION HERE: for driver (board zero), we want 16MHz internal osc, 16MHz out.
driver.setOCShutdown(OC_SD_DISABLE); // ATTENTION: on the a
driver.setVoltageComp(VS_COMP_DISABLE); // compensate for motor V
driver.setLoSpdOpt(true);
driver.setPWMFreq(PWM_DIV_2, PWM_MUL_2); // 31.25kHz PWM freq
driver.setSwitchMode(SW_USER); // Switch is not hard stop
driver.setAccKVAL(128); // We'll tinker with these later, if needed.
driver.setDecKVAL(128);
driver.setRunKVAL(128);
driver.setHoldKVAL(32); // This controls the holding current; keep it low.
// ###### END OF AUTODRIVER CONFIGURATION ######
delay(1000);
Serial.println("Communication test: ");
Serial.println(driver.getStatus(), HEX);
Serial.println ("SETUP FINISHED, PRESS ANY KEY TO CONTINUE");
while (!Serial.available()){}
Serial.read();
}
void loop() {
Serial.println ("#### Starting test ####");
Serial.println ("Moving motor connected to board 0 forward at 500 steps/sec ");
Serial.println ("Showing status register, binary");
driver.run (FWD, 500);
Serial.print ("FWD, Accellerating --> ");
printBits (driver.getStatus());
delay(1000);
Serial.print ("FWD, Constant speed --> ");
printBits (driver.getStatus());
delay (2000);
driver.softStop();
Serial.print ("Soft stp, decellerating --> ");
printBits (driver.getStatus());
delay (1000);
Serial.print ("Stopped --> ");
printBits(driver.getStatus());
driver.hardHiZ();
Serial.print ("High impedance --> ");
printBits (driver.getStatus());
Serial.println ();
Serial.println ("Moving motor connected to board 0 reverse at 500 steps/sec");
Serial.println ("Showing status register, binary");
driver.run (REV, 500);
Serial.print ("REV, Accellerating --> ");
printBits (driver.getStatus());
delay(1000);
Serial.print ("REV, Constant speed --> ");
printBits (driver.getStatus());
delay (2000);
driver.softStop();
Serial.print ("Soft stp, decellerating --> ");
printBits (driver.getStatus());
delay (1000);
Serial.print ("Stopped --> ");
printBits(driver.getStatus());
driver.hardHiZ();
Serial.print ("High impedance --> ");
printBits (driver.getStatus());
Serial.println ();
Serial.println("Test finished");
while(1){}
}
void printBits(unsigned int n) {
byte numBits = 16; // 2^numBits must be big enough to include the number n
char b;
char c = ' '; // delimiter character
for (byte i = 0; i < numBits; i++) {
// shift 1 and mask to identify each bit value
b = (n & (1 << (numBits - 1 - i))) > 0 ? '1' : '0'; // slightly faster to print chars than ints (saves conversion)
Serial.print(b);
if (i < (numBits - 1) && ((numBits-i - 1) % 4 == 0 )) Serial.print(c); // print a separator at every 4 bits
}
Serial.println();
}
Terminal output: test with artemis board #1: the output seems to be left shifted by 1. I have no clue why…
11:13:07.379 -> Communication test
11:13:07.445 -> A000
11:13:07.445 -> SETUP FINISHED, PRESS ANY KEY TO CONTINUE
11:15:17.735 -> #### Starting test ####
11:15:17.735 -> Moving motor connected to board 0 forward at 500 steps/sec
11:15:17.834 -> Showing status register, binary
11:15:17.868 -> FWD, Accellerating --> 0001 1100 0110 0000
11:15:18.831 -> FWD, Constant speed --> 0001 1100 1110 0100
11:15:20.856 -> Soft stp, decellerating --> 1111 1100 1010 0000
11:15:21.852 -> Stopped --> 0001 1100 0010 0100
11:15:21.885 -> High impedance --> 1111 1100 0010 0110
11:15:21.951 ->
11:15:21.951 -> Moving motor connected to board 0 reverse at 500 steps/sec
11:15:22.017 -> Showing status register, binary
11:15:22.050 -> REV, Accellerating --> 0001 1100 0100 0000
11:15:23.047 -> REV, Constant speed --> 0001 1100 1100 0100
11:15:25.038 -> Soft stp, decellerating --> 1111 1100 1000 0000
11:15:26.034 -> Stopped --> 0001 1100 0000 0100
11:15:26.100 -> High impedance --> 1111 1100 0000 0110
11:15:26.133 ->
11:15:26.166 -> Test finished
Terminal output: test with arduino mega: things look ok.
11:13:07.379 -> Communication test:
11:13:07.445 -> 7C03
11:13:07.445 -> SETUP FINISHED, PRESS ANY KEY TO CONTINUE
11:15:17.735 -> #### Starting test ####
11:15:17.735 -> Moving motor connected to board 0 forward at 500 steps/sec
11:15:17.834 -> Showing status register, binary
11:15:17.868 -> FWD, Accellerating --> 0011 1110 0011 0000
11:15:18.831 -> FWD, Constant speed --> 0001 1110 0111 0010
11:15:20.856 -> Soft stp, decellerating --> 0111 1110 0101 0000
11:15:21.852 -> Stopped --> 0001 1110 0001 0010
11:15:21.885 -> High impedance --> 0111 1110 0001 0011
11:15:21.951 ->
11:15:21.951 -> Moving motor connected to board 0 reverse at 500 steps/sec
11:15:22.017 -> Showing status register, binary
11:15:22.050 -> REV, Accellerating --> 0101 1110 0010 0000
11:15:23.047 -> REV, Constant speed --> 0001 1110 0110 0010
11:15:25.038 -> Soft stp, decellerating --> 0111 1110 0100 0000
11:15:26.034 -> Stopped --> 0001 1110 0000 0010
11:15:26.100 -> High impedance --> 0111 1110 0000 0011
11:15:26.133 ->
11:15:26.166 -> Test finished
Terminal output: test with Artemis ATP #2: Seems that the comm is also not working properly
11:39:37.251 -> Communication test:
11:39:37.285 -> 2000
11:39:37.285 -> SETUP FINISHED, PRESS ANY KEY TO CONTINUE
11:39:43.158 -> #### Starting test ####
11:39:43.158 -> Moving motor connected to board 0 forward at 500 steps/sec
11:39:43.257 -> Showing status register, binary
11:39:43.290 -> REV, Accellerating --> 1010 0000 0000 0000
11:39:44.186 -> REV, Constant speed --> 1010 0000 0000 0000
11:39:46.177 -> Soft stp, decellerating --> 1010 0000 0000 0000
11:39:47.205 -> Stopped --> 1010 0000 0000 0000
11:39:47.238 -> High impedance --> 1010 0000 0000 0000
11:39:47.305 ->
11:39:47.305 -> Moving motor connected to board 0 reverse at 500 steps/sec
11:39:47.371 -> Showing status register, binary
11:39:47.404 -> FWD, Accellerating --> 1010 0000 0000 0000
11:39:48.200 -> FWD, Constant speed --> 1010 0000 0000 0000
11:39:50.224 -> Soft stp, decellerating --> 1010 0000 0000 0000
11:39:51.220 -> Stopped --> 1010 0000 0000 0000
11:39:51.253 -> High impedance --> 1010 0000 0000 0000
11:39:51.319 ->
11:39:51.319 -> Test finished
SparkfunGetSetParamTest from examples with the arduino and the artemis #2
Arduino mega terminal output:
16:48:40.422 -> Config reg value: 2E88
16:48:40.456 -> Status reg value: 7C03
16:48:40.489 -> LoSpdOpt 0
16:48:40.489 -> LoSpdOpt passed r/w test!
16:48:40.522 -> MinSpeed 0.0000000000
16:48:40.555 -> MinSpeed passed r/w test!
16:48:40.555 -> StepMode 7
16:48:40.589 -> StepMode passed r/w test!
16:48:40.622 -> MaxSpeed 991.8212890625
16:48:40.622 -> MaxSpeed passed r/w test!
16:48:40.655 -> FullSpeed 602.7221679687
16:48:40.688 -> FullSpeed passed r/w test!
16:48:40.721 -> Acc 1004.0891113281
16:48:40.754 -> Acc passed r/w test!
16:48:40.754 -> Dec 1004.0891113281
16:48:40.788 -> Dec passed r/w test!
16:48:40.821 -> OCThreshold 8
16:48:40.821 -> OCThreshold passed r/w test!
16:48:40.854 -> PWMFreqDivisor 8192
16:48:40.887 -> PWMFreqDivisor passed r/w test!
16:48:40.920 -> PWMFreqMultiplier 3072
16:48:40.920 -> PWMFreqMultiplier passed r/w test!
16:48:40.987 -> SlewRate 512
16:48:40.987 -> SlewRate passed r/w test!
16:48:41.020 -> OCShutdown 128
16:48:41.020 -> OCShutdown passed r/w test!
16:48:41.053 -> VoltageComp 0
16:48:41.086 -> VoltageComp passed r/w test!
16:48:41.120 -> SwitchMode 0
16:48:41.120 -> SwitchMode passed r/w test!
16:48:41.153 -> OscMode 8
16:48:41.153 -> OscMode passed r/w test!
16:48:41.186 -> AccK 41
16:48:41.219 -> AccK passed r/w test!
16:48:41.219 -> DecK 41
16:48:41.252 -> DecK passed r/w test!
16:48:41.252 -> RunK 41
16:48:41.252 -> RunK passed r/w test!
16:48:41.285 -> HoldK 41
16:48:41.318 -> HoldK passed r/w test!
16:48:41.318 -> Passed? 1
Artemis board #2 terminal output:
2.3 Results from SparkfunGetSetParamTest
14:06:50.160 -> Config reg value: 5C10
14:06:50.160 -> Status reg value: F806
14:06:50.193 -> LoSpdOpt 0
14:06:50.193 -> !!! LoSpdOpt failed
14:06:50.226 -> Expected 1
14:06:50.226 -> Got 0
14:06:50.259 -> MinSpeed 0.0000000000
14:06:50.259 -> !!! MinSpeed failed
14:06:50.292 -> Expected 23.8418788910
14:06:50.359 -> Got 47.5999984741
14:06:50.359 -> StepMode 6
14:06:50.392 -> StepMode passed r/w test!
14:06:50.425 -> MaxSpeed 1983.6425781250
14:06:50.425 -> !!! MaxSpeed failed
14:06:50.458 -> Expected 152.5878906250
14:06:50.492 -> Got 305.1757812500
14:06:50.492 -> FullSpeed 1197.8149414063
14:06:50.525 -> !!! FullSpeed failed
14:06:50.558 -> Expected 160.2172851562
14:06:50.591 -> Got 312.8051757813
14:06:50.591 -> Acc 145.5201568604
14:06:50.624 -> !!! Acc failed
14:06:50.657 -> Expected 72.7600784302
14:06:50.657 -> Got 145.5201568604
14:06:50.691 -> Dec 145.5201568604
14:06:50.724 -> !!! Dec failed
14:06:50.724 -> Expected 72.7600784302
14:06:50.757 -> Got 145.5201568604
14:06:50.757 -> OCThreshold 0
14:06:50.790 -> !!! OCThreshold failed
14:06:50.823 -> Expected 1
14:06:50.823 -> Got 2
14:06:50.823 -> PWMFreqDivisor 16384
14:06:50.857 -> !!! PWMFreqDivisor failed
14:06:50.890 -> Expected 0
14:06:50.890 -> Got 8192
14:06:50.890 -> PWMFreqMultiplier 7168
14:06:50.923 -> !!! PWMFreqMultiplier failed
14:06:50.956 -> Expected 3072
14:06:50.989 -> Got 6144
14:06:50.989 -> SlewRate 0
14:06:50.989 -> !!! SlewRate failed
14:06:51.022 -> Expected 512
14:06:51.022 -> Got 0
14:06:51.056 -> OCShutdown 0
14:06:51.056 -> !!! OCShutdown failed
14:06:51.089 -> Expected 128
14:06:51.089 -> Got 0
14:06:51.089 -> VoltageComp 0
14:06:51.122 -> !!! VoltageComp failed
14:06:51.155 -> Expected 32
14:06:51.155 -> Got 0
14:06:51.155 -> SwitchMode 0
14:06:51.188 -> SwitchMode passed r/w test!
14:06:51.222 -> OscMode 0
14:06:51.222 -> !!! OscMode failed
14:06:51.255 -> Expected 8
14:06:51.255 -> Got 0
14:06:51.255 -> AccK 82
14:06:51.255 -> AccK passed r/w test!
14:06:51.288 -> DecK 82
14:06:51.288 -> DecK passed r/w test!
14:06:51.321 -> RunK 82
14:06:51.321 -> RunK passed r/w test!
14:06:51.354 -> HoldK 82
14:06:51.354 -> HoldK passed r/w test!
14:06:51.387 -> Passed? 0