Driving a meter in 60 steps

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
FFMan
Posts: 502
Joined: 09 January 2010, 12:52 PM

Driving a meter in 60 steps

Post by FFMan »

just for a fun project I am aiming to turn a vintage analogue meter into a clock.

the meter is from an old pyrometer, and usefully the gauge is marked 1-12 from left to right, so I figure it could make an interesting clock.

the obvious way is to get a clock motor and attach/regear an endless pot to the hour hand shaft, only slight issue, finding a mechanism man enough to move a pot but I suspect that can be found. 1 rpm motors abound so a regear of this using some trusty meccano in several steps might work.

other method, trusty zbasic project, but how best to create a nice ladder of steps. might be best to have an hour output and then a minute offset and then combine the outputs.

I need to establish what current drives to fsd but I suspect it will be milliamps won't it ?

just a bit of fun really, hate to see nice looking vintage stuff go to waste..
twesthoff
Posts: 247
Joined: 17 March 2006, 6:45 AM
Location: Fredericksburg, VA

Driving a meter in 60 steps

Post by twesthoff »

You could drive it with a PWM pin and resistor, depending on what current is needed to drive the meter full scale..

On 9/9/2013 4:34 PM, ZBasic wrote:
just for a fun project I am aiming to turn a vintage analogue meter into a clock.

the meter is from an old pyrometer, and usefully the gauge is marked 1-12 from left to right, so I figure it could make an interesting clock.

the obvious way is to get a clock motor and attach/regear an endless pot to the hour hand shaft, only slight issue, finding a mechanism man enough to move a pot but I suspect that can be found. 1 rpm motors abound so a regear of this using some trusty meccano in several steps might work.

other method, trusty zbasic project, but how best to create a nice ladder of steps. might be best to have an hour output and then a minute offset and then combine the outputs.

I need to establish what current drives to fsd but I suspect it will be milliamps won't it ?

just a bit of fun really, hate to see nice looking vintage stuff go to waste..



twesthoff
Posts: 247
Joined: 17 March 2006, 6:45 AM
Location: Fredericksburg, VA

Post by twesthoff »

Would you post a picture of the meter? Not many have scales of 0 to 12.
Nice way to make a clock, with PWM you can fine tune each major point to make it more accurate too.
Don_Kirby
Posts: 341
Joined: 15 October 2006, 3:48 AM
Location: Long Island, New York

Post by Don_Kirby »

The 0-12 scale is probably 0 - 1200 degrees. Pyrometers typically employ thermocouples to sense temperature, which generate their own, non-linear voltage relative to the applied temperature. If this is the case with your meter, it may be a bit of a challenge to interface it, as the voltages required to drive it full-scale would be in the millivolt range. Moreover, the non-linear response of the meter means that 10 millivolts doesn't necessarily produce twice the needle movement as 5 millivolts.

If all else fails, you could certainly replace the existing internals with an inexpensive RC servo, which would be very easy to drive with a PWM signal.
FFMan
Posts: 502
Joined: 09 January 2010, 12:52 PM

Post by FFMan »

thanks for the comments - hadn't though of pwm.

will post a pic on Friday when I am back at home, and run some test to determine fsd and whether its linear or not - had not occurred to me it wouldn't be.

servo might be the way, but feels like kind of cheating !
FFMan
Posts: 502
Joined: 09 January 2010, 12:52 PM

Post by FFMan »

OK - couple of pictures attached.

The resistance of the movement is 80.4 ohms. The needle is a bit floaty but settles to a consistent reading. The scale is 0-12 and ma required to drive it are below.

So does not appear to be linear though it has to be said this is with a pot and a psu, but I think there is sufficient difference to assume its not quite linear.

of course if I use pwm, I can program any curve I like

Code: Select all

12= .156ma
9=.107		.049
6=.067		.040
3=.026		.041
is pwm likely to be work here, or shall I just get a mini servo.

the advantage with the mini servo idea is I can fit all the workings inside the case which would be nicer than having an external module.

any thoughts out there ?

thanks
Attachments
IMG_0392_s.JPG
(171.96 KiB) Downloaded 174 times
IMG_0393_s.JPG
(193.71 KiB) Downloaded 185 times
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Driving a meter in 60 steps

Post by GTBecker »

> ... does not appear to be linear...

To the contrary, graphing those four points appears to be a nearly
straight line. Only the value for "12" looks a little high, and an
extrapolated "0" seems to cross Y at about -0.01, so all you need is an
offset of~+0.010mA. Does the meter have a zero-set screw?

Your attachments didn't make it, unfortunately, but if fullscale is
"12", it might be a 150uA FS movement. Generating an appropriate
current should be easy with PWM and a series resistance, allowing the
movement mass to integrate.

Edit: I see the images on the web page. Looks like there is indeed a zero set on the movement.
Tom
DocJC
Posts: 112
Joined: 16 March 2006, 6:23 AM
Location: Cleveland, OH
Contact:

Post by DocJC »

Which micro are you using?

Before you get too far in your design you might want to program the Timer/Counter in PWM mode and output 100% and 0% and then measure the output voltages with an O'scope or DMM.

The high might be ~ 4.5 V on a 5 V micro, not 5 V.
Likewise the low might be a few tenths of a volt above 0 V.
This is dependent upon the output driver used inside the micro.

Unless the zero-set screw allows you to set the pin negative enough at 0 % PWM output one would need to add a negative voltage to the PWM output to get zero. i.e. Zero on the display has a small + voltage output from the micro, giving a small current at the 0 level.

If you switch to a micro driving a couple of op-amps then the output of the micro could be fed through a true LPF, (RC), to integrate the pulse train into a slightly ripply DC value. An op-amp then adds whatever DC offset and gain you need for precisely hitting your 0 and 12 marks.

One could also, of course, use a rail-to-rail op-amp to convert the micro's PWM waveform into a waveform that goes very close to 0 for the low, and to a known voltage for the high. Then feed this to the meter, or convert it to a DC for the meter using a second op-amp.

Given the low resolution of the meter and the visual parallax error in reading it, the above might not make a big difference, but it is nice to be aware of the issues before you start tinkering.

Lastly, read the data sheet carefully. If I recall correctly on some of the AVR micros, in one of the PWM modes, 0 isn't zero. The module outputs a periodic pulse even for 0 output! This is evident when driving LEDs. It would also add to your 0 level output voltage.

I can recall capturing the 0 level in code as a special case, and then outputting 100 % with a reversal of the output polarity, giving a true 0 output, without the periodic pulse being an issue.

I think this came up before, and Don already does this if you are using the ZBasic commands to generate the PWM, and not setting the registers yourself.

Cool meter, by the way!

JC
FFMan
Posts: 502
Joined: 09 January 2010, 12:52 PM

Post by FFMan »

thanks for the reply and the heads up on hitting zero.

my electronics expertise does not run to some of the techniques you mention, but i'll see what 0% gives. if there is an offset, a second pin used ti drive a relay or similar to drop the feed at 0% might work. depends on what 0% gives.

i'll see what processors I have in the drawer, my test bed tends to be a zx24p but the 328n is better price wise and I think I have a few in the bits box. am toying with an RTC chip and of course I will have to code a simple mechanism to set the time which I will aim to do without adding an lcd, but using the meter scale to set hours and minutes. one or two discrete buttons should cover it.

will get some tinker time soon I hope.

thanks
FFMan
Posts: 502
Joined: 09 January 2010, 12:52 PM

Post by FFMan »

OK - found some time to do some experimenting using a zx24p.

If I insert a series resistor (approx. 35k) such that 100% duty is FSD then as correctly foreseen, at 0 duty cycle the meter reads 1.2, or in my terms 01:12 which isn't so great.

this is a reading of 0.25v.

Why isn't this zero at zero duty cycle and whats the easiest way around it ?

If I set the pin to output and then low I get about the same result.

thanks
FFMan
Posts: 502
Joined: 09 January 2010, 12:52 PM

Post by FFMan »

Actually I think thanks to DocJC I have found a simple solution.

The zero set lever allows effectively to add some -ve offset. I can then recalibrate by series resistor to read 12 at 100% and all looks good.

Will keep playing but I think its almost there.

If I move to a 328n, will my max voltage effectively be 3.3 or thereabouts ?
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

FFMan wrote:If I move to a 328n, will my max voltage effectively be 3.3 or thereabouts ?
The ZX-328n is supposed to be run at 5V. Perhaps you intended to refer to a ZX-328L. Whatever the supply voltage, 100% PWM will yield an average voltage very near the supply voltage. At 0%, the voltage is slightly above zero because "Vol" (Voltage Output Low) is never 0.0 volts on any logic family that I know of. This is due to the saturation voltage from drain-source or collector-emitter depending on the logic family.
- Don Kinzer
FFMan
Posts: 502
Joined: 09 January 2010, 12:52 PM

Post by FFMan »

I see I have a couple of 328l in the parts box.

Could I run this at 5v to give me the PWM range I need ?

If I could, I assume the slower clock has no material effect on PWM ?

thanks
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

FFMan wrote:Could I run [a ZX-328L] at 5v to give me the PWM range I need ?
Yes. The ZX-328L can operate from 2.75 to 5.5V. You'll find this on the ZX-328L product page.
FFMan wrote:If I could, I assume the slower clock has no material effect on PWM ?
The only effect of a slower clock is a lower maximum PWM frequency.
- Don Kinzer
FFMan
Posts: 502
Joined: 09 January 2010, 12:52 PM

Post by FFMan »

thanks

> The only effect of a slower clock is a lower maximum PWM frequency

but I assume 50hz isn't an issue ?
Post Reply