D21G Interruption in only one channel (Ex. CH1)

Hello,

I am trying to use an interruption for an emegency stop.

I want to detect only the changes in only one channel (example CH1), but following the instruction  https://github.com/Industruino/libraries/blob/master/README.md#interrupts,  the interruption is triggered by any channel change.

How can I configure the code to trigger the intteruption only with one channel and use the rest of channels for other proposals?

Thanks.

Antonio_Per
Antonio_Per
4
| 2 1 1
Asked on 8/22/18, 11:47 AM
0
vote
2040 Views

Hi, indeed the interrupt is triggered by any channel change, unless you mask the channels you do not want to connect to the interrupt. You can do this with the current Indio library as follows:

  Indio.digitalMode(3, INPUT_MASKED); 

This is a new feature, we have not documented it yet but you can check the library source code if you need details.

Alternatively, you could set a flag in the ISR to indicate that the interrupt is triggered, and then in the main loop, when the flag is detected, check if the channel you want to detect (eg. CH1) has changed state or not. Do not call the Indio library within the ISR, that will not work. Obviously you can also poll the CH1 every loop to check its status without using the interrupt, but the above solution with an interrupt will be slightly faster as you won't need to poll CH1 every loop, only when the flag is set.

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

This seems to work well for blocking interrupts from other inputs triggering the interrupt; but when we configure a channel as an output and issue a output write on another channel that seems to interrupt it, does it make sense to add OUTPUT_MASKED if that would work and makes sense? or any suggestions on how to block the interrupt from firing at all except on one channel input and ignoring all other channels regardless of them beingconfigure as inputs or outputs... Thanks, Josh

Josh Nijenhuis
on 1/26/19, 4:26 AM

Just reading through the PCA9555 data sheet and at point 8.4.1 it does say that an output shouldn't cause an interrupt. Waiting your response, hopefully there is an explanation... Thanks, Josh

Josh Nijenhuis
on 1/26/19, 4:44 AM

hi Josh, please note the current INDIO uses PCAL9555A, and the output indeed does not cause an interrupt, please refer to my email

Tom
on 1/28/19, 1:54 AM

Thanks Tom,

I have tested and it is working.
Just to be sure, for the outputs, is it necessary to configure something?

Indio.digitalMode(1, INPUT);           
  Indio.digitalMode(2, INPUT_MASKED);     
  Indio.digitalMode(3, INPUT_MASKED);     
  Indio.digitalMode(4, INPUT_MASKED);    
  Indio.digitalMode(5, INPUT_MASKED);     
  Indio.digitalMode(6, INPUT_MASKED);    

  Indio.digitalMode(7, OUTPUT);          
  Indio.digitalWrite(7, LOW);             
  Indio.digitalMode(8, OUTPUT);         
  Indio.digitalWrite(8, LOW);            

A pin configured as an output can trigger the interruption?
I have modified the status and it is working fine, but I prefer to check any posibility.

Another point, is it still necesary to include the following lines when the interruptions are used in D21G?

 Wire.begin();
  Wire.beginTransmission(0x21);
  Wire.write(0x4A);
  Wire.write(0x00);                 //  low byte
  Wire.endTransmission();
  Wire.beginTransmission(0x21);
  Wire.write(0x4B);
  Wire.write(0x00);                 //  low byte
  Wire.endTransmission();           // END OF EXTRA

Best regards.

Antonio_Per
Antonio_Per
4
| 2 1 1
Answered on 8/23/18, 11:11 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: 8/22/18, 11:47 AM
Seen: 2040 times
Last updated: 8/23/18, 11:17 AM