Quicker Digital Writes

​Hello,

​I am trying to get quicker digital writes than with using Indio.digitalWrite, on the order of 410µs.  This is so I can use my Industruino to help with some DALI ballast programming, especially since unlike other Arduino boards, the Industruino board gives me a nice 12V digital output if it feed it with that power input.  However, the Indio.digitalWrites appear to be quite slow when I hook it up to an oscilloscope, on the order of 1.4ms at best.  I'd like to be able to write to the pin directly, but after looking through the libraries, from what I can tell Indio uses this I2C protocol, which is incredibly difficult for me to decipher, so there's no PORTA/PORTB/PORTC registers that I can write to directly like on a normal Arduino board to simply flick a pin to HIGH or LOW.

​Am I incorrect?  Is there some register that on a D21G I can directly flick a digital output pin on?

​Thank you,

~D

dimind
dimind
4
| 2 1 1
Asked on 9/5/18, 9:45 PM
0
vote
2368 Views

@Tom, I can't confirm your answer (as in, I want to, but I don't have the privileges yet), but that's the right approach.  Like you suggested, I threw the following in my code to increase the clock speed:

Wire.setClock(400000);

And it just barely is able to satisfy the DALI requirements at a 12V input signal.

 

Thanks!

dimind
dimind
4
| 2 1 1
Answered on 9/11/18, 4:58 PM
0
vote

Hi, indeed the digital channels are controlled over an I2C expander, with the advantage of full isolation. As mentioned in the Indio library the chip is a PCA9555, and you can check its datasheet for the precise protocol. I don't think the Indio code can be much optimised. What you could try is to increase the I2C clock speed; the default seems to be 100kHz but the chip supports up to 400kHz so you could test this by changing the speed in your version of the Industruino Wire library https://github.com/Industruino/IndustruinoSAMD/blob/master/libraries/Wire/Wire.h  line 85

I don't think it will give you 4x higher speed but maybe you will see an improvement; please let us know.

I have not tested this so i don't know if it affects the operation of the analog channels.

Tom
Tom
5675
| 1 1 3
Answered on 9/11/18, 12:23 AM
0
vote

Your answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

Ask a Question

Keep Informed

About This Forum

This community is for professionals and enthusiasts of our products and services.

Read Guidelines

Question tools

46 follower(s)

Stats

Asked: 9/5/18, 9:45 PM
Seen: 2368 times
Last updated: 9/11/18, 8:23 PM