Skip to content

Commit ba3e608

Browse files
committed
Sangaboard v0.3 support
Sangaboard v0.3 controller uses different pins to control the motors, this adds a define to select the version. The microcontroller on this board does not reset on new serial connections, so a version command was addded and openflexure_stage will query the firmware version. This means the new openflexure_stage is incompatible with older firmware.
1 parent a1781ee commit ba3e608

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

arduino_code/openflexure_nano_motor_controller/openflexure_nano_motor_controller.ino

+20-6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
//#define ADAFRUIT_TSL2591
2121
//#define ADAFRUIT_ADS1115
2222

23+
//#define SANGABOARDv2
24+
#define SANGABOARDv3
25+
2326
#ifdef ADAFRUIT_TSL2591
2427
#include <Wire.h>
2528
#include <Adafruit_Sensor.h>
@@ -99,12 +102,18 @@ int command_prefix(String command, const char ** prefixes, int n_prefixes){
99102
void setup() {
100103
// initialise serial port
101104
Serial.begin(115200);
102-
105+
while (! Serial )
106+
delay(1);
103107
// get the stepoper objects from the motor shield objects
104-
motors[0] = new Stepper(8, 13, 12, 11, 10);
105-
motors[1] = new Stepper(8, 9, 8, 7, 6);
106-
motors[2] = new Stepper(8, 5, 4, 3, 2);
107-
108+
#if defined(SANGABOARDv2)
109+
motors[0] = new Stepper(8, 13, 12, 11, 10);
110+
motors[1] = new Stepper(8, 9, 8, 7, 6);
111+
motors[2] = new Stepper(8, 5, 4, 3, 2);
112+
#elif defined(SANGABOARDv3)
113+
motors[0] = new Stepper(8, 8, 9, 10, 11);
114+
motors[1] = new Stepper(8, 5, 13, 4, 12);
115+
motors[2] = new Stepper(8, 6, 7, A5, A4);
116+
#endif
108117
EACH_MOTOR{
109118
motors[i]->setSpeed(1*8.0/4096.0); //using Fergus's speed for now, though this is ignored...
110119
steps_remaining[i]=0;
@@ -781,8 +790,12 @@ void loop() {
781790
}
782791
return;
783792
}
784-
785793
#endif //ENDSTOPS
794+
795+
if(command.startsWith("version")){
796+
Serial.println(F(VER_STRING));
797+
return;
798+
}
786799
if(command.startsWith("help")){
787800
Serial.println("");
788801
Serial.println(F(VER_STRING));
@@ -828,6 +841,7 @@ void loop() {
828841
Serial.println(F("max <d> <d> <d> - set maximum positions"));
829842
#endif
830843
Serial.println(F("test_mode <s> - set test_mode <on> <off>"));
844+
Serial.println(F("version - get firmware version string"));
831845
Serial.println("");
832846
Serial.println("Input Key:");
833847
Serial.println(F("<d> - a decimal integer."));

openflexure_stage/stage.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ def __init__(self, *args, **kwargs):
7373
"""
7474
super(OpenFlexureStage, self).__init__(*args, **kwargs)
7575
try:
76-
self.board = self.readline(timeout=1).rstrip()
76+
# Request version from the board
77+
self.board = self.query("version").rstrip()
7778
# The slightly complicated regexp below will match the version string,
7879
# and store the version number in the "groups" of the regexp. The version
7980
# number should be in the format 1.2 and the groups will be "1.2", "1", "2"

0 commit comments

Comments
 (0)