I find that the biggest problem with getting this project to work is configuring the UART to send and receive data via the RS485 converter. And you always seem to end up fiddling with things, bend double, outside on the ground with the HotTub taken apart.
But RS485 is a half duplex interface - the transmit and receive use the same pins.
So you receive whatever you send. This means you can fool the software into thinking you are connected to the Hottub just by sending the right message.
So I added a little test feature that sends an ID Command packet with ID = 0 every 3 seconds.
If everything is working, the software will respond with an ID ACK message.
This all runs on the bench inside where you have your logic analyser and oscilloscope.
So if you can get the ID ACK working on the bench, when you get in outside in the Hottub, the only thing left that can be wrong, is the RS485 wires might need swapping around.
My test function looks like this:
void spa_emulate() {
Q_out.push(0xFE);
Q_out.push(0xBF);
Q_out.push(0x02);
Q_out.push(0x00);
rs485_send(true);
}
Call it every 3 seconds in the loop function (Don't forget to remove it when you connect to the Hottub)
I find that the biggest problem with getting this project to work is configuring the UART to send and receive data via the RS485 converter. And you always seem to end up fiddling with things, bend double, outside on the ground with the HotTub taken apart. But RS485 is a half duplex interface - the transmit and receive use the same pins. So you receive whatever you send. This means you can fool the software into thinking you are connected to the Hottub just by sending the right message. So I added a little test feature that sends an ID Command packet with ID = 0 every 3 seconds. If everything is working, the software will respond with an ID ACK message. This all runs on the bench inside where you have your logic analyser and oscilloscope. So if you can get the ID ACK working on the bench, when you get in outside in the Hottub, the only thing left that can be wrong, is the RS485 wires might need swapping around.
My test function looks like this: void spa_emulate() { Q_out.push(0xFE); Q_out.push(0xBF); Q_out.push(0x02); Q_out.push(0x00);
rs485_send(true); }
Call it every 3 seconds in the loop function (Don't forget to remove it when you connect to the Hottub)