Another thing to consider is the BAUD rate. The default BAUD rate for the I7017 is 9600.
At 9600 each character requires approximately 1ms to transmit/receive. For your example the, command sent to the I7017 is 4 characters in length, this will require about 4ms to transmit the command.
The response for the #AA command is quite long, this is what it looks like:
">+05.123+04.153+07.234-02.356+10.000-05.133+02.345+08.234" and is followed by an ASCII CR.
The response is 58 characters in length. This will require about 58ms to receive.
The command and response will take about 62ms. This does not take into account the internal processing time of the I7017.
It is not possible to get an ADC reading every 10ms (0.01SecClk) if your communication takes 62ms.
I have 3 suggestions to speed up stuff:
- Crank up the BAUD rate. If you could run at 115200 BAUD, then your 62 character command/response will take about 5.2ms instead of 62ms.
- You could change the response format to 2's complement HEX. This would shorten the response string for the #AA from 58 characters to 34. The total command/response string length is now 38 characters. At 115200 BAUD this will require about 3.1ms.
- If you are only interested in a single A/D channel, then you could use #AAN format to read only a single A/D channel. The command grows to 5 characters but the response is only 5 characters (2's Compliment HEX) so the total command/ response is 10 characters and this would take about 0.8 ms at 115200. I don't think that this will work for you as you appear to be looking at 3 A/D inputs for your application. It is faster to issue a single #AA command and then to issue 3 #AAN commands.
I have more suggestions, but I'll save them until you've digested, these.
Gary D.