Hardware
Apple Hardware
Fix or Upgrade Apple hardware including iPhone.
MACTech the news
MACTech is a very active and excellent source of Macintosh information, covering a wide range of issues, including up-to-date news, and Macintosh and Windows integration.
PIC your AXE
For those wanting to find an easy introduction to microprocessors that are
- cheap - of the order of $10 or less
- powered from batteries (3 x AAA cells works even during programming)
- programmed easily and reliably - with a USB cable or serial cable
- programmed using a Macintosh or PC using readily available free software
- programmed in a very simple version of BASIC (control basic)
The result is a standalone microcontroller that can be used in many projects. There used to be a free book available from MicroZed (Australian Distributor). called "Getting Started", but it appears to be no longer available. The simplest project I've seen is a LED flasher (producing the Morse Code message "HELLO"). The most complicated project controlled by a PICAXE chip I've seen so far is a dual channel 1 Ms/s oscilloscope that feed the serial data stream to a computer.
These could be suitable for upper primary schools students or high school students. Sources of information:
- MicroZED the Australian Distributors are helpful and efficient in supplying parts
- The Revolution Ed site contains a huge amount of information and the free software.
The PICAXE range has also been featured in a number of articles in different magazines around the world including Australia. Well worth a look.
Another range of products that are very similar, but aimed at high school students and college students is from Parallax.
Micro-controllers: Low cost hardware and Open Source applications
The Arduino platform is an excellent alternative to the PICAXE platform depending upon your requirements and ability. The twee concepts look similar but in fact are quite different.
The proprietary PICAXE is designed to work with a particular bare micro-controller chip with an onboard boot loader that you cannot alter. The processors can be made to run at 4, 8, 20 MHz.
Your program is constructed on a Mac or PC (with much better PC support than Mac support). The program is a simplified version of BASIC called Control PICAXE BASIC. The program is compressed and then copied into EEPROM on the PICAXE micro-controller. In this respect it is very similar to the Parallax Stamp approach. There is limited support for variables, and for interpreting the function of pins. It would form the basis of an excellent introduction to industrial control systems. Although a relatively simple system, including what's required for programming, it is extremely reliable.
The Arduino platform is different. Firstly the design is open source, and the application called Arduino that is used to develop programs and load them into the Arduino micro controller hardware is based on C and C++. The latest version even supports namespaces. The programming development interface looks the same on the PC as on a Mac and the latest versions of reference designs can be directly connected to a PC or Mac using USB.
The communications baud rate, unlike the PICAXE is not limited to low speeds allowing the ATMEL processor to work at much higher speeds. The processor works at 16 MHz. The second major difference is how Arduino uses the on chip RAM/ FlashRAM. Programs are compiled to native ATMEL code, which means the user programs loaded into the Arduino are running at native code speed rather than interpreted speed.
Some Arduino modules have sufficient memory to have a small real time operating systems loaded for true multitasking. In some ways the Arduino platform is easier to use than the PICAXE system and is gaining in popularity because of the amount of free software, and relatively cheap "break out boards" called Arduinio shields, that allow easy connection between boards WITHOUT SOLDERING.
A German initiative called Fritzing provides a very nice design development environment, including producing a neatly laid out circuit diagrams and a circuit board printed circuit board pattern. Interestingly, you start by designing your circuit in a semi-pictorial format, based on a "breadboard" and Arduino module image.
The Fritzing application is free, open source and also includes many common components in its library including PICAXE components. It would be an excellent companion to the Arduino software development environment and the PICAXE software environment. The application produces images that can be used to construct printed circuit boards.
Micro-controllers for the young and/or not so technical
The Arduino platform has a very active world wide community. One of the original intentions of the Arduino project was to bring computer technology to non-technical people.One interesting offshoot is the EduWear and Amici community that aims to continue to spread the word about micro-controllers/ microcomputers. Their focus is on wearable " intelligent" clothing and soft toys as a vehicle for introducing young people to computer technology.
To help novices, especially children, learn about (by doing) computing they are promoting the development of wearable garments and soft toys with embedded "intelligence", by using melded aspects of the MIT effort "Scratch" -basically the icon based construction of programs, with the Arduino "Sketch" integrated development environment(IDE).
The support site is actively supported, and they have produced some projects that would be interesting to younger students, 10+ years. There is an active Australian community as well as several Australian vendors such as Freetronics and Little Bird Electronics with products that could support this initiative in upper primary and high schools.
Arduino Meets the Mac
How does the Mac implement serial port access?
Some low level system software exists in the Mac OS X distribution (actually part of Unix) To get a functional serial port you will need an appropriate USB2Serial port driver: there really are only 2 common USB to Serial chips now used: FTDI-232 and Prolific PL-2303. You can install both drivers without interference. The most common now is the FTDI chipset. Arduino Uno and variants used the FTDI chip, but the latest Arduino modules use an AVR controller with internal USB interface hardware.
Software drivers are needed by all serial port applications and are not pre-installed.
(i) Attach an Arduino via a USB cable. That's it. The bare Arduino can be powered and controlled via the USB port.
(ii) Download a serial port access application and run it. The easiest and most useful is the Arduino IDE.
The application will enumerate the serial ports it sees. If you don't understand what that means then go to each of the sites below and read what they say. Each emphasises a different aspect.
The *really powerful* aspect of all of this comes about when you can use AppleScript to communicate with serial port protocol devices like the Arduino.
Serial Port Applications to connect an Arduino to a Macintosh
(i) Use AppleScript and SerialPort X OSAX
AppleScript help with serial port access
(ii) Use the Arduino IDE which has a built-in Serial Port Comms function and effectively is an integrated set of software tools organised as a tool chain. Very, very easy to use and obviously designed for the Arduino.
(iii) Use CoolTermMac, a dedicated Serial Port Terminal application. It is AppleScriptable!
(iv) Use Serial Tools which is a set of serial port tools for Mac OS X. It is as object code version and open source code version. This app is capable of internally looping serial data to "sniff" the data stream for testing purposes.
Some other specific resources
Ashley Hughes connects an Arduino to a Macintosh using ColTermMac
A mini tutorial on connecting an Arduino to a Mac
Mac OS X 10.4 and 9-Pin RS-232 Serial interfaces
More details can be found at AppleScripting -SerialPort
Simulation of simple logic circuits- ICT, Physics, Software Design and Development
Note: 2010-10-25 it appears as from MacOS X 10.6.5 Java is deprecated (updates will not be supplied by Apple).
For all those people wanting access to Carl Burch's very interesting AND easy to use simple logic simulator look at LogicSim It has a number of features that makes it very "student friendly". The best features are that you can modify a live circuit and it will show errors in silly designs.
Another interesting version is Andreas Tetzl LogicSim written in Java. Not as well developed as Carl Burch's, but is reasonably easy to use and is open source. Has all of the basic gates and memory elements. Will allow you to deploy it as a Java Applet. This means that you could easily use it in a class with students accessing it through a Web Browser. This capability means that you could integrate it with web based learning materials.
And still another interesting version. This one is relatively simple (as the freeware version) and features images of the components as well as schematic symbols. It is worth a look at http://sol.gfxile.net/atanua/index.html.
Update: 2012-02-01 An application called iCircuit available through Apple's App Store has just been upgraded- it HAD a nasty habit of slowing to a crawl after a few minutes. it is NOW an excellent Integrated Development Environment(IDE) for interactively constructing and observing electronic circuits. You could develop a whole introductory course in electronics around it. iCircuit's state observation functions are excellent; Multiple Waveforms, Voltage, Current, Power, Resistance even for pieces of wire! Circuits can be made by selecting components via a "pick and place" library. What makes this app different from many other simulations is that all of this can be done live, while the simulation is running. It's the nearest thing I've seen to the concept of "building an aeroplane in flight". I've recently used it to effectively design a simple Interface for an Arduino where there was a current budget of less than 150 mA. Really worth a look.
AppleScripting (Real) Objects
One day, instruments like the relatively cheap Dick Smith Electronics Multimeter (DSE-Q1473) may carry on a limited conversation with a user, such as when configuring and reporting results. With an embedded accelerometer, picking it up will initiate activation. Here is one example of how AppleScript could be used to implement some kind of embedded intelligent object behaviour. Of course, this proof of concept runs on Mac OS X and can't be connected to the meter in question, but the code demonstrates a tiny part of the principle.
The idea is to design and use a higher level command language. Intelligent behaviour, is to some extent, based on the ability to keep abstracting and chunking lower level concepts and concrete actions.
The abstract commands given are: setup(), become_DCvolt_meter(), become_ACvolt_meter(), become_Ohm_meter(), become_Continuity_meter(), become_Frequency_meter(), ident(). Each of these sets appropriate fields in a record, including an <instruction:> field. For interest, we add a voice reporting to the ident() command.
The next step... connect to an applescript fragment that implements voice recognition.
-- 2008 Ian W. Parker
-- define characteristics of measuring instrument: electrical meter, take model as DSE Q1473
-- first worked on: 2008-01-19 last worked on 2008-06-17
set Meter_1 to define_device({title:"Meter-" & "DSE-Q1473"})
tell Meter_1
setup() -- initialise
become_DCvolt_meter() -- for testing continuity
ident() -- report configuration
end tell
on define_device(aName)
script buildDevice
property settings_1 : {SelectRotation:"OFF"}
property settings_2 : {SelectButton:" ", RelativeButton:"", DataHoldButton:"", HzDutyButton:""}
property settings_3 : {info:""}
property settings_4 : {instruction:""}
property settings : settings_1 & settings_2 & settings_3 & settings_4
--
on setup() -- reconstruct basic parameters and initial situation
set SelectRotation of my settings to "OFF"
set SelectButton of my settings to " "
set RelativeButton of my settings to ""
set DataHoldButton of my settings to ""
set HzDutyButton of my settings to ""
set info of my settings to "ready"
set instruction of my settings to ""
end setup
--
on become_DCvolt_meter()
set SelectRotation of my settings to "DCV"
set instruction of my settings to "To make me into a D C voltmeter, left rotate selector to, OFF. Right rotate selector one click"
end become_DCvolt_meter
--
on become_ACvolt_meter()
set instruction of my settings to "To make me into an A C meter, left rotate selector to, OFF. Right rotate selector two clicks"
set SelectRotation of my settings to "ACV"
end become_ACvolt_meter
--
on become_Ohm_meter()
set instruction of my settings to "To make me into a resistance meter, left rotate selector to OFF. right rotate selector three clicks"
set SelectRotation of my settings to "Ω"
set SelectButton of my settings to "Ω"
end become_Ohm_meter
--
on become_Continuity_meter()
set instruction of my settings to "To make me into a continuity meter, left rotate selector to, OFF. Right rotate selector three clicks, then twice press select button"
set SelectRotation of my settings to "Ω"
set SelectButton of my settings to "Ω"
end become_Continuity_meter
--
on become_Frequency_meter()
set instruction of my settings to "To make me into a frequency meter, left rotate selector to OFF. right rotate selector one click, then twice press Hz/DUTY button"
set SelectRotation of my settings to "DCV"
set HzDutyButton of my settings to "Hz"
end become_Frequency_meter
--
on ident()
say instruction of settings
return (aName & settings)
end ident
end script
end define_device
For soothe, for data
Data collected in experiments using data loggers generally contains a lot of noise from the analogue to digital conversion and the sensor. In particular, sound and vibration sensors pick up stray sources because they are designed to have small inertia. Temperature sensors on the other hand, generally take several seconds to stabilise because of thermal inertia.
Noise levels can be up to 2 binary bits for a well constructed logger interface (out of 8 bits(256 levels) or 10 bits(1024 levels)), impairing the dynamic range. It is possible to retrieve some of this dynamic range by smoothing the data stream using a simple predictor-corrector algorithm that looks very much like the position-velocity equations of motion in Physics.
Here is an implementation of the alpha-beta filter algorithm for a data list. For good measure the data is generated by a simulation of (Gaussian noise: +/- 0.5 + constant measurement:100) using the well known Box-Mueller transformation from a canonical uniform distribution[0 to 1]. The filter outputs the filtered data in the form of a CSV text file composed of a count field followed by one data pair per line. It may be directly imported into Excel.
Of course the simulated data stream could be replaced by a real data stream.
The alpha, and beta parameters (alpha: 0.0 to 1.0, beta: 0.0 to 1.0) can be changed to experiment with their behaviour. Smaller means less responsive. The update interval, delta_t is set to 0.01 s (100 Hz which is typical of many experiments done in a high school science lab), so it can be set according to the update interval of the real data stream.
It is interesting to plot the data to see how quickly the filter picks up tracking the data. The first item is count, the second item is (simulated measurement), and the third is the smoothed estimate. The filter processes 50 data items. (for 0.01 x 50 = 0.5 s).
This AppleScript features:
- use of Satimage OSAX
- creating and writing to a text file on the desktop
- formatting the numerical data before writing to the text file (so it is compatible with Excel)
- use of the scaled random number generator
- use of square root function and natural log function
-- ForSoothe : Alpha-Beta filter algorithm with simulated input data stream
-- by Ian W. Parker first worked on 2009-05-02, last worked on 2009-05-03
-- requires Satimage OSAX for formatting of data
global data_list, data_file
set alpha to 0.5 -- position update correction weighting
set beta to 0.5 -- velocity update correction weighting
set delta_t to 0.01 -- (s) measurement interval (100 Hz)
set data_list to {{0, 0, 0}} -- count, xk, vk
-- ------------------------------------------------------
try
close access -- to all open files
end try
set data_file to open for access (path to desktop as string) & ¬
"test-file.text" with write permission
set data_list to alpha_beta_filter(alpha, beta, delta_t)
close access data_file
-- -----------------------------------------------------
-- ------------ [ support routines] ---------------
-- -----------------------------------------------------
on alpha_beta_filter(alpha, beta, delta_t)
global data_list
local xk, vk
repeat with k from 1 to 50 -- items
try
--predictor set, formula 1
-- previous item will be last item in data_list
set xk to (item 2 of last item of data_list) + alpha * delta_t * ¬
(item 3 of last item of data_list)
-- formula 2
set vk to item 3 of last item of data_list
--
-- corrector set, formula 3,
-- type = 2, gaussian: mean = 100, stdev = 1
set measurement to measured(2, 100, 1)
set rk to measurement - xk
-- formula 4
set xk to xk + alpha * rk
-- formula 5
set vk to vk + (beta / delta_t) * rk
end try
-- update the data list by appending record
set data_list to data_list & {{k, (format measurement into "###.#") ¬
as number, (format xk into "###.##") as number}}
set line_of_data to (measurement & "," & xk & "
") as string
write line_of_data to data_file
end repeat
return data_list
end alpha_beta_filter
-- measurement models, executable code
-- (s/c)ould be replaced with a call to a sensor read (eg. via serial port)
on measured(type, my_mean, my_var)
local w, x1, x2
-- two types uniform distribution (0,1)
if type is 1 then
-- simulated uniform density noisy data: my_mean ± 0.5 * my_var
-- my_mean is mean value, my_var is scale
return my_mean + (random number from -0.5 * my_var to 0.5 * my_var)
else
-- Polar form of Box-Muller transform: gaussian distribution (0,1)
set w to 2.0
repeat while (w ≥ 1.0)
set x1 to 2.0 * (random number from 0.0 to 1.0) - 1.0
set x2 to 2.0 * (random number from 0.0 to 1.0) - 1.0
set w to x1 * x1 + x2 * x2
end repeat
set w to sqrt ((-2.0 * (ln (w))) / w)
return my_var * (x1 * w) + my_mean
end if
end measured
Poly Nomials fit
The concept of least-squares fitting a mathematical formula to a data set is mathematically rather involved. However there are various levels of accessibility. For example AppleScript can give us a linguistic clue as to what is being done at the more abstract level.
This small script will transform data pairs from an experiment {{x(i),y(i)}, …} into a form compatible with the SATIMAGE OSAX fitpolynomial function. It is a bridge between using Excel or Numbers and research strength programs such as R for statistical computing.
This script features the generation of a string representing a polynomial in x. Each factor returned from <filtpolynomial> is used to build the polynomial string. The factors are converted to 4 place accuracy, E notation so that the string of each factor is of fixed width. An error estimate is also generated.
To make the script compatible with the capabilities of Excel or Numbers, the highest degree able to be generated is 6. By replacing the 6 at the end of "repeat with fit_degree from 2 to 6" with another small integer you can either limit the search or expand the search. The routine will keep building polynomials to fit the data until the error is less than a predetermined fit_error_max or it has generated the highest polynomial requested.
-- Ian W. Parker, first worked on 2010-07-17, last worked on 2010-07-18
-- analysis of science investigation data, requires list of data pairs {{x,y}, ...}
-- equivalent to linear tend line & polynomial modelling of Excel and Numbers
--equivalent to polynomial fit from Videopoint
-- requires satimage OSAX
-- ---------------- TEST DATA -----------------------------------------------------------
-- ideal model experiment_list below generated from (-1 + 0.1*x + x^2) with 1 dec place
-- two dependent variable values removed and replaced with "*" for test purposes
-- set experiment_data to {{1, 0.1}, {2, 3.2}, {3, 8.3}, {4, "*"},
-- {5, 24.5}, {6, 35.6}, {7, 48.7}, {8, "*"}, {9, 80.9}, {10, 100.0}}
-- ------------------------------------------------------------------------------------------
property fit_error_max : 0.01 --maximum deviation
property fit_error_res : "0.000E00" -- satimage OSAX, data display resolution (3 decimal digits, force E notation)
-- the test sample data list
set experiment_data to {{1, 0.1}, {2, 3.2}, {3, 8.3}, {4, "*"}, {5, 24.5}, {6, 35.6}, {7, 48.7}, {8, "*"}, {9, 80.9}, {10, 100.0}}
-- remove any pairs with unknown values in the list
set data_list to scanned from experiment_data
-- polynomial best fit, successively increase the degree parameter
-- until we get a fit_error_actual less than fit_error_max or poly. of degree 6
-- equivalent to what might be done manually using an application like Excel or Numbers.
repeat with fit_degree from 2 to 6
-- build a representation: y = formula (x) using function from satimage OSAX
set y to fitpolynomial data_list degree fit_degree
set fit_model to construct_polynomial_fit(y)
set fit_error_actual to (item 2 of fit_model as number)
if fit_error_actual is less than fit_error_max then exit repeat
end repeat
if item 2 of fit_model is "0" then set item 2 of fit_model to "Exact ± " & fit_error_max
-- result: {"-1.000E00 +1.000E-01*x +1.000E00*x^2 ", "Exact ± 0.01"
fit_model
-- ---------------------------------------------------------------------------------
-- scan data list for rogue items of the form { <number>, * }
-- and recompose as a list of two lists {{x},{y}}
-- acceptable to the satimage OSAX <fitpolynomial> function
-- ---------------------------------------------------------------------------------
on scanned from data_list
set {my_result, x_items, y_items} to {{}, {}, {}}
repeat with next in data_list
set the_item to next as list
-- remove any incomplete items
if next does not contain "*" then
set my_result to my_result & {the_item}
-- recompose the list
set x_items to x_items & item 1 of the_item
set y_items to y_items & item 2 of the_item
-- this will be returned
set my_result to {x_items, y_items}
end if
end repeat
end scanned
-- ---------------------------------------------------------------------------------
-- construct a polynomial fit with error estimate, down to fit_error_max
-- x is a placeholder for independent variable value
-- ---------------------------------------------------------------------------------
on construct_polynomial_fit(x)
-- requires x to be result of fitpolynomial function from satimage OSAX
set {fit_error, fit_result} to {format (fit error of x) as number into fit_error_res, fit result of x}
set {power, poly_string} to {0, ""}
repeat with next in fit_result
set next to format next into fit_error_res
if power is not 0 then
--insert "+" only if next non negative
if (next as number) ≥ 0 then set poly_string to poly_string & " +"
set poly_string to poly_string & next & "*x"
if power > 1 then set poly_string to poly_string & "^" & power & " "
else
set poly_string to poly_string & next
end if
set power to power + 1
end repeat
if (fit_error as number < fit_error_max) then set fit_error to "0"
{poly_string} & {fit_error}
end construct_polynomial_fit