{"id":2519,"date":"2012-11-22T11:20:40","date_gmt":"2012-11-22T15:20:40","guid":{"rendered":"http:\/\/www.paleotechnologist.net\/?p=2519"},"modified":"2012-11-22T11:20:40","modified_gmt":"2012-11-22T15:20:40","slug":"basic-stamp-board-review","status":"publish","type":"post","link":"https:\/\/www.paleotechnologist.net\/?p=2519","title":{"rendered":"BASIC Stamp board review"},"content":{"rendered":"<p>While browsing through a local Radio Shack the other day, I noticed some BASIC Stamp boards in stock. Since new dev boards are always interesting &#8212; and since I&#8217;ve been programming in BASIC since the <del>days of the dinosaurs<\/del> early &#8217;80s, I decided it was time I tried one. I certainly like microcontrollers, and for better or worse, BASIC is still my &#8220;native&#8221; programming language. A BASIC Stamp board is therefore a no-brainer, right?<\/p>\n<p>Well, yes and no&#8230;<\/p>\n<p><strong>Setup:<\/strong><\/p>\n<p>Physical setup of the board is pretty straightforward. To save on cost and packaging, no software is included; you download it from Parallax&#8217;s site. Bonus points for environmental responsibility: check.<\/p>\n<div id=\"attachment_3052\" style=\"width: 610px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.paleotechnologist.net\/wp-content\/uploads\/2012\/11\/package.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3052\" class=\"size-full wp-image-3052\" title=\"Just enough to get started -- but don't forget the 9V battery!\" src=\"https:\/\/www.paleotechnologist.net\/wp-content\/uploads\/2012\/11\/package_sm.jpg\" alt=\"\" width=\"600\" height=\"782\" \/><\/a><p id=\"caption-attachment-3052\" class=\"wp-caption-text\">The BASIC Stamp 2 &quot;Home Work Board USB&quot; in its package. (Click for larger.)<\/p><\/div>\n<p>Unfortunately, Parallax&#8217;s site doesn&#8217;t have a very intuitive process for locating the board drivers. The directions on the package steer you to www.parallax.com\/rt (which I won&#8217;t link to and add to the confusion), but that page just offers vaguely-helpful instructions on how to find your product number and type it in. Doing so lets you locate the product page for the specific board you have. Hunting around on <em>that <\/em>page turns up a link to Parallax&#8217;s common software download page for most or all of their BASIC stamp boards (begging the question, why did I have to enter in the product number??)<\/p>\n<p>Once you locate the <a href=\"http:\/\/www.parallax.com\/basicstampsoftware\" target=\"_blank\">BASIC Stamp software download page<\/a>, things fortunately get a lot easier. The page has an easy, obvious &#8220;1-2-3&#8221; chart front and center. Nice! Click on the first link, install the software, and connect up the board. Simple.<\/p>\n<div id=\"attachment_3065\" style=\"width: 610px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.paleotechnologist.net\/wp-content\/uploads\/2012\/11\/Board.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3065\" class=\"size-full wp-image-3065\" title=\"It comes with everything except software. Well, that and a 9-volt battery.\" src=\"https:\/\/www.paleotechnologist.net\/wp-content\/uploads\/2012\/11\/Board_sm.jpg\" alt=\"\" width=\"600\" height=\"800\" \/><\/a><p id=\"caption-attachment-3065\" class=\"wp-caption-text\">The box contains the board, a cable, jumper wires, and non-skid feet. (Click for larger.)<\/p><\/div>\n<p>Download the software? Check.<\/p>\n<p>Run the installer? Check.<\/p>\n<p>Plug in the device? Check. (The USB drivers loaded nicely on \u00a0Windows 7\/64bit.)<\/p>\n<p>Launch the software? Check.<\/p>\n<p>Run examples? <em>Uh oh.<\/em> Unlike the easy &#8220;Examples&#8221; menu in the <a href=\"http:\/\/www.arduino.cc\/\" target=\"_blank\">Arduino IDE<\/a>, Parallax&#8217;s Basic Stamp Editor software starts up with its default directory in C:\\Windows. This is not only useless (that&#8217;s not where the examples are or where your programs ought to go) &#8212; but potentially dangerous if people start digging around in the Windows directory structure. These boards are marketed to primary and secondary-school students, and this is asking for trouble.<\/p>\n<p>Guessing that the correct location was in the &#8220;Program Files (x86)\\Parallax&#8221; directory (it was), I soon was in more or less the right place. The next challenge was to determine which version of BASIC stamp the board had. This, again, wasn&#8217;t specified. A quick check of the packaging turned up a reference to a &#8220;BASIC Stamp 2 chip,&#8221; so I went with that. (The actual chip turns out to be <a href=\"http:\/\/www.microchip.com\/wwwproducts\/Devices.aspx?dDocName=en010206\" target=\"_blank\">a garden-variety PIC<\/a>, presumably with special firmware.)<\/p>\n<p style=\"text-align: center;\">&nbsp;<\/p>\n<div id=\"attachment_3055\" style=\"width: 610px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.paleotechnologist.net\/wp-content\/uploads\/2012\/11\/PIC16F57.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3055\" class=\"size-full wp-image-3055 \" title=\"At this point, I'm wondering if I should have just stuck a 16F88 on the board and fired up MPLab. (That's a Microchip Serial EEPROM at lower left, too, by the way.)\" src=\"https:\/\/www.paleotechnologist.net\/wp-content\/uploads\/2012\/11\/PIC16F57_sm.jpg\" alt=\"\" width=\"600\" height=\"450\" \/><\/a><p id=\"caption-attachment-3055\" class=\"wp-caption-text\">The star of the show turns out to be a Microchip PIC16F57. (Click for larger.)<\/p><\/div>\n<p>I fired up a random example from the &#8220;BS2&#8221; folder &#8212; a &#8220;connection test&#8221; program. It ran, but reported no boards found (even though the board&#8217;s lights blinked when programming it.) I tried a few more examples with the same result &#8212; no board found.<\/p>\n<p>At that point, I decided to try applying 9V to the battery terminals, theorizing that the board didn&#8217;t get its power from USB (like the Arduino boards do.) This worked, and the board was soon running the connection-test example correctly.<\/p>\n<p><strong>Programming<\/strong><\/p>\n<p>I loaded up another example &#8212; &#8220;HIGH_LOW.BS2&#8221; &#8212; and ran it. A LED that I had connected between P0 and Ground blinked dutifully at 1Hz. Success. I modified the delay times to 100ms instead of the default 500ms, and the LED was soon blinking at 5Hz. So far, so good.<\/p>\n<p><strong>Performance<\/strong><\/p>\n<p>I decided to see what the board could do with the throttle wide open. I commented out the &#8220;pause&#8221; lines (the board&#8217;s dialect of BASIC uses the usual apostrophe-for-comment convention), and re-ran the program. The LED came on dimly (as expected), and the oscilloscope showed a high-frequency output.\u00a0Dialing in the &#8216;scope readout showed an output at roughly 1.775kHz, with a 25% duty cycle.<\/p>\n<div id=\"attachment_3057\" style=\"width: 610px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.paleotechnologist.net\/wp-content\/uploads\/2012\/11\/1775Hz.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3057\" class=\"size-full wp-image-3057\" title=\"GOTO commands in PIC assembly take two instruction cycles, so the 25% duty cycle is more or less expected. But how fast is it running...?\" src=\"https:\/\/www.paleotechnologist.net\/wp-content\/uploads\/2012\/11\/1775Hz_sm.jpg\" alt=\"\" width=\"600\" height=\"450\" \/><\/a><p id=\"caption-attachment-3057\" class=\"wp-caption-text\">The output from a simple &quot;high, then low, then repeat&quot; program. (Click for larger.)<\/p><\/div>\n<p>Writing this code in native PIC assembly would produce the same 25% duty cycle: One instruction would be needed to raise the output; one more would lower it, and a &#8220;GOTO&#8221; instruction to loop back to the beginning would take two cycles (due to the way the PIC uses a simple two-stage pipeline to execute code.)<\/p>\n<p>A PIC clocked at 8MHz would execute code at two million instructions per second (2 MIPS), counting GOTOs and such as two instructions. If this high\/low\/repeat code were written in assembly, it would take four instruction cycles to execute, resulting in one cycle every two microseconds, or a frequency of 500kHz. The observed frequency, by comparison, is some <strong>two hundred eighty times slower<\/strong> than this theoretical maximum.\u00a0(&#8230;and most PICs, including the 16F57, can run much faster than 8MHz if need be.)<\/p>\n<p>That&#8217;s not merely slow &#8212; that&#8217;s <em>glacial!<\/em> <a href=\"https:\/\/www.paleotechnologist.net\/?p=1808\" target=\"_blank\">Even the Arduino executes naive C++ code faster than that<\/a>. Unless the PIC is being clocked extraordinarily slowly, either it&#8217;s running the BASIC code as an interpreter (a bad idea), or the compiler is very inefficient.<\/p>\n<p>This calls for more investigation, but my guess is that performance is not high on the priority list for the BASIC Stamp.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Radio Shack stores now carry BASIC Stamp boards. I got one and tried it out&#8230; <a href=\"https:\/\/www.paleotechnologist.net\/?p=2519\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"footnotes":""},"categories":[236,216,210,238,211,381,225],"tags":[],"class_list":["post-2519","post","type-post","status-publish","format-standard","hentry","category-basic","category-coding","category-digital","category-electronics","category-pic","category-reviews","category-toys"],"_links":{"self":[{"href":"https:\/\/www.paleotechnologist.net\/index.php?rest_route=\/wp\/v2\/posts\/2519","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.paleotechnologist.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.paleotechnologist.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.paleotechnologist.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.paleotechnologist.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2519"}],"version-history":[{"count":22,"href":"https:\/\/www.paleotechnologist.net\/index.php?rest_route=\/wp\/v2\/posts\/2519\/revisions"}],"predecessor-version":[{"id":3068,"href":"https:\/\/www.paleotechnologist.net\/index.php?rest_route=\/wp\/v2\/posts\/2519\/revisions\/3068"}],"wp:attachment":[{"href":"https:\/\/www.paleotechnologist.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2519"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.paleotechnologist.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2519"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.paleotechnologist.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}