Here follow a number of code contributions (snippets or small projects) to the PICAXE and ZBASIC user forums that may be of use for or provide inspiration to others:
- PICAXE M2 variants: Fast spike detection (and programmable noise canceler): This approach allows to detect very fast spikes (optionally: above a certain noise level) using an interrupt (much faster than the Picaxe's polled interrupt system generally can, since in that case they are only recognized when occurring exactly in between Basic commands), and probably equally fast as the hardware X2 interrupts. It uses the SR-Latch bit as a memory which is set active by the spike, subsequently the latch output generates a polled interrupt.
- PICAXE M2 variants: "Non-Interruptible Pause": This example code shows how in an interrupt-driven program a pause functionality of one or multiple seconds can be implemented (since normally an interrupt will cause an executing PAUSE command to directly finish without completion). The example shown here allows interrupts to be used to collect information in a given time interval. The M2's free-running timer is used to implement an "non-interruptable", one-second pause.
- PICAXE M2 variants: Accessing comparators on the PICAXE-18M2: The PICAXE M2 variants have one or two independent comparators (see Microchip's datasheet) which, although not directly supported by the COMPSETUP command like with the X2 variants, nevertheless can be configured with the same flexibility through direct POKESFR and PEEKSFR register operations. The example code is for an 18M2.
- Small PICAXEs (08M2 & 08M): Single-paper Picaxe-08M(2) programming quick reference (including troubleshooting): Not so much of a code snippet, more of a "documentation snippet". Presented is a single-paper overview of the main programming concepts (symbols, registers, most important commands, picaxe pinout and troubleshooting) for a 08M(2). It may serve well in the class room as a quick reference and help guide, I have been using it to give my middle and youngest sons an introduction to Picaxe. MS-Word version available for download to tailor to one's specific needs/opinions. This contribution was motivated by Manuka's "cheat sheet" concept.
- MicroBot (BOT120): asynchronous RC control using interrupt on IR receiver input: Here is a small change suggestion regarding the mounting of the IR receiver extension to the popular MicroBot (BOT120), which may make the use of IR remote control of this bot much more flexible, simply by changing the mounting position of the IR receiver. It then becomes possible to implement real asynchronous remote control by using an interrupt (active low) on this input. As a result the Microbot does not have to wait for input from the RC but can in its main body program do all kinds of useful things continuously and will at the same time react immediately whenever a RC key is pressed.
- Any combination of PICAXE-types: Automatic Clock Frequency calibration/finetuning: The two code snippets given here (for a master and a slave Picaxe, connected to each other via a 1K or larger resistor) cause the slave node internal resonator frequency to get aligned with the master node's frequency.
- PICAXE-18X: This code shows how on the highly configurable PICAXE-18X any of the output pins can be converted to input pins (logical), or two of the output pins to ADC inputs, effectively allowing a maximum of 5 ADC channels on the 18X: Converting 18X output pins to inputs (logical or ADC)
Presented here are a number of OO classes which provide a high-level ZBasic interface for exporting/importing data (arrays or matrices with floats) directly to/from MS-Excel using the Parallax PLX-DAQ macro. In this way a quick-and-dirty method is available for exporting and importing arrays of floating-point data (real-time or stored data after a datalogging session) including string-based annotation information to and from an MS-Excel worksheet in a standardized format. Individual worksheet cells can be managed (strings, floats) directly as well. No programming at the PC side is required. As a result, simple annotated graphs can be produced directly from logged data, and even a Excel worksheet-based interactive user interface can be built with very little effort.
- Project showcase: A Mahjong points calculating device, for automating the booring points roundup in this interesting family game
Here follows a functioning test program for the popular SCP1000 barometric pressure and temperature sensor (SPI interface variant based on SparkFun Breakout Board).
- Use of the FirstTime library function to provide a start-up message a limited number of times after download.