Question from the Customer:
We are using the Aardvark I2C/SPI Host Adapter to program SPI devices. We successfully completed the first two stages of verifying the software. However, we are having issues with the third stage – automating the process. There was no activity, which was verified on an oscilloscope.
Stage 1: We executed the following commands with the Control Center Serial Software:07 03 (initial)
08 02 (HIGH set)
0B 01 (PWM set)
15 FF (DUTY set)
Both the GUI and the oscilloscope showed it was functioning correctly.
Stage 2: To automate that process, we wrote a script with Aardvark Software API for continuous execution. At this stage, we only included the Initial and HIGH set commands, which worked correctly:<adapter>
<configure i2c="1" spi="1" gpio="0" tpower="1" pullups="0"/>
<spi_bitrate khz="125"/>
<spi_config polarity="rising/falling" phase="setup/sample" bitorder="msb" ss="active_low"/>
<spi_write ss="0" count="2" radix="16">07 03</spi_write>
<spi_write ss="0" count="2" radix="16">08 02</spi_write>
<spi_write ss="0" count=“2” radix="16">0B 01</spi_write>
<spi_write ss="0" count=“2” radix="16">15 FF</spi_write>
</adapter>
Stage 3: We added the last two commands for PWM set and DUTY set:<adapter>
<configure i2c="1" spi="1" gpio="0" tpower="1" pullups="0"/>
<spi_bitrate khz="125"/>
<spi_config polarity="rising/falling" phase="setup/sample" bitorder="msb" ss="active_low"/>
<spi_write ss="0" count="2" radix="16">07 03</spi_write>
<spi_write ss="0" count="2" radix="16">08 02</spi_write>
<spi_write ss="0" count=“2” radix="16">0B 01</spi_write>
<spi_write ss="0" count=“2” radix="16">15 FF</spi_write>
</adapter>
This is where we saw no activity on the oscilloscope. Can you explain what causes such problems? What changes can we make to automate this entire process?
Response from Technical Support:Thank you for your questions! There are latencies that could affect the performance of your script. For your project, we have two recommendations:
There are factors of speed and latency that can affect a script’s performance:
To compensate for the latencies and timing requirements, we recommend adding sleep before and after the last two commands as shown below:
<adapter>
<configure i2c="1" spi="1" gpio="0" tpower="1" pullups="0"/>
<spi_bitrate khz="125"/>
<spi_config polarity="rising/falling" phase="setup/sample" bitorder="msb" ss="active_low"/>
<spi_write ss="0" count="2" radix="16">07 03</spi_write>
<spi_write ss="0" count="2" radix="16">08 02</spi_write>
<sleep ms="10"/>
<spi_write ss="0" count=“2” radix="16">0B 01</spi_write></P
<spi_write ss="0" count=“2” radix="16">15 FF</spi_write>
<sleep ms="10"/>
</adapter>
Please note, “10 ms” is an example. As previously stated, refer to the device datasheet to see how much delay is needed.
For your project, we recommend using the Promira Serial Platform. This tool uses Ethernet, and Ethernet over USB, which provides a faster interface with this host computer. The Promira platform also operates at higher speeds than the Aardvark adapter.
For Promira Software API I2C/SPI Active functions, there is also the advantage of queuing and shifting multiple commands to the target device at once. For information about queuing, please refer Section 5.5.3 Queuing of the Promira Serial Platform I2C/SPI Active User Manual.
We hope this answers your questions. Additional resources that you may find helpful include the following:
If you want more information, feel free to contact us with your questions, or request a demo that applies to your application.