{"id":1758,"date":"2013-04-25T14:57:29","date_gmt":"2013-04-25T22:57:29","guid":{"rendered":"http:\/\/pididu.com\/wordpress\/?p=1758"},"modified":"2016-06-06T06:45:21","modified_gmt":"2016-06-06T14:45:21","slug":"picaxe-embedded-processor","status":"publish","type":"post","link":"http:\/\/pididu.com\/wordpress\/blog\/picaxe-embedded-processor\/","title":{"rendered":"PICAXE embedded processor"},"content":{"rendered":"<figure id=\"attachment_1759\" aria-describedby=\"caption-attachment-1759\" style=\"width: 640px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/pididu.com\/wordpress\/wp-content\/uploads\/2013\/04\/boost.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-1759\" title=\"PICAXE set up as boost switching regulator\" alt=\"PICAXE boost swtiching regulator\" src=\"http:\/\/pididu.com\/wordpress\/wp-content\/uploads\/2013\/04\/boost.jpg\" width=\"640\" height=\"545\" srcset=\"http:\/\/pididu.com\/wordpress\/wp-content\/uploads\/2013\/04\/boost.jpg 640w, http:\/\/pididu.com\/wordpress\/wp-content\/uploads\/2013\/04\/boost-100x85.jpg 100w, http:\/\/pididu.com\/wordpress\/wp-content\/uploads\/2013\/04\/boost-300x255.jpg 300w, http:\/\/pididu.com\/wordpress\/wp-content\/uploads\/2013\/04\/boost-352x300.jpg 352w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><figcaption id=\"caption-attachment-1759\" class=\"wp-caption-text\">The PICAXE 20M2 is the black chip at the upper left of the breadboard. There is an onboard pulse width modulator, and onboard A\/D converter, so it was easy to make a switching regulator out of it. There were extra I\/O pins left over, so I&#8217;m driving a multiplexed LED display.<\/figcaption><\/figure>\n<p>A couple months ago, I discovered the PICAXE embedded processor. It&#8217;s supposed to be designed as an educational tool, but I&#8217;m realizing that the chip is <strong>so versatile<\/strong>, I can make it do real work. Here is basically what is on the chip:<\/p>\n<ul>\n<li>PIC processor that runs at 32 MHz<\/li>\n<li>Oscillator with resonator (no external components)<\/li>\n<li>2048 bytes of FLASH for program<\/li>\n<li>512 bytes of RAM<\/li>\n<li>256 bytes of non-volatile EEPROM<\/li>\n<li>RS-232 UART, through which device can be programmed<\/li>\n<li>Sixteen programmable I\/O pins<\/li>\n<li>Precision voltage reference<\/li>\n<li>Eleven 10-bit Analog to Digital converters, which can also be used as touch sensors<\/li>\n<li>Digital to Analog converter<\/li>\n<li>Pulse width modulator<\/li>\n<li>BASIC interpreter built-in<\/li>\n<li>Keyboard interface<\/li>\n<li>i2c interface<\/li>\n<li>one-wire bus interface<\/li>\n<li>infrared interface<\/li>\n<li>music generator with tunes<\/li>\n<\/ul>\n<p>And the development platform, including simulator, is free. So basically, for about $3, you just connect this thing to your serial port, and away you go. It&#8217;s like an Arduino board, only all on one chip, and cheaper. Did I mention that it can run multiple tasks? Unbelievable.<\/p>\n<p>I have several projects planned for the PICAXE. One is the power transfer controller for my <a title=\"Roderick's solar bicycle project\" href=\"http:\/\/pididu.com\/wordpress\/solarbike\/\" target=\"_blank\">solar bicycle<\/a>. \u00a0Watch this space for other projects, one of which will incorporate the stepper below.<\/p>\n<p><iframe loading=\"lazy\" src=\"http:\/\/www.youtube.com\/embed\/8EiTmpyozDI?rel=0\" height=\"315\" width=\"420\" allowfullscreen=\"\" frameborder=\"0\"><\/iframe><\/p>\n<p>Here is the program, if anyone is interested:<\/p>\n<pre>; try stepper motor\r\n; outputs\tC.0 = A (white)\r\n;\t\tC.1 = B (red)\r\n;\t\tC.2 = ~A (green)\r\n;\t\tC.3 = ~B (brown)\r\n;\r\n; inputs C.7 = CCW button\r\n;        C.6 = CW button\r\n;        C.5 = START button\r\n\r\n; comipler directives only apply to PICAXE programming editor\r\n; #com 1\r\n#picaxe 20m2\r\n#no_data\t\t; do not bother to download EEPROM data\r\n\r\nsymbol\tStepValue = b0\r\nsymbol\tDrivePattern = b1\r\nsymbol\tStepMask = 7\t\t; =3 for 4 step pattern, =7 for 8-step\r\n\r\n; Initialize\r\n\tpinsB = %10000000\r\n\tdirsB = %10000000\t\t; for debug, drive LED's too\r\n\tpinsC = %00000000\r\n\tdirsC = %00001111\r\n\tpullup $E000\t; 3 input buttons\r\n\tStepValue = 0\r\n\r\nmain:\r\n;\r\n; Do some manual positioning\r\n;\r\n\tbutton C.7, 0, 10, 1, b3, 0, SkipCCW\r\n\t\t; increment by one ccw\r\n\t\tStepValue = StepValue + 1 and StepMask\t; count up modulo 4\r\n\t\tcall StepMotor\r\nSkipCCW:\r\n\tbutton C.6, 0, 10, 1, b4, 0, SkipCW\r\n\t\t; decrement by one cw\r\n\t\tStepValue = StepValue - 1 and StepMask\t; count up modulo 4\r\n\t\tcall StepMotor\r\nSkipCW:\r\n\tbutton C.5, 0, 10, 2, b5, 1, RunMotor\r\n\tpause 100\r\n\tgoto main\r\n\r\nRunMotor:\r\n\tfor b4 = 1 to 2\r\n\r\n\t\tfor b3 = 1 to 100\r\n\t\t\tStepValue = StepValue + 1 and StepMask\t; count up modulo 4\r\n\t\t\tcall StepMotor\r\n\t\t\tpause 1\t; pulse for 1 mS\r\n\t;\tpinsC = 0\t; turn off for a moment - can only do with single phase\r\n\t;\tpause 500\r\n\t\tnext b3\r\n\r\n\t\tfor b3 = 1 to 100\r\n\t\t\tStepValue = StepValue - 1 and StepMask\t; count up modulo 4\r\n\t\t\tcall StepMotor\r\n\t\t\tpause 1\t; pulse for 1 mS\r\n\t\tnext b3\r\n\r\n\tnext b4\r\n\r\n\t; turn coils off to save power\r\n\tpinsC = $0\r\n\r\n\tgoto main\r\n\r\n; advance motor one to match StepValue\r\nStepMotor:\r\n\tlookup StepValue, (%0011, %0010,%0110, %0100,%1100, %1000,%1001,%0001), DrivePattern\t; half-step\r\n;\tlookup StepValue, (%0011, %0110, %1100, %1001), DrivePattern\r\n;\tlookup StepValue, (%0001, %0010, %0100, %1000), DrivePattern\r\n\tpinsC = DrivePattern\r\n\treturn<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A couple months ago, I discovered the PICAXE embedded processor. It&#8217;s supposed to be designed as an educational tool, but I&#8217;m realizing that the chip is so versatile, I can make it do real work. Here is basically what is on the chip: PIC processor that runs at 32 MHz Oscillator with resonator (no external &hellip; <a href=\"http:\/\/pididu.com\/wordpress\/blog\/picaxe-embedded-processor\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">PICAXE embedded processor<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[204,66,166],"tags":[56],"_links":{"self":[{"href":"http:\/\/pididu.com\/wordpress\/wp-json\/wp\/v2\/posts\/1758"}],"collection":[{"href":"http:\/\/pididu.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pididu.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pididu.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/pididu.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1758"}],"version-history":[{"count":0,"href":"http:\/\/pididu.com\/wordpress\/wp-json\/wp\/v2\/posts\/1758\/revisions"}],"wp:attachment":[{"href":"http:\/\/pididu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1758"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pididu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1758"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pididu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1758"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}