tailieunhanh - Practical Arduino Cool Projects for Open Source Hardware- P38

Practical Arduino Cool Projects for Open Source Hardware- P38: A schematic or circuit diagram is a diagram that describes the interconnections in an electrical or electronic device. In the projects presented in Practical Arduino, we’ve taken the approach of providing both a photograph and/or line drawing of the completed device along with a schematic. While learning to read schematics takes a modest investment of your time, it will prove useful time and time again as you develop your projects. With that in mind, we present a quick how-to in this section | CHAPTER 15 VEHICLE TELEMETRY PLATFORM if millis - lastLogWrite LOG_INTERVAL The blue LED indicating that a sample is being written is illuminated and the position counter for the log buffer is reset. digitalWrite VDIPWRITE_LED HIGH byte position 0 The log entry length and the entry itself are sent to the host for debugging purposes. logEntry Now for the interesting bit. A WRF WRite File command is sent to the VDIP1 with a single argument that tells it the number of bytes of data to follow in the actual message. Because each log entry will have a newline character appended we have to take the current logEntry length and add 1 to it to get the actual message length. Note that before doing this the VDIP1 needs to be initialized and that process is taken care of by a function that we ll see in just a moment. WRF 1 13 BYTE The position counter is used to walk through the log buffer array one character at a time to send it to the VDIP1. However the RTS ready to send pin on the VDIP1 is checked prior to transmission of each character to make sure the VDIP1 input buffer still has free space. If RTS is low inactive it s clear to send the character and increment the position counter. Otherwise it shouts loudly to the host to notify you that the VDIP1 buffer was full. In production you probably wouldn t want the error message being sent to the host but it can be handy when doing development. while position if digitalRead VDIP_RTS_PIN LOW vdipBuffer position position else BUFFER FULL After sending a WRF command to the VDIP1 it will keep accepting data until it has received exactly the number of bytes specified in the WRF argument. The number passed in was one greater than the number of bytes in the buffer so if nothing else was sent the Vinculum chip on the VDIP1 would sit patiently waiting for the next character. If a mistake is made .