PICAXE I/O ROUTINES AND FUNCTIONS

Similar documents
AXE114S BINARY CLOCK. revolution Revolution Education Ltd. Web: Version /09/08 AXE114.PMD.

The $25 Son of a cheap timer This is not suitable for a beginner. You must have soldering skills in order to build this kit.

Your Multimeter. The Arduino Uno 10/1/2012. Using Your Arduino, Breadboard and Multimeter. EAS 199A Fall Work in teams of two!

AXE033 SERIAL/I2C LCD

- 35mA Standby, mA Speaking pre-defined phrases with up to 1925 total characters.

PICAXE DATALOGGER (AXE110P)

MICROCONTROLLER INTERFACING CIRCUITS

revolution Contents: Introduction Power 28-pin Project Board with input/output cables

Analog control unit for mobile robots

PICAXE COLOUR SENSOR. revolution. Overview: Contents (AXE045 Colour Sensor): Contents (AXE112S Starter Pack): General Operation:

Objectives: Part 1: Build a simple power supply. CS99S Laboratory 1

If an occupancy of room is zero, i.e. room is empty then light source will be switched off automatically

PICAXE RF CONNECT KIT (AXE213)

USING I2C WITH PICAXE

The Programming Interface

Special Lecture. Basic Stamp 2 Programming. (Presented on popular demand)

GLOLAB Universal Telephone Hold

Combi B Alarm box. Mounting instructions

TS510 & TS500. Installation & User Guide. Compatible Equipment

PolyBot Board. User's Guide V1.11 9/20/08

RGB for ZX Spectrum 128, +2, +2A, +3

Copyrights 2010 Victron Energy B.V. All Rights Reserved

Example use of a microcontroller.

MODULE BOUSSOLE ÉLECTRONIQUE CMPS03 Référence :

PHYS 2P32 Project: MIDI for Arduino/ 8 Note Keyboard

SYSTEM 4C. C R H Electronics Design

DET Practical Electronics (Intermediate 1)

Example use of a microcontroller. Revolution Education Ltd. Web:

Parts of a Computer. Preparation. Objectives. Standards. Materials Micron Technology Foundation, Inc. All Rights Reserved

Example use of a microcontroller.

M68EVB908QL4 Development Board for Motorola MC68HC908QL4

A guide to using Blockly to simulate and program a PICAXE microcontroller

[F/T] [5] [KHz] [AMP] [3] [V] 4 ) To set DC offset to -2.5V press the following keys [OFS] [+/-] [2] [.] [5] [V]

RC2200DK Demonstration Kit User Manual

MIDECO 64-outputs MIDI note decoder USER MANUAL. Roman Sowa 2012

Kit Watt Audio Amplifier

TEECES DOME LIGHTING SYSTEMS

ezsystem elab16m Project 1F: Alarm System (Full Project description)

9452/9453 Installation and User Guide

Data Acquisition Module with I2C interface «I2C-FLEXEL» User s Guide

WIRING HARNESS FOR AS635P4. BLUE PLUG RED, BLUE, BLACK, WHITE - Plug in dual stage sensor harness

Web Site: Forums: forums.parallax.com Sales: Technical:

Solar Home System. User Manual. AEH-SHS01-10W2L Solar Home System 2 Lamps

Electronics 5: Arduino, PWM, Mosfetts and Motors

C4DI Arduino tutorial 4 Things beginning with the letter i

Cornerstone Electronics Technology and Robotics I Week 15 Voltage Comparators Tutorial

Your EdVenture into Robotics You re a Programmer

Smarthome SELECT Bluetooth Wireless Stereo Audio Receiver and Amplifier INTRODUCTION

Programming PIC Microcontrollers in PicBasic Pro Lesson 1 Cornerstone Electronics Technology and Robotics II

SYSTEM 45. C R H Electronics Design

Zeros, Ones, and the Morse Code

Advanced LED Controller (LED Chaser)

