Pages: [1]   Go Down
Author Topic: get shiftin data with interrupt  (Read 662 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hello,

i build the Parallel to Serial Shifting-In with a CD4021BE from the arduino tutorials http://www.arduino.cc/en/Tutorial/ShiftIn.
now the question is: "can i call an interrupt on pressing a button?"
i want to make a keyboard out of this to control the frequency of a sinewave,
but the response time is to slow, so evertime a state change takes place (button released/pressed) i want to interrupt the main program and set a new tuning word to look up in the dds table.
when i put the datapin on pin 3 an write

attachInterrupt(1, doPiano, CHANGE); // pin 3

then the function doPiano is called continuos, without pressing or releasing any button.
any suggestions?
i would appreciate.

greetings
peter
Logged

Central Europe
Offline Offline
Edison Member
*
Karma: 7
Posts: 1220
Use the Source, Luke.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

With the hardware you mention, no keyboard interrupts. You'll have to poll the keyboard by continuously cycling through the shift registers.

Korman
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 127
Posts: 8517
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
but the response time is to slow
How slow, the SR read should happen in < a couple of uS I would think.

Quote
when i put the datapin on pin 3 an write

attachInterrupt(1, doPiano, CHANGE); // pin 3
This will interrupt on the first change of state coming out of the SR's data pin and probably all others. The interrupt(s) will occur part way through the shiftin function so your doPiano function will be called at the wrong time and with dodgy data.

Quote
then the function doPiano is called continuos, without pressing or releasing any button.
Can't explain that, unless the code is dicking with the data pin there should be no changes if no keys are pressed.

Also have a look at the MAX6818, that will give you an interrupt on any input change of state.
« Last Edit: September 28, 2010, 07:49:37 pm by graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34150
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
but the response time is to slow,
You haven't posted the code but there is probably a whacking big delay in the loop. Remove this for faster response.
Logged

Pages: [1]   Go Up
Jump to: