Just to be clear. I do have both(either) the master or the slave running on RX1/TX1 on a T3.2 with the ModbusRtu file from BEN's post....same setup with the ModbusRtu.h (one from your link) did not respond to a known good Master with no other changes on the ABS4988T board on same TX1/RX1 setup. This is the single port slave test code used (plagiarized heavily from Ben's example):
Code:
/**
* Modbus slave example 1:
* The purpose of this example is to link a data array
* from the Arduino to an external device.
*
* Recommended Modbus Master: QModbus
* http://qmodbus.sourceforge.net/
*/
#include <ModbusRtu.h>
// data array for modbus network sharing
uint16_t au16data[16] = {
3, 1415, 9265, 4, 2, 7182, 28182, 8, 0, 0, 0, 0, 0, 0, 1, 65535 };
/**
* Modbus object declaration
* u8id : node id = 0 for master, = 1..247 for slave
* u8serno : serial port (use 0 for Serial)
* u8txenpin : 0 for RS-232 and USB-FTDI
* or any pin number > 1 for RS-485
*/
Modbus slave(1, Serial1, 23); // this is slave @1 serial, port 1, dere at do23/A9 teensy 3.2
elapsedMillis sinceRead = 0;
elapsedMillis ledOffTime = 0;
uint8_t ledState = 0;
uint8_t address = 0;
void setup() {
//
pinMode( OUTPUT, 23);
digitalWrite(23, LOW);
slave.begin( 9600, SERIAL_8N2); // or try baud-rate at 38400
//slave.begin( 19200, SERIAL_8E1 ); // 19200 baud, 8-bits, even, 1-bit stop
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
//Serial.begin(9600);
}
void loop() {
slave.poll( au16data, 16 );
//Serial.print(au16data[4]);
if (sinceRead > 100) {
sinceRead -= 100;
// slaveData[address] = analogRead(A0);
// address++;
// if (address > 15) address = 0;
ledFlash (1);
}
if (Serial1.available()>=1) ledFlash(100);
if (ledOffTime > 1000) {
ledOffTime = 1000;
digitalWrite(LED_BUILTIN, LOW);
ledState = 0;
}
}
void ledFlash(uint32_t duration) {
digitalWrite(LED_BUILTIN, HIGH);
if (ledState == 0 && ledOffTime >= duration) {
ledOffTime -= duration;
}
ledState = 1;
return;
}
That particular Board is currently using all other pins 2-13 for stepper control lines. but I could just pop one of the allegros out for the test.
I could however use a different carrier board and run TWO RTU masters (one on Serial1 and the other on Serial4) on a T3.6?? THat sounds like an adventure HAR.
On this board (TELEZ)
https://forum.pjrc.com/attachment.ph...5&d=1481908735
or would it be OK to try SoftwareSerial on pins 20/21/22 as that board (the ABS4988T) has strap holes in it for general utility.
PS: Just for my notes and some other people I am working with:
Anyway I have a group of friends working with me. We will run TTL (3.3v) point to point Modbus RTU slave on the T3.2 to an esp32 or esp8266 acting as a Modbus Master for a cloud link remote operator interface. The ESP will also have a local touchscreen (on the ESP) and wifi cloud linking SW to provide secure remote access via cell phone. This will leave the TEENSY practically full bandwidth for stepper/feedback control. With the esp handling graphics and remote requests.
On TELEZ we will run Modbus master rtu on the T3.6 TX1/RX1 port and another type of protocol as a master on TX4/RX4 and also run a Modbus TCP server on a Wiznet 820i CS0/MOSI0/MISO0/SCK0 (on 10,11,12,13). These are already tested on the TELEZ Board. With only the TX4RX4 left to implement. The Raspberry is the local headless IDE (linux). I don't plan on an ESP for the TELEZ board for now unless the linux box proves to cumbersome for remote USER access.
All the best.