ServoPAL (#28824): Servo Pulser and Timer

1. Learn about the 555 timer integrated circuit and applications 2. Apply the 555 timer to build an infrared (IR) transmitter and receiver

RADIANT PLASMA 4700 Plasma Spark Generator

UPS PIco. to be used with. Raspberry Pi B+, A+, B, and A. HAT Compliant. Raspberry Pi is a trademark of the Raspberry Pi Foundation

Radio sensor powered by a mini solar cell the EnOcean STM 110 now functions with even less light

BMD16N-SD. version 1.2

AUTODIALLER / QUICKDIALLER - SA132

Servo Motors (SensorDAQ only) Evaluation copy. Vernier Digital Control Unit (DCU) LabQuest or LabPro power supply

Using and Wiring Light Emitting Diodes (LEDs) for Model Railroads

Capacitive Touch Sensor Project:

Web Site: Forums: forums.parallax.com Sales: Technical:

MODEL 5010 DUAL CHANNEL SMOKE/FIRE DETECTION MODULE

ABACOM - netpio.

An Introduction to MPLAB Integrated Development Environment

Parallax Serial LCD 2 rows x 16 characters Non-backlit (#27976) 2 rows x 16 characters Backlit (#27977) 4 rows x 20 characters Backlit (#27979)

Chapter 4: Pulse Width Modulation

Glolab Talking Phone Dial Monitor

Stop Alert Flasher with G-Force sensor

Owner s Manual AWM910 JENSEN AWM910 COMPACT DISC PLAYER RADIO CD COMPACT MUSIC SYSTEM MUTE AUX BAND AUX IN PUSH PUSH PWR VOL ALARM T/F AUD SPK A SPK B

AVR Butterfly Training. Atmel Norway, AVR Applications Group

Digital Keypad Use s Manual

K9 Heat Alarm Owners Manual HA-1520

KD-204. Telephone Remote Switch. Operating Instructions

FREQUENCY RESPONSE OF AN AUDIO AMPLIFIER

Wireless Audio Video Sender

Operating Manual Color Changing Fountains

The basic set up for your K2 to run PSK31 By Glenn Maclean WA7SPY

Points Position Indicator (PPI1) for Points Motors with Common Ground

Welcome to the tutorial for the MPLAB Starter Kit for dspic DSCs

Pulse Width Modulation (PWM) LED Dimmer Circuit. Using a 555 Timer Chip

WHO ANSWERED FIRST? FIND OUT WITH THIS QUIZ BUZZER KIT

Tutorials Drawing a 555 timer circuit

PRO PLM Installation Instructions

ECEN 1400, Introduction to Analog and Digital Electronics

1R / 4-BUTTON SERIES

INTRODUCTION TO SERIAL ARM

SD21-21 Channel Servo Driver Module Power Servo's

MODEL 2202IQ (1991-MSRP $549.00)

Controlling a Dot Matrix LED Display with a Microcontroller

Final Design Report 19 April Project Name: utouch

User and installation manual

AUTOMATIC CALL RECORDER JAMECO PART NO

Designing VM2 Application Boards

Real Time Clock USB Evaluation Board V3.0

Optical Sensor Interface for AFX Digital LED Timer/Counter by George Warner, Jan

IPX AUTOMATIC IP NETWORK LOSS BACKUP A/B SWITCH INSTRUCTION BOOK IB

revolution Revolution Education Ltd. Web: Vesrion 2.128/08/02 PICLOCK.P65 SELF -ASSEMBL Order Codes:

Transcription:

PICAXE I/O ROUTINES AND FUNCTIONS Pin configuration for PICAXE-08M chip: Two programming lead connectors are shown: Left: Standard programming lead with 3.5mm stereo plug Right: Cable made from old mouse cable connected to DB9 female connector and a 3 pin header strip. Note the dimple on the left of the chip indicates its orientation. -ve pin (aka 0v) in the photo is leg 8 in the schematic diagram above. Pin 0, 1, 2 in the photo are leg 7, 6 and 5 in the schematic diagram. DC Power Supply: Never use a supply higher than 5V! Your kit comes supplied with a 3 x AA switched battery box. Use this until you become more familiar with electronics and PICAXE chips. 1

Regulated Power Supply: Some users may wish to use a wall adapter style power supply (e.g. part PWR009). It is essential that a good quality regulated 9V DC device is used with a 5V regulator. Unregulated devices may give excessive voltages (under low load conditions) that will damage the microcontroller. The 9V DC supply must be regulated to 5V using a voltage regulator (e.g. 7805 (1A capability) or 78L05 (100mA capability)). The full regulation circuit is shown below. The 1N4001 diode provides reverse connection protection, and the capacitors help stabilise the 5V supply. Note that voltage regulators do not generally function correctly unless the input supply in this circuit is approximately 8V or higher. Care with LED s LED is short for Light Emitting Diode. They glow when connected to a circuit. LEDs require a minimum voltage, about 1.6-2.0 Volts before they begin to glow. LEDs must be connected the right way around. They have a positive and negative leg. The short leg with the flat side on the LED always connects to the NEGATIVE side of the circuit closest to the NEGATIVE power supply rail. The longer leg connects to the side towards the POSITIVE power supply rail (usually to the PICAXE pin). CAUTION: Do not touch the legs of the LED to a 9V battery as this will blow the LED and you will have to buy another! Common pin configurations Common Transistor layout: IR Decoder layout: 2

Example programs 1. Single LED flasher - connect a LED to pin 2 and 0V (-ve) high 2 wait 1 low 2 connect pin 2 to high voltage state to turn on the LED wait for 1 second connect pin 2 to low voltage state to turn off LED pause for 1000 milliseconds=1s go back to start point main Make the LED flash from any of the output pins 0, 1, 4 Make the LED stay on for longer Make the LED stay off for longer Make more than one LED flash 2. Flash together - connect a LED to pin 2 and 0V (-ve), and another to pin 1 high 2 connect pin 2 to high voltage state to turn on the LED low 1 connect pin 2 to low voltage state to turn off LED pause 500 pause for 500 milliseconds= 0.5s low 2 connect pin 2 to low voltage state to turn off LED high 1 connect pin 1 to high voltage state to turn off LED pause 500 pause for 500 milliseconds= 0.5s go back to start point main Make the LEDs flash together flash Make the LED flash at a faster rate Make the LED stay off for longer Make more than one LED flash Use the TOGGLE command instead or HIGH AND LOW? 3. Counting flashes - connect a LED to pin 2 and 0V (-ve) For b1 = 1 to 10 Saves the value 1 into memory space b1 high 2 connect pin 2 to high voltage state to turn on the LED pause 500 pause for 500/1000 second = 0.5s low 2 connect pin 2 to low voltage state to turn off LED pause 500 pause for 500 /1000 seconds=0.5s next b1 increases the value in b1 by 1 each loop until value 10 Increase the number of LED flashers Attach a speaker and get it to play a tune (see below) after 8 flashes of the LED 3

4. Light alert main program starts here readadc 1,b1 read voltage on pin 1 and save in memory space b1 If b1>150 then Music jump to Noise if voltage number higher than 150 wait 2 wait for 2 seconds jump back to Main Music: 'play James,Bond theme - cut and paste this code! tune 0, 2, ($20, $62, $62, $22, $E2, $20, $20, $20, $20, $63, $63, $E3, $22, $22, $22, $20, $62, $62,$22,$E2,$20,$20,$20,$20,$63,$63,$23,$E3,$22,$21,$20,$00,$AB,$27,$25,$A7) jump back to Main Insert line debug after the readadc line and check the input voltage number on pin 1. Shade the LDR to alter its resistance and see the voltage numbers change. Alter the threshold for the speaker to sound to make it trigger more easily. SENSOR CIRCUITS 1. Temperature sensor 10k thermistor terminated between +ve and pin 1 10k pull down resistor between pin1 and -ve serout 0, n2400, ("temp:", #b0) send txt message along programming lead 2. Light intensity sensor LDR terminated between +ve and pin 1 10k pull down resistor between pin1 and -ve serout 0, n2400, ("light:", #b0) send txt message along programming lead 4

3. Infra-red light sensor Infra red terminated between +ve and pin 1 10k pull down resistor between pin1 and -ve serout 0, n2400, ("IR light:", #b0) send txt message along programming lead. Make a Terminator target practice game like the one on the Nexus Research Group website! 4. Touch sensor A piece of hook up wire in +ve rail. Another piece of hook up wire in pin 1 rail. 4.7M pull down resistor between pin1 and -ve serout 0, n2400, ("touch:", #b0) send txt message along programming lead. Can you have this as an alarm instead? Use as a standalone unit that will flash a LED or play a tune if the wires are touched? How about a moisture sensor? Will a dry sponge work as opposed to a damp sponge? Or a conductivity sensor to see what materials can conduct electricity? Night Light / Novelty Jelly Connect a blue LED to pin 2 and 0V (-ve), and a yellow LED to pin 4. For a birthday treat, place the entire circuit in a jar with a tight sealed lid and place in the bottom of a jelly mold so when the jelly is upright, the LEDS can be seen thru the glass and illuminate the jelly! Or for a spooky Halloween effect, carve a pumpkin and place two red LED s in the circuit for a pumpkin that glows in the dark! for b1= 0 to 255 step 2 pwm 2,b1,1 pwm 4,b1,1 next b1 for b1= 255 to 0 step -2 pwm 2,b1,1 pwm 4,b1,1 next b1 ' counter loop so LED has multiple PWM cycles ' PWM pin 2 LED one cycle increasing pulse width ' PWM pin 4 LED one cycle increasing pulse width ' effect is a pleasing surging brightness increase ' PWM pin 2 LED one cycle decreasing pulse width ' PWM pin 4 LED one cycle decreasing pulse width 5

The PICAXE-08 Commands DIGITAL OUTPUT HIGH LOW TOGGLE OUTPUT INPUT REVERSE PULSOUT DIGITAL INPUT IF THEN PULSIN Switch an output pin high (on). High 2 turns pin 2 on Switch an output pin low (off). Low 2 turns pin 2 off Toggle the state of an output pin. Set a pin as output. Output 1 makes pin 1 an output pin Set a pin as input. Input 1 makes pin 1 an input pin Reverse the input/output state of a pin. Output a pulse on a pin for given time. Jump to new program line depending on input condition. If b1 < b2 then motoroff Measure the length of a pulse on an input pin. ANALOGUE OUTPUT SOUND Output a sound. 0 = no sound, 255 = hiss. Sound 2, (100, 20) sound pin 2, 5kHz tone, 0.2 s PLAY TUNE Play an internal tune on the PICAXE output pin 2. PLAY tune,led - Tune is a variable/constant (0-3) which specifies which tune to play 0 - Happy Birthday (All parts) 1 - Jingle Bells (08M/14M only) 2 - Silent Night (08M only) 3 - Rudolph the Red Nosed Reindeer (08M only) - LED is a variable/constant (0-3) which specifies if other PICAXE-08M outputs flash at the same time as the tune is being played. 0 - No outputs 1 - Output 0 flashes on and off 2 - Output 4 flashes on and off 3 - Output 0 and 4 flash alternately Play a tune on the PICAXE output pin 2.. TUNE LED, speed, (note, note, note...) - LED is a variable/constant (0-3) as above for - speed is a variable/constant (1-15) which specifies the tempo of the tune. - notes are the actual tune data generated by the Tune Wizard. PWM Provide a pulse width modulation output pulse. PWM 1, 50, 10 pulse pin 1, 50/255 duty, 10 cycles ANALOGUE INPUT READADC PROGRAM FLOW Read analogue channel into a variable. Read 1, b0 ' read analogue pin 1 into b0 FOR.. NEXT Establish a FOR-NEXT loop For b1=0 to 100 step 10 'Counts in tens BRANCH Jump to address specified by offset GOTO Jump to address If b1=5 goto motoroff GOSUB Jump to subroutine at address. RETURN Return from subroutine IF.. THEN Compare and conditionally jump. VARIABLE MANIPULATION {LET} LOOKUP LOOKDOWN RANDOM Perform variable mathematics. Lookup data specified by offset and store in variable. Find target s match number (0-N) and store in variable Generate a pseudo-random number SERIAL I/O SEROUT Output serial data from output pin. Serout 0, n2400, (65) pin 0, 2400 bps, sends ASCII 65 (=A) SERIN Serial input data on input pin. Serin 0, n2400, ("A") pin 0, 2400 bps, waits for ASCII 65 6

INTERNAL EEPROM ACCESS EEPROM READ WRITE POWER DOWN NAP SLEEP END MISCELLANEOUS PAUSE WAIT DEBUG Store data in data EEPROM before downloading BASIC program Read data EEPROM location into variable Write variable into data EEPROM location Write 220, b1 store byte b1 into address 220 Enter low power mode for short period (up to 2.3 sec) Enter low power mode for period (up to 65535 sec) Power down until reset, an indefinate sleep Wait for up to 65535 milliseconds Wait for up to 65 seconds Outputs variable value to PC screen via programming lead Debug b0 shows b0 value on screen CASI, the PICAXE autonomous Mars rover prototype by Michael Fenton that can also be remotely controlled by a Casio Graphics calculator Parts List: Breadboard PICAXE 08M 3 x AA switched battery box UV Led (silver tape) Infra-red photo transistor (black tape) 10k Thermistor temperature sensor 2 each of yellow, red, blue, white ultrabright LED s Speaker 10k resistors 4.7M resistor Hook up wire CD-ROM with Mac OSX and Windows software Serial cable 3.5mm stereo socket Instruction manual, circuit diagrams, example codes 7