Shop OBEX P1 Docs P2 Docs Learn Events
Stop The Blinking! — Parallax Forums

Stop The Blinking!

kivimakikivimaki Posts: 2
edited 2007-03-06 14:05 in BASIC Stamp
I am doing an art project with a basic stamp and an accelerometer where a light gets brighter the longer the object is in motion. If the object is at rest, the light slowly fades away.

I finally got everything to work (at the beginning of the project three weeks ago I had never used a basic stamp and had no experience with circuitry), but the light is constantly blinking.

To make the light (flashlight bulb) fade, I have it hooked up to a transistor and I am using PULSOUT with a variable duration on the base. I believe that the blinking is introduced when the stamp gets the info from the accelerometer, because my PULSOUT method works in a simple DO ... LOOP.

Is there any way to fix the blinking but maintain the fading effect? I thought about using a digital potentiometer, but when I tried it out, it didn't work.

Any suggestions would be greatly appreciated.

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-03-05 23:22
    Guess you'll want to change from DO...LOOP to DO...LOOP...UNTIL
  • kivimakikivimaki Posts: 2
    edited 2007-03-05 23:35
    My actual program does not have a DO...LOOP. I just used the DO...LOOP to figure out how to dim the light using PULSOUT. The actual program is a big loop, but with the other code to monitor the position, I effectively get a loop with a pause where the code is. My question is if there is a way to keep the light on while the other code runs.
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2007-03-05 23:39
    The "Process Control" text has circuits that can be used to lock in that PWM voltage (filtered and buffered) to drive the load while doing other things. The text uses it to keep a fan running at a variable speed, but the principle is the same. It's in chapter 5 I think?

    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    StampPlot - GUI and Plotting, and XBee Wireless Adapters
    Southern Illinois University Carbondale, Electronic Systems Technologies
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2007-03-06 01:19
    kivimaki--

    Gee. Why don't you post your code? There are a LOT of helpful people here that may be able to spot the problem in your code. Maybe, even me, although I am also a newbie.

    Just for curiosities' sake, why did you use a flashlight bulb instead of an LED? (Not that your choice is "wrong"; it just seems more difficult to me, although it may not be.)

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-03-06 14:05
    PULSOUT lets you send a programmable width output pulse, from 2 uSec to 65.536 mSec.

    Well, you can do something similar in code, using:

    OnCounter VAR BYTE
    BlinkState VAR BIT
    LightBulb CON 0 ' 0 being the pin the lightbulb control is on in this example


    BlinkState = 0
    OnCounter = 0
    MAIN:
    IF BlinkState = 0 THEN
    BlinkState = 1
    HIGH LightBulb
    ELSE
    BlickState = 0 ' it WAS 1 on entry...
    LOW LightBulb
    END IF
    IF SensorTime THEN
    ReadSensor
    ELSE
    PauseOneSensorTime
    ENDIF
    ' When HERE, go do something else, like read your sensor.
    ' Note, you'll have to experiment to find out how long it takes
    ' to read your sensor.

    The idea with this code (bad example, sorry about that) is to use the time around the main loop of your program as a primitive time-delay. It's going to be around 20 mSec or so -- which would give you a slow but effective 'PWM rate'.

    So, a 50% duty cycle would be 20 mSec on, 20 mSec off. Your eye can't react this fast, so you won't see any flicker. To change the duty cycle, use the "OnCounter" to adjust how many cycles the light is 'on' versus 'off'.
Sign In or Register to comment.