Shop OBEX P1 Docs P2 Docs Learn Events
Tutorial on ADC posted — Parallax Forums

Tutorial on ADC posted

Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
edited 2011-03-24 17:31 in Propeller 1
I spent some time working with the 3208 ADC chip and did a quick tutorial on it.

http://www.gadgetgangster.com/tutorials/397

Feel free to point out an obvious flaws or errors if spotted.

Hope it helps someone.

Thanks!
OBC
«1

Comments

  • $WMc%$WMc% Posts: 1,884
    edited 2011-03-15 11:43
    Thanks for the Tutorial OBC.
    '
    I need all the help I can get with Spin.
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-03-15 11:46
    OBC, thanks. This is very helpful!
  • JasonDorieJasonDorie Posts: 1,930
    edited 2011-03-15 12:19
    Jeff - That's very well written. I've been thinking of doing some entry level tutorials for the Prop. Yours is a great example of how to present it.
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-03-15 13:36
    Jeff,

    Two notes:

    1) For safety sake, it's a good idea to connect DOUT and DIN via a 3.3K (or higher) resistor; this prevents collisions [due to programming error] from ever causing a problem with the Propeller IO pin (which is connected to DIN).

    2) When porting code to the 3202 there is one less mux bit and one less data bit. A few of us have been caught out by the latter. I've recently updated my object 3202 code (in ObEx) to correct this "gotcha."
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-03-15 20:41
    There's a photocell connected between +V and the Ch_0 input.
    I think there should also be a resistor, >> R_dark (220k-470Ω),
    from Ch_0 to GND.
    [Otherwise it's a variable resistor that's always pulled-high/up.]

    PE -- 10k between +V and Ch_0, and the photocell between Ch_0 and GND would be better yet.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-03-15 22:11
    Thanks, dude. It's about time I learn about this stuff.
  • SSteveSSteve Posts: 808
    edited 2011-03-16 00:28
    Something you typed got turned into question marks:

    Screen shot 2011-03-16 at 12.25.02 AM.png


    Click the above image for a legible version. The forum software made it minuscule.

    I checked the page source to see if it was an encoding issue, but they're questions marks there too.
  • groggorygroggory Posts: 205
    edited 2011-03-16 03:11
    PJ Allen wrote: »
    There's a photocell connected between +V and the Ch_0 input.
    I think there should also be a resistor, >> R_dark (220k-470Ω),
    from Ch_0 to GND.
    [Otherwise it's a variable resistor that's always pulled-high/up.]

    PE -- 10k between +V and Ch_0, and the photocell between Ch_0 and GND would be better yet.

    I also see that error. I wonder if GG actually tested his tutorial before posting it? That is kinda a critical flaw in the circuit (from a functionality perspective)
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2011-03-16 07:33
    groggory wrote: »
    I also see that error. I wonder if GG actually tested his tutorial before posting it? That is kinda a critical flaw in the circuit (from a functionality perspective)

    I appreciate the comments and will look at that potential issue. Any circuit published in my material is built and tested before publishing. In this case, an identical breadboard was assembled and used for testing.

    This may be another case (like many I've discovered) where the components are forgiving. It's one of the more interesting things I've found where you can get away with breaking the rules. (Doesn't make the engineers happy, and defies the datasheets, but there it is.)

    Either way, I'll give it a good looking over.

    Thanks Guys
    OBC
  • schillschill Posts: 741
    edited 2011-03-16 07:42
    OBC:

    It probably wouldn't be a bad idea to include a schematic for the circuit in addition to the breadboard and platform pictures.

    Tutorials like this provide a good opportunity for people to start to learn to read schematics since they can compare them to the breadboarded circuit.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-03-16 09:02
    I don't know what's important to you then. It's not component forgiveness, catering to engineer happiness, nor datasheet defiance.
    What does the voltmeter tell you?
    I don't want to be characterised as mean or insensitive or any of that rot, but feel free. If I'm the Antichrist for it then make the most of it.
    If you'd simply preface your stuff as "Doing 'Tronix For Propheads" or "Electronics-free Zone" then that'd be cue enough for me to simply not care. That's not education, it's "doing stuff", but there it is.
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-03-16 09:25
    This may be another case (like many I've discovered) where the components are forgiving. It's one of the more interesting things I've found where you can get away with breaking the rules. (Doesn't make the engineers happy, and defies the data sheets, but there it is.)

    I would suggest that when creating tutorials we are all more stringent lest newbies adopt bad habits that will bite them later.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-03-16 09:51
    The 3208 must be acting as the second half a voltage divider (not in its job discription).

    The circuit should resemble a pot with the wiper connected to the 3208. One leg of the pot should be high and the other low. This way the wiper voltage changes.

    The photo resistor should be connected as if one of its leads is the wiper of a pot. The other lead should be either high or low. A normal reistor is used to make the rest of the voltage divider with one lead acting as a pot wiper and the other connected high or low (but opposite of the photo resitor's second lead).

    I hope that makes sense.

    Jeff, this isn't a "potential issue" it's a "critical flaw" as groggory noted. (That's not supposed to sound a rude as it might.) I think these tutorials are a great idea.

    Duane
  • schillschill Posts: 741
    edited 2011-03-16 10:16
    The 3208 will work as 8 single-ended inputs or 4 pseudo-differential inputs. I wonder if this is an effect of it working in differential mode. I haven't looked at the object in detail (I'm not sure which 3208 object the tutorial is using) to know for sure.

    But, I agree that the resistor needs to be there in the tutorial.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2011-03-16 16:47
    Hmm..

    I've stirred a hornets nest..

    I've been on the road most of the day so I won't get a chance to dissect this until later tomorrow. I'm sure some resistors will find their way into the document.

    OBC
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2011-03-16 17:03
    schill wrote: »
    OBC:

    It probably wouldn't be a bad idea to include a schematic for the circuit in addition to the breadboard and platform pictures.

    Tutorials like this provide a good opportunity for people to start to learn to read schematics since they can compare them to the breadboarded circuit.

    Excellent suggestion! I'll add a link to the datasheet and see if I can generate a schematic as well.

    OBC
  • groggorygroggory Posts: 205
    edited 2011-03-16 19:23
    Duane Degn wrote: »
    The 3208 must be acting as the second half a voltage divider (not in its job discription).

    The circuit should resemble a pot with the wiper connected to the 3208. One leg of the pot should be high and the other low. This way the wiper voltage changes.

    The photo resistor should be connected as if one of its leads is the wiper of a pot. The other lead should be either high or low. A normal reistor is used to make the rest of the voltage divider with one lead acting as a pot wiper and the other connected high or low (but opposite of the photo resitor's second lead).

    I hope that makes sense.

    Jeff, this isn't a "potential issue" it's a "critical flaw" as groggory noted. (That's not supposed to sound a rude as it might.) I think these tutorials are a great idea.

    Duane

    Yep...here's why it works. (from the MCP3208 datasheet)

    mcp3208.png

    The ADC samples with effectively a 1k resistor to ground as its reference point. There's some other hoo ha going on too...but that's the key element on how you got away with that working.

    If you wanted to do a follow up ADC tutorial you could also go into how to convert high impedance sources into low impedance sources so ADC circuits can be used to their full potential with sensors like the flexiforce (and other high impedance sensors).
  • groggorygroggory Posts: 205
    edited 2011-03-16 19:26
    JonnyMac wrote: »
    I would suggest that when creating tutorials we are all more stringent lest newbies adopt bad habits that will bite them later.

    Or follow up tutorials with a series of nodal analysis equations. I love nodal analysis. It does pretty much everything for telling you what a simple circuit will do. And as a bonus, it only requires algebra. :-)
  • SRLMSRLM Posts: 5,045
    edited 2011-03-16 20:49
    Is there a reason why you aren't using the "fast" version of the driver (in obex)? I know it's not necessary in this particular application, but it might be good to let people become familiar (or at least aware) of the other version.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2011-03-16 21:12
    @SRLM:

    I'm using the one which is included in the Propeller Tool. You are right, it should be notated and a link posted.
    I tend to gravitate toward using tools which are already in the hands of the user as much as possible. So while there is an improvement posted in OBEX, anyone who has installed Propeller Tool will have the one I've used by default.

    OBC
  • garylakegarylake Posts: 41
    edited 2011-03-17 08:53
    Jeff,

    What you and Nick are doing with the tutorials is great. Ok, they need a little tweaking, but it is better than nothing. I really appreciate the effort. Don't stop.

    Thanks
    Gary Lake
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2011-03-17 09:29
    Gary,

    Nick and I both have thick skin.. No worries! We both know that positive and critical responses mean readers!

    We are expanding our efforts and continuing forward!

    My approach to learning the Propeller is from the eyes of a beginner, not an EE. I have experience is teaching and instruction so I'm exploiting my unique position to help others who will hopefully enjoy this hobby as much as I am. I dare to make mistakes publicly and learn from them

    What is interesting is that so many times I'm finding so many times the Propeller will allow breaking the rules and still work perfectly and consistently. It appears that the Propeller has spoiled me a little, and I'll have to tighten up the belt so to speak when moving into the Propeller II as well as other less well designed chunks of silicon. :)

    To put ones self out there is a truly challenging act, and I highly recommend it. It is both rewarding and an opportunity to grow. There is an amazing knowledge pool here, I want to encourage others who have the knowledge to take the time to share it! JonnyMac is an excellent example of this.

    If you can write a little, then create a small tutorial for others and post it! If you can speak a little, attend a UPE event and present your project and knowledge!

    OBC
  • groggorygroggory Posts: 205
    edited 2011-03-17 09:53
    My approach to learning the Propeller is from the eyes of a beginner, not an EE.

    I want to recommend you and everyone else who hasn't gone through formal electronics education to buy a read a book... "Practical Electronics for Inventors." It goes over everything from basic theory to AC theory to signals to every type of passive and many types of actives and many common IC's. Then it has lots of common circuits and clear explanations for each.

    The book was required reading at MIT for my friend who got a degree in Aerospace Engineering...which means he wasn't an electronics junkie and they just wanted him to learn enough to get it done and fast!

    This book is the cliff's notes to an EE's knowledge. :-) It's my favorite book when I'm working on electronic stuff and forget how to work say a Triac into my circuit. Or how to work the flip flops and discrete logic the way I want it to. :-)

    Edit: Changed book to 2nd edition
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2011-03-17 11:34
    groggory wrote: »
    I want to recommend you and everyone else who hasn't gone through formal electronics education to buy a read a book... "Practical Electronics for Inventors." It goes over everything from basic theory to AC theory to signals to every type of passive and many types of actives and many common IC's. Then it has lots of common circuits and clear explanations for each.

    The book was required reading at MIT for my friend who got a degree in Aerospace Engineering...which means he wasn't an electronics junkie and they just wanted him to learn enough to get it done and fast!

    This book is the cliff's notes to an EE's knowledge. :-) It's my favorite book when I'm working on electronic stuff and forget how to work say a Triac into my circuit. Or how to work the flip flops and discrete logic the way I want it to. :-)


    Purchased moments ago and added to my reading list!

    OBC
  • schillschill Posts: 741
    edited 2011-03-17 11:44
    Purchased moments ago and added to my reading list!

    It looks like that link is to the first edition. There is a second edition:

    http://www.amazon.com/Practical-Electronics-Inventors-Paul-Scherz/dp/0071452818/ref=tmm_pap_title_0

    It's thicker and heavier but I've never compared the two to see what the differences really are. I have both.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2011-03-17 11:49
    Now you tell me... :)

    I'm sure either will come in handy..

    Now, can I count on you "experts" to assist me in getting this tutorial corrected? :)

    OBC
  • groggorygroggory Posts: 205
    edited 2011-03-17 11:55
    schill wrote: »
    It looks like that link is to the first edition. There is a second edition:

    http://www.amazon.com/Practical-Electronics-Inventors-Paul-Scherz/dp/0071452818/ref=tmm_pap_title_0

    It's thicker and heavier but I've never compared the two to see what the differences really are. I have both.

    My bad. I have the 1st edition. My friend has the 2nd edition. Here were my quick notes between the two.

    The first edition had many hand drawn drawings to go over ideas. The 2nd edition had much more 'professional looking' drawings.
    The second edition had a larger selection of circuits and added some circuits and explanations to certain sections.
    The second edition has many corrections to incorrect formulas.

    I revise my earlier recommendation a bit. Cancel your order and place the order for the 2nd edition book. Good catch Schill.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2011-03-17 12:54
    2nd edition on it's way..

    Thanks
    OBC
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-03-17 14:49
    OBC,

    Parallax's "Robotics with the Boe-Bot" has some information on using a photoresistor in a voltage divider circuit on page 197. Chapter 6 (page 193) is titled "Light Sensitive Navigation with Photoresistors."

    I think the e-book is available for download for free. I'll check. Hang on for a second.

    Here it is http://www.parallax.com/Portals/0/Downloads/docs/books/edu/Roboticsv3_0.pdf

    I just noticed my book is version 2.2. So it might be on a different page.

    Wow! Big difference between versions 2.2 and 3.0. Chapter 6 (page 169) is now titled "Light-Sensitive Navigation with Phototransistors." I think photoresistors aren't ROHM compliant.

    They still use a voltage divider but I don't see the same box explaining what a voltage divider is. Anyway, It could be something to read while you wait for your book.

    Voltage dividers are an important electronics principle.

    I have a pdf file of version 2.2, if anyone whats it and can't find it online.

    Edit: Version 2.2 can be found here http://www.parallax.com/tabid/535/Default.aspx
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-03-17 15:55
    OBC posted, "What is interesting is that so many times I'm finding so many times the Propeller will allow breaking the rules and still work perfectly and consistently."
    I think the interface between the Propeller and the 3208 is fine. But that's not the issue, your "configuration" of the ADC's input is. The ADC's input impedance is forming the other leg of the voltage divider and you get some variation only on account of that. The Propeller is not allowing you to break the rules and to contend otherwise is an unsound inference.

    On the one hand you admit your ignorance, but on the other you flout it. That's amazing.
    The thing is -- there's no priesthood of EEs out to keep you down, stifle your progress, or dampen your spirit, man. To proceed, sometimes a guy has to go with his schema , but when he finds that it's not in keeping with the facts then he must amend it.

    I can understand your passion to evangelise the world to the Propeller, but this isn't the way to do it. If tutorials such as this are to be the Propeller's clarion then its future looks bleak, the road to its oblivion paved by its enthusiasts with such good intentions.

    Have a good day.
Sign In or Register to comment.