Skip to content
Parallax Learn

Parallax Learn

  • Welcome
  • Tutorials
        • Tutorial Series head tag

          Tutorial Series
        • Tutorial Series

          The special, classroom-ready series pages are organized collections of tutorials for our most popular hardware and/or languages. The tutorials for each topic are conveniently accessible from a single page, shown in the order it is recommended that they be completed.
        • Robotics Series Head tag

          Robotics Series
        • Robotics Series

          • Artificial Intelligence
          • Cybersecurity: Radio Data tutorialCybersecurity
          • cyber:bot + Python
          • cyber:bot + MakeCode
          • Boe-Bot Tutorial SeriesBoe-Bot
          • Arduino Shield-Bot
          • ActivityBot with C TutorialsActivityBot + C
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot + BlocklyProp
          • Scribbler 3 Tutorial SeriesScribbler 3
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education
          • Propeller C-Language BasicsPropeller C Basics
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit + C
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit + BlocklyProp
          • Badge WX Tutorial SeriesBadge WX
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics
          • View All Tutorial Series »
        • Browse Tutorials
        • Browse Tutorials

          Individual tutorials sorted by robot or kit, and language.
        • By Robot or Kit
          • ActivityBot
          • SumoBot WX
          • Boe-Bot
          • Shield-Bot
          • cyber:bot
          • Badge WX
          • ELEV-8
          • ARLO
        • By Language
        • By Language

          • Propeller C
          • Arduino
          • BlocklyProp
          • PBASIC
          • Python
          • MakeCode
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses
  • Visible Light Navigation for the cyber:bot

Visible Light Navigation for the cyber:bot

RC-time and Voltage Decay

The charge transfer measurement is done with these two lines of code:

    bot(8).write_digital(1)        
    qt_left = bot(8).rc_time(1)

The first line, bot(8).write_digital(1), does two things.  First, it charges the capacitor by setting Propeller I/O pin P8 to output high (3.3 volts). Then, it waits one millisecond for the capacitor to fully charge – more than enough time for this tiny one. 

The next line, qt_left = bot(8).rc_time(1), is doing a lot more.  The rc_time function:

  1. Marks the time on the Propeller system clock.
  2. Sets P8 to an input, which allows the charge in the capacitor to start draining.
  3. Watches the voltage sensed at P8  Remember, P8 is a digital I/O pin; instead of sensing a range of analog values, it reports either a high (1) or a low (0) signal with 1.6 volts being the threshold in between.
  4. Marks the time again when the signal at P8 changes from 1 to 0.
  5. Subtracts the first time marked from the second time marked. The result is how long it took capacitor to discharge from 3.3 V to the 1.6 V voltage threshold.
  6. Stores the discharge time in the variable qt_left.  

Look Deeper: Voltage Decay Graphs

Here is an example of a charge transfer measured with an oscilloscope, a device that displays voltage as it changes over time.  The vertical axis on the left is volts, and time increases by milliseconds along the bottom. 

The red line that’s graphing voltage is called a trace.  The trace plots the capacitor’s voltage in the P8 QT circuit; that’s the left light sensor.  In response to bot(8).write_digital(1), the voltage quickly rises from 0 V to almost 3.3 V at about the 1 ms mark, and stays there for 1 millisecond.  Then, at the 2 ms mark, the rc_time call allows the voltage in the capacitor to start draining, or “decay.”  The rc_time function measures the time it takes the voltage to decay to the Propeller I/O pin’s logic threshold of about 1.6 V. This measured rc decay time gets stored in the qt_left variable.  In the plot, it looks like that decay took about 1 ms, so the qt_left variable would store a value close to 1000.

Keep in mind that these are not the voltage measurements from Activity 1, they are time measurements.  When the voltage decay takes a short time the number will be small, and that means bright light.  When the voltage decay takes a long time, the number will be larger, and that means dimmer light, shade, or for really large numbers, darkness.

Keep in mind that these are not the voltage measurements from Activity 1, they are time measurements.  When the voltage decay takes a short time the number will be small, and that means bright light.  When the voltage decay takes a long time, the number will be larger, and that means dimmer light, shade, or for really large numbers, darkness.


Printer-friendly version
Test the Light Sensor Eyes
Prev
Light Measurements for Roaming
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024

© 2025 Parallax Learn • Built with GeneratePress