The Meccabrain is somewhat limited although it can be driven from a tablet via Bluetooth. Some of the peripherals are interesting and I'm looking into how they can be used. The published document mentions servos and "Smart LEDs" but the MAX robot also has "Smart motors" and an ultrasonic sensor using the same protocols.I'm also working on a signal sniffer that can read the traffic on one of the lines which will hopefully allow me to work out how an Arduino can make use of these devices. Again, I've got the communications sorted apart from a minor timing issue.
My objective is to use an Arduino to monitor and control the Meccano peripherals. This will allow them to be used in a much wider range of applications than the very limited ones for the kits they are supplied with.
Further testing ...I changed the value of the timer preset to see if that had any effect - the program fails for values of the preset between 0x8A6F and 0x8D9F. I have not tested much outside this range. I have also tried changing to Timer 3 with no effect on the problem.As the program is working with a delay of 12 ms - preset of 0xA23A - I'm moving on with other areas.
The sequence I am using is based on a state transition approach. The first set of states deal with the command transmission. Once the command has been completely sent (I am using the TXC flag to signal this), the system moves on to the receive function, where it looks for a low-high transition on the pin previously used as TX1. When this is detected, the time is grabbed and the INT function changed to look for the next high-low transition. This then allows the pulse width to be calculated and the response bit set or cleared as appropriate.I have got working code for this, and with the 12 ms delay I can manage to decipher the response strings. However, I am still baffled as to why the TXC flag is apparently triggered early if the timeout is within a fairly restricted range of values.
I do not need any assistance with either communication format. I am sure I am not the only one who has wanted to do something similar with an Arduino, but can't find any references to this situation. There is quite possibly a very simple explanation and I am simply trying to find out why the timer setting apparently affects the operation of the UART.
I'm sorry if you feel you have been wasting time on this, but I think I have made it clear in a number of posts that getting the communications going was not the issue.
In the program I have written to transmit commands from the Arduino to a Meccano slave module, I an using Serial1, using the TXD1 function of pin 18. When the 6 bytes of the command have been transmitted, I have to change function of pin 18 so that I can use the INT3 function of pin 18 to detect transitions,