Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:51 29 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : measuring period

Author Message
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2350
Posted: 01:59am 27 Mar 2014
Copy link to clipboard 
Print this post

a question which geoff may know the answer to (and probably others):

when measuring period (ie, after configuring a pin with "SETPIN pin, PIN"), what is the granularity of the measurement? does it measure to the nearest millisecond, or down to microseconds?

i am wanting to create a keypad consisting of resistors and a capacitor that is charged up. to do this, i need to be able to basically measure the time between discharging the capacitor down to 0 volts, and the capacitor charging up to the point that the input pin it is connected to reaches a logic 1 level.

in an ideal world, this would consist of a command that pulls a pin low (open collector) then times how long it takes for the pin to flip state (to '1') once the low has been removed. i'm thinking of achieving this through a brief pulse on a second pin that discharges the capacitor, with this discharge pulse also gated onto the timing pin.

the above is, i suspect, relatively close to how the DISTANCE command works. indeed, i may be able to adapt this to fill the job.


rob :-)Edited by robert.rozee 2014-03-28
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2817
Posted: 08:24am 27 Mar 2014
Copy link to clipboard 
Print this post

Hi Rob,

Smart idea trying to create a keypad based on capacitive-touch techniques.

What kind of charge/discharge timescales are you designing this upon?

In response to your question I don't know if this extract from Page 23 of Geoff's Beta 16 manual helps:

For accurate measurement of signals less than 10Hz it is generally better to measure the period of the signal. When set to this mode the Micromite will measure the number of milliseconds between sequential rising edges of the input signal.


Sorry I can't add any more value here; I simply haven't played around with Period measurements on the MicroMite.

Hopefully Geoff will give you a definitive answer when he reads your post!

Good luck with this idea; I hope you get it working . . . .



For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2350
Posted: 01:02pm 27 Mar 2014
Copy link to clipboard 
Print this post

not quite capacitive-touch, the buttons will close real switches, and select between a set of charging resistors, while the single timing capacitor will be something like 1nF or so. the charge time when a key is pressed will be proportional to R x C, and i'm planning to pick the R and C values to achieve times less than a millisecond. lets say 50uS for the top left key and 800uS for the bottom right key.

for the circuit, imagine the LM334 keypad example discussed elsewhere, but replacing the LM334 etc with the timing capacitor.

at present, without resorting to anything to clever, the quickest solution seems to be to have the keypad select the timing resistor in an LM555 pulse generator circuit. connect the output of the 555 into a counting pin, and count the pulses received over a 10mS interval (using a 10mS timer interrupt). pick values to produce between 100 and 1600 pulses in the 10mS interval, or between 10KHz and 160KHz. this seems within the micromite's abilities, and would give 100 keypad samples per second.


rob :-)
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2817
Posted: 01:31pm 27 Mar 2014
Copy link to clipboard 
Print this post

Rob,

Without thinking too much about the logic, could this method allow for multiple key presses?

I tried something similar back in March 2011 but stopped the project due to personal reasons. I never did get back to the project as other ideas then took over.

By the way I initially said ' . . . keypad based on capacitive-touch techniques' as I fully appreciated you were using actual switch contacts. The theory is identical to certain methods used in capacitive touch and hence it will work in theory; however do you feel it will realistically work in the real world or is there some catch?

I really hope it does work because I have several uses for something like this.

Please keep us posted on progress.


For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2350
Posted: 02:31pm 27 Mar 2014
Copy link to clipboard 
Print this post

you mean key rollover, where having two keys down at once will produce the 'code' for the first key pressed, then the code for the second key pressed without the first key still being down causing interference? i'm afraid not, to achieve this requires either having multiple pins used for sensing, or being able to (more or less) differentiate between 2^n states (where n=16 for a 4x4 keypad) on a single input pin.

at best, the methods i am looking at can lock out having more than one key down at once. ie, require an 'all up' period between keypresses and ignore when a second key is pressed while the first is still down.

i'm now thinking that counting pulses won't work reliably, as generating a timer interrupt that occurs at exactly a fixed interval might not be possible on the micromite (or maximite). since interrupts are only serviced between interpreting lines in the main part of a program, while over time the total number of interrupts occurring may be correct, there could well be quite a bit of jitter on individual ones.

which leads me back to the LM334 solution. i do think i may have come up with a solution that will not require a temperature compensation diode, while still being independent of temperature. and also not be reliant on the calibration of the A/D converter (ie, independent of Vcc voltage). i shall post the results soon.


rob :-)
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 08:48pm 27 Mar 2014
Copy link to clipboard 
Print this post

A 12/14 pin pic connected to I2C will work with a 4x4 keypad and use only 2 pins (that are already designated for I2C use). Cost will be about the same as a LM334 with its caps/resistors and uses less pcb space.

Any particular reason to not do that?


Microblocks. Build with logic.
 
MOBI
Guru

Joined: 02/12/2012
Location: Australia
Posts: 819
Posted: 09:21pm 27 Mar 2014
Copy link to clipboard 
Print this post

  Quote  A 12/14 pin pic connected to I2C will work with a 4x4 keypad and use only 2 pins


I have been doing that for years and think I already have a topic on TBS on the subject. Choose between 12key or hex.

===============
Just because I use i2c and also it is my comms of choice, it shouldn't detract from trying to make a single pin key keypad to fit (e.g.) the uMite. It is a great pin saver and besides it would be fun to succeed at. I don't know how many things I have built over the years simply to say at the conclusion "well...I beat you, you b...d"

I am following the project closely as it may lead to a method of "multi addressing" a i2c slave using just one pin.Edited by MOBI 2014-03-29
David M.
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 11:20pm 27 Mar 2014
Copy link to clipboard 
Print this post

You are right!

Having a challenge is part of the fun.
An essential part of doing what we do. :)

I often have I2C in my projects already (RTC,Memory) and connecting an 'analog' keyboard using only one pin is actually using one pin more then absolutely necessary.
Having a BOM for both options can be surprising sometimes.

And of course it all depends on the project.





Microblocks. Build with logic.
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024