At first, Davina thought that the program may not have been able to handle double-digit numbers, so she spent some time researching the particular function Serial.parseInt() for Arduino. Serial.parseInt(), however, is capable of handling multi-digit numbers, so it was clear that the problem lay elsewhere.
Parm and Davina realized that there must be a simple calculation error when they tried entering 10 mL into the application and found that the program was responding correctly - the pump just remained on for longer than expected. At this point, the Arduino code was multiplying the integer it received from the controller by 637 milliseconds, since previous testing yielded a standard curve with equation y = 0.126x + 0.512 for seconds per mL, which yields 637 milliseconds for 1 mL. Davina made the mistake of multiplying by 637 outright, rather than multiplying by 126 (the "slope") and then adding 512 to the resultant figure. This difference is highlighted below:
On the mechanical side of things, the Arduino and relay were put into the cardboard box, which has been sprayed with chalkboard paint for waterproofing and a uniform black color. The configuration is shown in Figure 1 below.
The first calculation keeps the pump on for about 32 seconds; the second, for about 7.
vs.
On the mechanical side of things, the Arduino and relay were put into the cardboard box, which has been sprayed with chalkboard paint for waterproofing and a uniform black color. The configuration is shown in Figure 1 below.
Figure 1. Arduino and relay system inside electrical component box. All cords run out from the box through holes. |