Serial1 on IND.I/O
Eventually, I need to be able to use modbus to communicate with another device. I connected everything and it didn't work, so I've been simplifying and simplifying, and I'm down to this:
I am trying to get my IND.I/O to use its Serial1 (RS-485) port. Here is my sketch:
void setup() {
Serial1.begin(9600, SERIAL_8N2);
pinMode(9 /*TxEnablePin*/, OUTPUT);
digitalWrite(9 /*TxEnablePin*/, LOW);
delay(1);
}
void loop() {
digitalWrite(9, HIGH);
Serial1.write(85);
delay(200);
digitalWrite(9, LOW);
delay(200);
}
I put a scope on the A and B RS-485 lines. With this sketch, I see this in the scope: https://imgur.com/SztEalF.png. As far as I can tell, this is basically what the simple modbus master library does (albeit grossly simplified).
It looks like the writes to pin 9 are simply setting the serial output to high or low!? (and the other wire is negative of the main wire.) When I change the delays, the length of time high or low (depending on which delay I change) changes accordingly.
If I change the code to use the Indio library like so:
#include <Indio.h>
void setup() {
Serial1.begin(9600, SERIAL_8N2);
Indio.digitalMode(9 /*TxEnablePin*/, OUTPUT);
Indio.digitalWrite(9 /*TxEnablePin*/, LOW);
delay(1);
}
void loop() {
Indio.digitalWrite(9, HIGH);
Serial1.write(85);
delay(200);
Indio.digitalWrite(9, LOW);
delay(200);
}
I get the following on the scope: https://imgur.com/f3iVsDn.png. So apparently digitalWrite(9, HIGH) is different from Indio.digitalWrite(9, HIGH). That's fine, at least I don't get 400 ms pulses, but I would really like to see my "85" be serialized on the line!
Please let me know what I should do next to try to troubleshoot this issue. Have I missed some configuration? Is there another test I should be running to rule out other problems? Thanks!
Hi, the RS485 is on 'Serial', please have a look at https://github.com/Industruino/documentation/blob/master/indio.md#rs485
'Serial1' is on D10/D5, available on the 14-pin IDC expansion port.
Your answer
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
Keep Informed
About This Forum
This community is for professionals and enthusiasts of our products and services.
Read GuidelinesQuestion tools
Stats
Asked: 7/30/20, 4:11 PM |
Seen: 1538 times |
Last updated: 6/14/21, 4:51 PM |
I have been reading the Indio library and I see how different `India.digitalWrite` is from `digitalWrite`! I'm starting to think I have a bad modbus chip in my IND.I/O? (max485 I think?)