will attachInterrupt interfere with 74hc595

I accidentally posted this in the wrong forum first, sorry about that.

Hi, I'm in the process of using 3 or 4 74hc595 shift registers to control a pov display I'm trying to make. I use a hall effect sensor (finally working!) to keep track of rotations.

I haven't hooked both systems up together yet (leds AND hall effect), so I'm not sure how this is going to work. if I use attachInterrupt on the hall effect sensor to call a function that adjusts for any small change in motor speed (it seems to vary between 900-1000rpm), will that completely destroy the data going out to the shift registers at that point? because, well, its interrupted... :)

also, I have 27 leds. If I use 3 shift registers for the first 24, will hooking the last 3 directly up to the arduino alter their timing any? I don't know if there's a noticeable delay between turning on an arduino pin, or sending data out through 3 daisy-chained shift registers

How are you controlling the display if you are using the interrupt elsewhere? Are your LED's multiplexed?

Using a attached interrrupt can effect the timing some on anything you have that is using delay(), etc, as all interrupts are disabled upon entering your interrupt routine. This would result is some 'slowing' of timing loops. A lot depends on how much code you include in your ISR routine. The basic idea is to do as little as possible inside the ISR so that normal interrupts can be reenabled when your ISR completes. If you keep your ISR routines very terse then you may not even notice an effect.


hmm? not sure I understand the question.

I have these leds wired up very similar to the shiftout tutorial, and the code basically has a few bytes for testing purposes that control individual leds off the shift register(eventually will make an array of bytes). I’m dividing up 1 rotation into its individual pixels, and then I’m going to do something similar to this

float last_event=millis(); // or micros? would that help for accuracy?

void interrupt_function()
rotation_time=some_beginning variable

I’m assuming that if my code outputs one “position” of lights, then delay(rotation_time/360) or however many different degrees I slice the circle up into, then it’ll adjust for slight variations in motor speed. I set up interrupt_function() to alter the effective “size” of each window of time.

but 2 things about this, the first is that at 900 rpm it will interrupt at least 15 times/sec. Is this going to throw off the shiftout function? If I’m sending a byte and only get in a couple bits because the interrupt triggers, will the system just wait patiently until the interrupt function is done to finish off the rest of the byte?

I’ve heard that serialout actually doesn’t actually use the spi ability in the arduino, and I spoke to an engineering professor that spi hardware isn’t affected by interrupts, but I’m really just relaying this without understanding it.