{"id":59,"date":"2004-05-24T09:32:48","date_gmt":"2004-05-24T14:32:48","guid":{"rendered":"http:\/\/www.tigoe.com\/pcomp\/code2\/category\/picbasic-pro\/59"},"modified":"2007-08-07T22:33:17","modified_gmt":"2007-08-08T03:33:17","slug":"analog-in-using-rctime","status":"publish","type":"post","link":"https:\/\/www.tigoe.com\/pcomp\/code\/picbasic-pro\/59\/","title":{"rendered":"Analog in using RCTIME"},"content":{"rendered":"<p><P>The RCTIME command is used to obtain a varying number from the charge or discharge of a capacitor in a resistor-capacitor circuit.   The PWM command produces a modulated pulse on an oputput pin to simulate a varying voltage.  The FREQOUT command pulses a frequency on the given pin.<\/P><br \/>\n<!--more--><\/p>\n<pre>\n' there is a variable resistor-capacitor circuit on pin 7, a speaker circuit on pin 8, \n' and an LED on pin 0, and an LED on pin 3 for this program:\n\npwrLED    con    0\nLED2    co   3\npotPin    con    7\nspkrPin    con    9\n    \n' declare variables:\npotVar    var    word    ' a word-sized variable to hold the results of the RCTIME command\nbyteVar    var    byte    ' a byte-sized variable that will vary proprtional to potVar\noutput pwrLED        'light an LED on pin 8\n\nhigh pwrLED'just so we know the stamp's working\n\nmain:\n    high potPin'put voltage out to the capacitor\n    pause 1    'hold a millisecond (0.4 ms on the BS2-SX)\n    rctime potPin, 1, potVar    'time how long the cap takes to discharge\n    debug ?potVar    \n    byteVar = potVar \/3        'convert potvar to a smaller number\n    pwm LED2, byteVar, 10        'output a varying voltage based on bytevar\n    freqout spkrPin,10,byteVar*50    'make a varying sound on the speaker\n    debug  ?byteVar\ngoto main\n<\/pre>\n<p><P>Schematic: <\/P><br \/>\n<P><IMG src=\"\/pcomp\/img\/analogio.gif\" width=\"572\" height=\"591\"><\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The RCTIME command is used to obtain a varying number from the charge or discharge of a capacitor in a resistor-capacitor circuit.  The PWM command produces a modulated pulse on an oputput pin to simulate a varying voltage.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-59","post","type-post","status-publish","format-standard","hentry","category-picbasic-pro"],"_links":{"self":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/posts\/59","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/comments?post=59"}],"version-history":[{"count":0,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/posts\/59\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/media?parent=59"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/categories?post=59"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/tags?post=59"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}