BrandonM via Pololu Forum schreef op 03-03-2021 22:05:
| BrandonM Pololu Employee
March 3 |
Hello, rolfmeesters.
Can you post more details about what you are trying in your NodeMCU setup with serial communication? For example, what is the alternative device number on the Tic set to, and could you post the code your are using to read it?
Brandon
Visit Topic or reply to this email to respond.
To unsubscribe from these emails, click here.
hi Brandon,
i’m doing SerialPositionControl on a number of steppers, wireless with NodeMCU’s.
reading the alternative Tic number makes it possible to use 1 sketch for all Node’s.
with I2C it has worked.
with Serial until now not.
attached is the test/demonstration sketch used for Arduino and NodeMCU.
/*
* test to read the alt_dev_nr from a Tic with serial connection
* with Arduino Uno Wifi Rev2 or NodeMCU 1.0 (ESP-12E module)
* the Tic used is set to alternative number 15
*/
#define this_sketch "test_Ticnr"
#include <ESP8266WiFi.h>
#include <Wire.h>
#include <Tic.h>
//uncomment next line for Arduino
#define Node
#ifdef Node
#define ticSerial Serial
#define meld Serial1
#else
#define ticSerial Serial1
#define meld Serial
#endif
//uncomment next line for single Tic
#define array
#ifdef array
TicSerial tic[] = {
TicSerial(ticSerial, 14),
TicSerial(ticSerial, 15),
TicSerial(ticSerial, 16),
TicSerial(ticSerial, 17),
TicSerial(ticSerial, 18),
TicSerial(ticSerial, 19),
TicSerial(ticSerial, 20),
TicSerial(ticSerial, 21),
TicSerial(ticSerial, 22),
TicSerial(ticSerial, 23),
TicSerial(ticSerial, 24),
TicSerial(ticSerial, 25),
TicSerial(ticSerial, 26),
};
#else
TicSerial tic(ticSerial);
#endif
void get_tic_number(){
uint8_t alt_offset = 0x6A;
uint8_t alt_length = 1;
uint8_t alt_dev_nr;
#ifdef array
tic[0].getSetting( alt_offset, alt_length, &alt_dev_nr);
#else
tic.getSetting( alt_offset, alt_length, &alt_dev_nr);
#endif
meld.println(alt_dev_nr);
meld.println((alt_dev_nr & 127) - 14);
}
void setup() {
ticSerial.begin(57600);
#ifdef Node
ticSerial.swap();
delay(2000);
#endif
// tic[0].exitSafeStart();//does not make a difference
delay(20);
meld.begin(57600);
meld.println(this_sketch);
get_tic_number();
}
void loop() {}
test_Ticnr.ino (1.51 KB)