I have a problem cocerning the timings of the K8055.
I’m using the K8055 to retrieve data from an array of 64 temperature sensors (Hygrosens SEMI833ET). Two multiplexers are used to select and read a specific sensor by selecting a path between an external power source, one of the sensors and the analog input of the K8055, which is used to determine the fall of voltage in the sensor. When the reading of one sensor is completed the next sensor is selected and so forth. To select the sensor, I use a group of three digital out-channels of the K8055 per multiplexer (6 in total). The control program is written in Borland C++.
My problem is that I need to read the sensors fairly frequently. According to the specifications of the K8055, which is the slowest component in my setup, I should be able to perform 25 readings per second (25 WriteAllDigital + 25 ReadAllAnalog commands). This would enable me to read data from the whole array of 64 sensors in less than three seconds, which would be sufficient for my needs.
It seems though that there is a long delay between the setting of the digital outputs and the arrival of the correct analog signal at the K8055’s analog input. Indeed I have to either insert a delay of 270 ms between the WriteAllDigital and the ReadAllAnalog command or perform the ReadAllAnalog command at least 10 times in a row before I receive the signal from the correct sensor.
After exhaustive analysis of the whole setup I think that I can break down the number of possible causes to either the digital outputs or the analog inputs of the K8055. Now my questions are:
[ul]1.) Could it be that the digital outputs take a long time to build up the voltage needed for the multiplexers’ digital inputs (2.4 V)? 2.) Does the ADC take a long time to report the current voltage? 3.) Could it be that the ADC is only triggered when it’s actively read and thus takes a long time to adjust to a change in voltage?[/ul]
Thanks in advance for any helpful comments from this great community!
The 4k7 pull-up resistors are OK. This is not the cause to the problem.
The digital output latency is about 8ms. (USB update rate specified max. 10ms according to the USB standards.)
No. The ADC is running all the time in the main loop of the microcontroller firmware.
The input is sampled all the time and the last value sent to the PC when requested.
The latency time is some ten microseconds from the analog input change to the conversion result. This time is negligible compared to the 10ms USB latency time.
The outputs are open collector NPN transistor outputs. Those go very quickly down. The low voltage is about 0.6V using 4k7 pull-ups.
BTW: The outputs are inverted.
I’ve resortet to a little work-around: I feed the lowest 3 dig outputs back into the lowest 3 dig inputs and, after setting the dig outs using WriteAllDigital, I read back their value from the dig inputs using ReadAllDigital in a loop that repeats until the value from the dig input is equal to the value written into the dig outputs. This loop typically has to repeat 7 or 8 times (and rarely up to 33 times) till the value written into dig out can be read from the dig in.
This work-around solved my issue and I can now read the correct sensor values at an acceptable rate, so apparently, for whatever reason, the fault is indeed at the dig outs.
The loop counter counts max up to 5. (Maybe you have faster PC.)
Every time the waveform from the digital output is similar.
The latency of one instruction is 8 ms. The total time of the execution of those three instructions seems to be 24 ms.
BTW: Use lower value pull up resistors if you connect the digital outputs also (directly without any series resistors) to the digital inputs. The high value is only about 2.7V with the 4k7 pull-up resistors.
Thanks a lot for your efforts, and thanks for the hint about the pull-up resistors. I hadn’t noticed the low voltage before.
In a test running over approximately 72000 readings my loop was repeated 7 times in 23,3% of all cases and 8 times in 76,4%. In rare cases the loop was repeated not at all, or up to 43 times.
There is a difference between your loop and mine though: Your loop stops as soon as at least one of the dig inputs switches to Hi, while my loop waits until it can entirely read the expected bit pattern. This difference however seems marginal, given that all inputs should switch at approximately the same time.
Thanks again for your efforts, I haven’t seen such exemplary custome care in a while!