{"id":45,"date":"2011-10-14T11:51:02","date_gmt":"2011-10-14T11:51:02","guid":{"rendered":"http:\/\/www.electronic-products-development.com\/?p=45"},"modified":"2024-03-07T16:54:14","modified_gmt":"2024-03-07T16:54:14","slug":"atod-conversion","status":"publish","type":"post","link":"https:\/\/ibex.tech\/c\/c\/atod\/atod-conversion","title":{"rendered":"AtoD conversion"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Converting Direct Voltage Value<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\t\/\/GET VOLTAGE\n\t\/\/Vref = 3.3V\n\t\/\/12bit AtoD = 0 to 4095\n\t\/\/4095 = 3.3V\n\n\tdouble d_temp;\n\td_temp = (((double)3.3 \/ 4095) * atod_buffer_0);\n\n\tuint16_t voltage_mv;\n\tvoltage_mv = (uint16_t)((((double)3.3 \/ 4095) * atod_buffer_0) * 1000);<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Converting Based On A Voltage Reference Reading<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\t\/\/int VrefAtodValue = AtoD reading for 2.5V Vref input\n\t\/\/int PsuVoltageAtodValue = AtoD reading for another AtoD input we want to be be accurate\n\t\n\t\/\/Get PSU voltage in mV (int x 1000) (e.g. 5000 = 5.000V)\n\tuint16_t PsuVoltageMv = (((double)2.5 \/ VrefAtodValue) * PsuVoltageAtodValue * 1000);<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Converting Voltage Value After Potential Divider Resistors<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\t\/\/Vref = 3.3V\n\t\/\/12bit AtoD = 0 to 4095\n\t\/\/4095 = 3.3V\n\n\t\/\/Potential divider input:- Vin -> 39K -> AtoD -> 100K -> Gnd\n\t\/\/Total resistance = 139\n\t\/\/To Gnd resistance = 100\n\n\t\/\/Result as a double:\n\tdouble dTemp;\n\tdTemp = ((((double)3.3 * ((double)139 \/ 100)) \/ 4095) * AtodBuffer0);\n\n\t\/\/Result as an int:\n\tuint16_t voltage_mv;\n\tvoltage_mv = (uint16_t)(((((double)3.3 * ((double)139 \/ 100)) \/ 4095) * AtodBuffer0) * 1000);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Converting Direct Voltage Value Converting Based On A Voltage Reference Reading Converting Voltage Value After Potential Divider Resistors<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-45","post","type-post","status-publish","format-standard","hentry","category-atod"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/posts\/45","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/comments?post=45"}],"version-history":[{"count":10,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/posts\/45\/revisions"}],"predecessor-version":[{"id":1526,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/posts\/45\/revisions\/1526"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/media?parent=45"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/categories?post=45"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/tags?post=45"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}