Shop OBEX P1 Docs P2 Docs Learn Events
BS2 - most simple analog to digital? — Parallax Forums

BS2 - most simple analog to digital?

John KauffmanJohn Kauffman Posts: 653
edited 2013-08-09 15:15 in BASIC Stamp
I've been teaching intro courses for ten years with the WAM kit that uses BS2 on homework board. Two chapters in the kit use resistive sensors (pot and phototransistor). For years I've explained an RC circuit h'ware & s'ware. It takes a good while for them to understand it. They frequently mess up the hware or sware when trying a project without the explicit drawings in the book.

But I'm starting to get some serious blow-back from kids that have tried an Arduino. They are used to just hooking up a voltage divider straight into an analog port and reading the value.

Is there any solution for BS2 that is as easy? I know there are ADC but then we are into serial comm. I know I could switch to Propeller but for an intro to uCon class I think the BS2 is much easier (they get some VB in middle school but most have not had C yet).

Do I continue teaching RCTIME and live with the Arduino comments or is there an easier BS2 option?

Thanks.

Comments

  • SapphireSapphire Posts: 496
    edited 2013-08-08 14:08
    You can make a simple ADC with the BS2 and an op-amp or comparator. The BS2 outputs PWM to a capacitor to develop a voltage, which is compared to an unknown voltage with the op-amp or comparator. The output of the op-amp or comparator is fed back into the BS2 on another pin, and through iteration, you can determine the unknown voltage.

    There is an article about this here: http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol1/col/nv25.pdf
  • John KauffmanJohn Kauffman Posts: 653
    edited 2013-08-08 14:28
    Thanks Sapphire. Lots of good info in the piece and I appreciate the pointer.

    But if I understand figure 25.2 correctly that solution would require a cap, 4 resistors, the OpAmp and a separate 9v supply. I think the result would be more accurate than the simple RC, but would increase the difficulty for these beginners.

    Still, thanks, this is a good project for the more advanced guys.
  • Mike GreenMike Green Posts: 23,101
    edited 2013-08-08 14:30
    If you don't need speed, you can do ADC with just a BS2 and the RCTIME statement. Look at EMESystems' website for a discussion on this. Click on the "app-notes" link on the bottom of the page. The section is labelled "RCtime command"
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-08-08 14:31
    My own feeling is that the concept of RC time is so important in electronics that they should learn it. "for their own good". It's analog meets digital, but it goes much deeper than that. They will definitely benefit if they trend toward the analog side of things, but they can also benefit on the digital side, to understand a host of timing issues that will come up as they advance in the field.
  • SapphireSapphire Posts: 496
    edited 2013-08-08 14:39
    Yes, the figure does show a lot of components. They would be required for a comparator. If you use a rail-to-rail op-amp, then only the first 10k resistor and 0.1uF cap are needed. A single 5v supply to a rail-to-rail op-amp will swing the output enough to get good readings, and the output resistors aren't needed at all. I use the LMC6482 or LMC6484 for this with very good results.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2013-08-08 15:02
    I agree with Tracy ... "the concept of RC time is so important in electronics that they should learn it" ... And as a derivative of RC time, the concept of using a Sigma Delta ADC is also important.
  • John KauffmanJohn Kauffman Posts: 653
    edited 2013-08-09 05:59
    Thanks.

    I'm with you on the importance of an RC to electronics students, and it is not hard in the overall scheme. I agree it should be part of the engineering / technician / scientist courses.

    But my goal is bringing the tool of the BOE to non-electronics students. I work with them to incorporate a BOE into agriculture projects or art installations. I want them to think of it as a basic tool like a circular saw. Buy a BOE, buy some sensors, copy code, make a few code changes and you have a tool that works. Understanding the guts of the tool is not an objective for this group (viz few of us know how the three-phase motor of a saw works but we grab it and make a decent cut).

    If a sociology major needs to record durations of a hundred tests, I want them to think BOE instead of grabbing a stopwatch and pencil. The set-up for a recording timer has to be ten minutes, not a learning exercise in RC circuits.

    The simpler it is to use BOEs, the more that will be bought and incorporated in projects that have nothing to do with electronics. I'm guessing the market for the simple tool is probably several orders of magnitude greater than for an electronics teaching platform. In one school we put all 9th graders through a few lab periods covering the first chapters of WAM. The objective was for them to know they have a powerful and easy tool available to use in their projects as juniors and seniors, regardless of the discipline.

    So to sum up the thread:
    - there is no easier and less-part-count alternative to RCTIME to measure a resistive sensor
    - for STEM students it behooves them to learn RC because of the many applications
    - for STEM students there are some good alternatives to RC which make good lessons
    - for comparison with other platforms, Arduino has simple analog pins and BOE does not.

    (please see a newer thread for another thought on adding analog pins to BOE)
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-08-09 11:56
    Understood. A dedicated ADC is very convenient. You could provide something in the ADC083x family along with a "canned" subroutine that does the magic of returning a value. There is SHIFT communication involved, but it could be copy-and-paste, instant gratification. (and, "See appendix X for more detail.") Granted, it is a bit harder than setting up the arduino with the proper shield etc, I don't really know, but it seems like most arduino projects do involve a patchwork of add-on modules that have to be wired up and configured in some way. So wiring up the three SPI wires to a BASIC Stamp and loading in a short subroutine that takes a pin number, maybe a channel number, and sets aside a variable for a result should not be too onerous, and still teaches very useful stuff for the less technically inclined student. They avoid the big hurdle, which is often I believe the math involved with RCTIME.
  • GenetixGenetix Posts: 1,754
    edited 2013-08-09 14:58
    RCTime demonstrates what you can do without an ADC. For example, Steve Wozniac employed an RC circuit for the Apple II's Paddle Port.
    K.I.S.S. - Keep It Simple Stupid
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-08-09 15:09
    I once had a digital bathroom scale that used RC time techniques to couple its strain gauges to a General Instruments (pre-Microchip) NMOS PIC controller. The scale's accuracy was not compromised by such a "primitive" ADC technique.

    -Phil
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2013-08-09 15:15
    "RCTime demonstrates what you can do without an ADC. For example, Steve Wozniac employed an RC circuit for the Apple II's Paddle Port.
    K.I.S.S. - Keep It Simple Stupid "
    - Not only that... RCtime is also used for many PC game cards for the joysticks. The '558' Quad 555 timer was a popular solution for using two analog joysticks to obtain the X and Y values from the joysticks.
Sign In or Register to comment.