Shop OBEX P1 Docs P2 Docs Learn Events
PulsIn - Bs2 Got it — Parallax Forums

PulsIn - Bs2 Got it

ArchiverArchiver Posts: 46,084
edited 2003-09-17 11:18 in General Discussion
Okay, I took the easy way out for now.

15 volt PWM Signal coming in and being clamped by a 3.9 zener (what I
had on hand) Stamp reads it and outputs a signal to a RC Network.
Works Perfect, Dead On. Voltage out X 2 = Duty Cycle
I just need the duty cycle indication withing a percent or two so
even if the stamp regulator difts a little it will not hurt me too
bad. Mainly reference readings.

======================================================================
===
' File: FREQ2.BS2
'
' Counts and displays frequency of pulses arriving on Pin 0
'
======================================================================
===

F_pin CON 7 ' frequency
input pin
VOut CON 6
pHigh VAR Word ' W3 high
pulse width
pLow VAR Word ' W2 low
pulse width
period VAR Word ' cycle time (high +
low)
freq VAR Word ' frequency
T2 Var word
T3 var word
duty var word
'

Output 6
Loop:
PULSIN F_pin, 0, pHigh ' get high portion of
input
PULSIN F_pin, 1, pLow ' get low portion of
input
period = pHigh + pLow ' calculate cycle
width

t2 = plow
t3 = phigh
t3 = t2 + t3
t3 = t3 / 10
t2 = t2 * 10
t2 = t2/t3
freq = 50000 / period * 10 ' calculate frequency

' display on DEBUG screen

DEBUG Home
DEBUG "Period...... ", DEC period * 2, " uS ", CR
DEBUG "Frequency... ", DEC freq, " Hz ", CR
DEBUG "Duty Cycle ..", Dec t2, "% "

t2 = t2 * 255
t2 = t2 / 100

PWM VOut, t2,150 ' output voltage
porportional to duty cycle (voltage * 2 = duty cycle
GOTO Loop ' do it again












--- In basicstamps@yahoogroups.com, smartdim@a... wrote:
> You may want to consider a MAX5101 DAC.
>
> It has rail to rail output. It has 3 outputs selected by two lines.
>
> If you run it on 5 volts, you can then easily amplify by two for a
0 to 10v output, 5 volts = 50% duty, 7.5 volts 75% etc.
>
> Or if you run it on 10 volts you have 0 to 10 volt output. A cheap
and dirty DAC can be made with a thing called and R2R resistor
network. It is I/O pin hungry though (8 pins), but you can use a
shift register and get away with only 3 pins.
>
> Ken

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-09-17 03:49
    In a message dated 9/16/2003 7:07:27 PM Pacific Daylight Time,
    skinner02001@y... writes:
    Okay, I took the easy way out for now.

    15 volt PWM Signal coming in and being clamped by a 3.9 zener (what I
    had on hand) Stamp reads it and outputs a signal to a RC Network.
    Works Perfect, Dead On. Voltage out X 2 = Duty Cycle
    I just need the duty cycle indication withing a percent or two so
    even if the stamp regulator difts a little it will not hurt me too
    bad. Mainly reference readings.
    ________________________________________________________-

    Just curious, is the 15 PWM signal buffered before you clamp it with the
    zener? Is the solenoid still able to receive full battery voltage?

    A word of caution.......

    If you have an oscope, I would suggest you look at the "zener clamped" duty
    signal. Zener diodes are not particularly fast devices. There may be momentary
    spikes greater that 5 volts until the zener clamps. Over time, the momentary
    spikes (if they are there ) in time will likely damage that stamp input pin.

    Cool project.....I recently did the same, but with a different uP (SX28). It
    has a two digit display and analog output that is fed to a data logger. We use
    it at my work to look at the duty cycle of transmission lock up solenoids,
    and pressure control solenoids on competitor vehicles.


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-09-17 11:18
    Your right, right after I typed the message I realized by clamping,
    I'm also changing the entire signal going to the Engine computer as
    well. I'll go ahead and look at the Buffers and be done with it. At
    least I was able to breadboard it all out and make sure it would work
    fine (software). I had planned on having two digits as well to
    display 0-99 on top for a visual reference by using a couple of bcd
    drivers, but then I decided I would do multiple channels on one chip.
    Once up and going, I'm moving over the the 16F84.

    Thanks,
    Richard


    --- In basicstamps@yahoogroups.com, smartdim@a... wrote:
    > In a message dated 9/16/2003 7:07:27 PM Pacific Daylight Time,
    > skinner02001@y... writes:
    > Okay, I took the easy way out for now.
    >
    > 15 volt PWM Signal coming in and being clamped by a 3.9 zener (what
    I
    > had on hand) Stamp reads it and outputs a signal to a RC Network.
    > Works Perfect, Dead On. Voltage out X 2 = Duty Cycle
    > I just need the duty cycle indication withing a percent or two so
    > even if the stamp regulator difts a little it will not hurt me too
    > bad. Mainly reference readings.
    > ________________________________________________________-
    >
    > Just curious, is the 15 PWM signal buffered before you clamp it
    with the
    > zener? Is the solenoid still able to receive full battery voltage?
    >
    > A word of caution.......
    >
    > If you have an oscope, I would suggest you look at the "zener
    clamped" duty
    > signal. Zener diodes are not particularly fast devices. There may
    be momentary
    > spikes greater that 5 volts until the zener clamps. Over time, the
    momentary
    > spikes (if they are there ) in time will likely damage that stamp
    input pin.
    >
    > Cool project.....I recently did the same, but with a different uP
    (SX28). It
    > has a two digit display and analog output that is fed to a data
    logger. We use
    > it at my work to look at the duty cycle of transmission lock up
    solenoids,
    > and pressure control solenoids on competitor vehicles.
    >
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
Sign In or Register to comment.