Pages: [1] 2   Go Down
Author Topic: keyboard multiplexing  (Read 3039 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I am trying to do some keyboard interfacing. (a-z characters + few other buttons).
So, it's all about 30+ inputs. (3 rows, 10 columns)

One of the way to minimize the input is, I've done the wiring as the keypad.
But still, it's about 10(columns)+3(rows) = 13 inputs.

Are there any other chip decoder, or any multiplexing method that I can use to reduce the inputs? Maybe <5 ?

Thank you.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 504
Posts: 19095
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

To get 30+ inputs down to a couple of wires you really need an I/O expander or similar. I did an post about using the MCP23017 (the chip costs around $2):

http://www.gammon.com.au/forum/?id=10945

That gives you 16 keys for only two ports on your Arduino (the I2C ones). You can wire up two using the same 2 ports by configuring them for different addresses (that post shows how). That gives you 32 keys.

There is also a Centipede shield that gives you 64 inputs/outputs (it is basically 4 x MCP23017 on a shield). You could use that in conjunction with the code I give in the post.
Logged


0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


That looks interesting. Thank you.
I will have a look at it.

Anyway, what digital oscilloscope did you use?
Especially with all the snapshots.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 504
Posts: 19095
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It was a logic analyzer, not an oscilloscope. I have a digital oscilloscope but it has a memory for a rather pathetic 2.5K samples. The Logic analyzer can save 10000M samples at a sample rate of up to 24MHz. That's a LOT more.

http://www.saleae.com/logic/

It also has analyzers for I2C, SPI, Serial, one-wire, and a few others. I have no commercial connections with them (apart from buying one) but I have been happy with it. It runs on Mac, Windows and Linux.

For $US 149 I find it an invaluable aid for debugging SPI/I2C connections. At least you can see whether the problem with your code is whether you are sending the right data, and getting a response, and if so, what you are sending and receiving. Without it you are largely guessing.

I've heard prices quoted for mixed-signal oscilloscopes for something like $10000 for something that will handle that many samples.
Logged


Sussex UK / CT USA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1028
Forums forever
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you get a cable with the USB interface built into it, you can avoid buying that (expensive) circuitry over and over again, to lie dormant in many Arduino finished projects.

Once you've done that, you can buy Arduino clones like the RBBB for about $14 inc p&p.

Details of cable, etc: http://www.arunet.co.uk/tkboyd/ele1psa.htm

At these levels, it would be easy to use two Arduinos for your project... one to "digest" the 10+3 inputs, and forward them to the second one over 5 digital lines... or over 1, if  you used a serial link....

http://sheepdogguides.com/dt4t.htm

Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thx for the info both of you.

Cheers.

Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@Nick,

As I am thinking of buying some logic analyzer for my debugging purposes, I have few questions for you.

As you said that the one that you used is only 24Mhz, as we know that the arduino runs on 16Mhz,
If I have arm cortex (leaflabs maples) running on 74Mhz, can this logic analyzer be used?

For my case, any logic analyzer that you can recommend?

Thank you.
Logged

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

The problem with a logic analyser is that it has to run many times faster that the circuit it is analysing in order for it to be any good. If it only runs at twice the speed then that is a 50% timing error in any signal it captures. I would go for at least 10 times the operating frequency of the system you want to measure.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 504
Posts: 19095
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I have been very happy with the Saleae Logic analyzer (link above). I know about sample rates, but you don't need to sample the processor directly, you need to sample the output of the processor. For every test I have done with the Arduino (including clocking out SPI by the hardware) it has easily kept up. For example, this quick test:

Code:
void setup ()
{
  pinMode (8, OUTPUT);
}

void loop ()
{
  digitalWrite (8, HIGH);
  digitalWrite (8, LOW);
}

You can't output pin level changes much faster than that (well, see below) but it captured that with samples about 100 apart (the pulses were about 4 microseconds each). So that is easily twice the rate of the changes.

In fact, the fastest I have seen it clock stuff out is the SPI clock, which (under hardware control) runs at about 125 ns per clock pulse. Capturing that I get a pulse on every 3rd sample, so it is just keeping up. In fact if my arithmetic is right, a 24 MHz frequency means sampling every 42 ns, which sounds about right for those results.

So my point is that, for the Arduino, this device can keep up with SPI clocks, and certainly pulses clocked out under software control. So for debugging SPI/I2C/async serial, it has been fine.

The Atmega328 runs at 8 Mhz doesn't it? So that is easily in range. The 74 MHz processor might be a challenge, I agree with Mike that you need the analyzer to run faster than what you are trying to measure or you get false readings. But again, it depends a bit on how fast the processor actually outputs the data you are trying to measure. For one thing, it depends on how many clock cycles it takes to execute an instruction.

And I should point out that I was trying to analyze USB logic. High-speed USB was just too fast for this particular unit. Low-speed it just kept up. In low-speed USB the pulses are 666 ns, so it was able to sample them. However having said that I wouldn't really recommend trying to understand USB with one of these, it is just too complex. A proper USB analyzer would be more efficient.
« Last Edit: March 05, 2011, 12:46:26 am by Nick Gammon » Logged


Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27372
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

"The Atmega328 runs at 8 Mhz doesn't it? " The 3.3V versions do, 5V is at 16MHz. Perhaps  you meant a different part?
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 504
Posts: 19095
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I meant that part, at 5V. I was wrong. The datasheet isn't the easiest thing in the world to quickly get a summary from. Anyway, that pretty much supports the observed behaviour of clocking out SPI pulses. At 16 MHz one clock would be 62.5 ns, so if I observed the SPI clock rate to be 125 ns, that would mean it clocks out every 2 CPU clock pulses.

It is certainly believable that the SPI hardware needs 2 CPU clock cycles to "do its thing" of setting up data on the data pin, and then clocking it out. Perhaps one cycle to get the data from memory, and the second cycle to set up the SPI pins.
Logged


0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So, does it mean that if I want to test the 74Mhz, I would require about analyzer that can read 350Mhz++ ?

I have searched some and found this http://www.pctestinstruments.com/ -  500 Mhz.
What do you think?

I would like to ask, would it still can read the data if I use the salae, and checking the 74Mhz?
I don't need the actual speed, only to debug certain period. (e.g: when switch is on, delay and etc)

Anyway, have you guys found any logic analyzer that has an extra of analog signal reading as well?
Or do I need an oscilloscope?

Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27372
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Man, that looks like a nice one.

I didn't read all the specs, if it has a way to define an external trigger to set off a digital scope to capture a brief  'glitch' event also that would be awesome.
« Last Edit: March 02, 2011, 10:37:12 pm by CrossRoads » Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 504
Posts: 19095
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

He is talking about the LA1034 LogicPort which provides 34 channels sampled at 500MHz. Ah, how do I respond? I haven't got that one so I can't say for sure. I would suggest Google "compare LA1034 Saleae". You see some interesting comments.

One point of difference, raised in one of those posts, is that the Saleae Logic samples at 24 Mhz for a simple reason - so it can stream the samples via USB to your PC (or Mac, in my case). Now the faster analyzers have to keep the samples in internal memory, which in the case of the LA1034 is 2K (per channel). Now admittedly they use compression (ie. noting changes, not just every sample) but if you have at least one channel that is "clocking" (eg. an SPI clock) then the compression won't do much, and you run out of samples after 2K.

By comparison, the Saleae Logic can stream 10000M samples (ie. 10G samples) to your PC. That's a lot. And it means you can set a trigger on something early (like, turning the gadget on), and look for things which happend 10G samples later.

If you want to see what I have done with the Saleae Logic device, check out my posts here:

http://www.gammon.com.au/forum/bbshowpost.php?bbtopic_id=123

Most of them have screen captures from the Logic. Things like switch bounces are clearly visible. You can see the SPI clock. And as I said before I could follow low-speed USB. Now high-speed USB is too fast, but then, 2K samples is not enough for high-speed USB (for any serious analysis), so the faster unit wouldn't be much of a help.

That raises another point, the Saleae Logic runs on Mac and Windows (and Linux I believe). So if you are a Mac user that might influence you.

Quote
Anyway, have you guys found any logic analyzer that has an extra of analog signal reading as well?
Or do I need an oscilloscope?

It's called a mixed-signal scope, and I would love to have one. smiley-wink  In fact, I have a Bitscope which does that:

http://www.bitscope.com/

However personally I just find the Logic really easy to use. It is small, it just sits on the disk virtually unnoticed. The software is pretty easy to use. It does the job.

But, don't take my word for it. Try Googling "compare logic analyzer" and see what other people think.
Logged


Global Moderator
Offline Offline
Brattain Member
*****
Karma: 504
Posts: 19095
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The other thing that the Logic analyzer does is let you set triggers. You can choose one channel (eg. SPI SS) to be the trigger on a raising or falling signal. Plus other channels can be and'ed in with the requirement that it is high or low. So you might trigger on channel 1 falling if channel 2 is high and channel 3 is low.

When I was testing keypresses I just put a trigger on the button itself. And bearing in mind that it has a memory, I can see what happened before the trigger.
Logged


Pages: [1] 2   Go Up
Jump to: