Reading a Clock Output and printing to LCD

Sodapep

Member
Hello!

I have a project that puts out simpe on/off 0-5V signal clock frequency for a low frequency oscillator. The oscillator varies in period between 100Hz and 0.025Hz (10ms to 40s). I'm looking at using an 08M2 to read that clock output, convert it to beats per minute (simply 60,000/ms = BPM), and display the BPM on an LCD. I'll try to figure out how to print to an LCD in the future, but I'm trying to wrap my head around how to get the PICAXE to read the clock signal efficiently. Below is the datasheet for the chip producing the clock signal.

(datasheet for LFO chip: http://www.electricdruid.net/datasheets/TAPLFO2Datasheet.pdf)

In my project, the PWM is also unused, but I think interpreting the clock signal might be easier?

I thought the 'puslin' command could be used, but that has a timeout period of 655ms, not nearly long enough to read the slowest pulse reading from the LFO.

My second thought was to use the 'count' command. The PICAXE can read every 20us, and can count for up to 65s, so it will be able to count the fastest and slowest pulses. The problem I'm having here is with the period. In order to get the longest reading, the period would have to be slightly over 40s, or 40000 in the command. That means that the program would only update the BPM display every 40s. That's a very long time to wait for a read out when trying to dial in a certain BPM, especially when in the higher Hz range.

Is there another command that might be more useful, or perhaps a way to alter count or pulsin that would make it more useful/update the display in real time? Perhaps the PWM output would be of more use?

Thanks in advance for guidance. The project is in it's infancy, so besides the TAPLFO chip and using a PICAXE, no hardware is set in stone yet. I appreciate any help!
 

hippy

Technical Support
Staff member
I cannot see any practical way you could update quicker than the pulse period.

A better approach might be to use the PICAXE controlled by the pot to produce the required pulse.
 

Sodapep

Member
Hi Hippy, thanks for the reply! I'll have to do some reading about how to control the high/low of a pin via pot, but the TAPLFO chip has has the ability to set the frequency at a rate that is 'tapped' in, which is a feature I'd have to figure out how to replicate with a PICAXE. I have seen a tap tempo device done like it before, so I'll have to see if I can find it.

The PICAXE would have to have the frequency set by a potentiometer as well as a tapped value, read the BPM to an LCD and send the clock out to other devices. Lots of work ahead!
 

hippy

Technical Support
Staff member
I had not read the datasheet earlier. It might be possible for the PICAXE to generate a signal which activates the TAPLFO tapped button input appropriately set by the pot.
 

Sodapep

Member
That's the smartest thing I've heard all day! What a good idea.

I'm thinking it might be more practical to use two buttons to control the up and down BPM rather than a pot, as a range from 0.05Hz/20,000ms/3BPM to 10Hz/100ms/600BPM might be hard to dial in whole digit BPMs.

Since the slowest pulse the pulsout command can do is 655ms, so I'm thinking I could just use a simple loop of something like

Code:
Clockout:
low C.2
pause b0
high C.2
pause b0
goto Clockout
and have b0 equal to a ms value in a table. Since the M2 parts can have 512 values in a table, I'll truncate the BPM list down to 5 BPM to 515 BPM. I still have to figure out how tables and lookup stuff works, but hopefully the general idea seems feasible. Then do a little equation to convert the pause time to BPM and have that printed on an LCD. I'm sure I'll be back with many more questions, likely in what order all of this code needs to be in, but I'll do a bit more reading first. Thank you for all your help so far!
 

techElder

Well-known member
Sodapep, I've just recently created a routine (with the help of this forum) that uses a pot with ADC and 3 buttons for functions.

What I did was decide what functions apply to the buttons. The buttons are the "SAVE" for their function.

I use a physical dial with 3 different scales (for the 3 functions) printed on it for the almost 360 degree range of the pot.

Instead of converting the ADC readings to values that mean something to the functions, I used the ADC readings with SELECT/CASE statements.

The effect is that a range of settings on the dial SELECTS a value that is then SAVED with one of the function buttons.

You can choose the granularity that you want for your program without getting into complex integer math.

I'm not prepared to post the code just yet, but it isn't really all that fancy or new. It just works for me.
 
Top