@11-11-2025

Zero2
-------
The arduino connects to the PC with the standard USB lead 
and connects to Zero2 using SoftwareSerial on pins 10(Rx),11(Tx),
Rx and Tx are inverted to RS232 format using two BC 549 transistors 
with 1k pull-ups to 5v and 10k base resistors to incoming signals.
Zero2's 12v motor supply is from the Aduino's Vin and the and 5v 
logic supply is from the Arduino's 5v.

The 12v motor power is controlled by a relay driven by a BC549 on pin 8
which also lights an LED so I can see whether power is on.

Umbilical    - 1 - 0v,Rx,Tx,5v,0v,12v - 6
Write to Z2  - xx,A2,A1,A0,D3,D2,D1,D0
Read from Z2 - xx,Rdy,D5,D4,D3,D2,D1,D0

WRITE
Address 0 - left motor - D3,D2   right motor - D1,D0  - [1,0,2,3]=forwards 
Address 1 - pen motor  - D1,D0   [1,0,2,3]=clockwise
Address 2 - hmi        - Hh,Hl,iL,iR - 1=on   
Address 3 - speech low nibble
Address 4 - speech/sound high nibble - write high nibble then low nibble  
Address 5 - sound low nibble
READ
Address 0 - lineSensor - D2,D1,D0   D2 left, D0 right

Stepper motors - drive/pen - unipolar (5 wires) 
  Impex ID31 (1983) 9904-112-31004, nominal 12v
  7.5deg, 48 steps/rev, 65 ohm, 175ma/coil,
  max working 20mNm, holding 28mNm, 240step/s  

The 9v supply is turned off automatically when stopped to reduce power, p0 disables, p1 enables 
The LEDs run from 5v through a ULN2003. When the 9v supply is off after a '.' cmnd 
the LEDs light through the flyback diodes in the ULN2003 to 0v.   

Primary commands used
012345678 ?$#.()* BDFLPRU abcfhilmnprsw
   
=============================================================
improvements?
------------- 
C - command, 
  Clf line find, 
  Cl<distance>  follow line for distance

'!' - use page3 Reacts for the next record, load, replay, or print
[S][#byte] - say phoneme        modify to Dan Michaels scheme
[d][s] - distance step       ?!!!

Reactions stored in EEPROM page 3 as 8 slots of 32 bytes, Reactions can have 
the same commands as Acts and ended with ".".
When a sensor test is made in an Act and something is detected then the 
relevant Reaction is played then the Act continues.

Currently higher actions are expected from a PC program eg the QL cControl program.
=============================================================
Zero2
=====
Just as with a washing machine controller where you wouldn't expect to have
to write more microcontroller code just to get it to do a different wash
cycle so neither is it desirable to have to continually write Arduino code
to change what the robot does.
The following commands can be entered from the Serial Monitor (or other
Terminal) set to 9600 baud and sequences of commands can be recorded in the
EEPROM so they are remembered even when power is off.
The sequences of commands can then be replayed.

Acts
====
If each sequence which we will call an Act takes less than 32 commands then
8 Acts will fit in the second 256 byte page of the EEPROM.
A second set of eight Acts will fit in the first 256 byte page of the EEPROM. 
These are addressed as logical Page0 by prefixing with 0 the 1-8 Act number.
So sixteen Acts can be remembered. 01,02,03,04,05,06,07,08,1,2,3,4,5,6,7,8

An Act can have up to 31 commands followed by '.' indicating end of the Act.
Any Act can chain to another Act, even itself.
Any of the Acts 1 - 8 can be set to autorun on poweron or reset,
depending on selected behaviour.

See also NOTES below.
=============================================================
COMMANDS
======== 
[Esc],[Q] - stop, quit operations, Horn off, LEDs off, go to command mode
[.] - stop, end current operation - recording, playing, input        
["]  start/end of a comment, processed in GetCcmnd()
[(] - start of a Do, will show its location in EEPROM when played, eg (=263
      If a jump to another Act is made from within a Do then the Do 
    location will be shown eg (@267) and when returning the return 
    location will be shown, eg (267)
      A jump to an Act from a Do will on . continue in the Do
      If a jump is made to an Act which contains another Do then that Do
      will become the current Do. Do are nestable up to 15 deep.
[)] - end of a Do, will show its location in EEPROM when played, eg )=285
[0] - use page0 for the next cmnd or Act number
[a][1-8] - Act to autorun on power on
[1-8] Play act, or the Act to record, copy, load etc
[p][1] - 9v power on, AutoPower on (turns 9v on for a move), automatic power-off at "." 
[p][0] - 9v power off, AutoPower off
[F]{digits}[,] - Forwards   - if no digits then 1 - units mm
[B]{digits}[,] - Backwards  - if no digits then 1 - units mm
[R]{digits}[,] - turn Right - if no digits then 1 - units degrees
[L]{digits}[,] - turn Left  - if no digits then 1 - units degrees
[D] - Pen down
[U] - Pen up
[P] - initialise Pen - not needed if Zero2 has a PenCamStop to set Up/Down
[f][l]{digits}[,] - forward left    - if no digits then 1 - 1 mm is 1/2 degree
[f][r]{digits}[,] - forward right   - if no digits then 1 - 1 mm is 1/2 degree
[b][l]{digits}[,] - backward left   - if no digits then 1 - 1 mm is 1/2 degree
[b][r]{digits}[,] - backward right  - if no digits then 1 - 1 mm is 1/2 degree
[m][digits][,] - actual degrees for R360 or L360
[w][0-9,0] - wait seconds, 0=10
[n][0-9,0] - nap tenths second, 0=10
SPEED
[s][1-9] - steptimeC => steptime/2
   [+] - speed-up,   steptimeC -=1  >=1
   [-] - speed-down, steptimeC +=1
   [u] - speed-up,   steptimeC -=1  >=stepmin
   [d] - speed-down, steptimeC *=2
   [m] - set speed-max for speed-up to current speed
   [s] - save speed
   [D] - set steptimeC to default =4
INDICATORS
[i][o] - Indicators off
   [r] - Indicator R on
   [l] - Indicator L on
   [s] - Indicators on
[i][0] - Indicators off
   [1] - Indicator R on
   [2] - Indicator L on
   [3] - Indicators on
HORN
[h][o] - horn off
   [h] - horn high tone
   [l] - horn low tone
   [n] - horn (both tones)
[h][0] - horn off
   [1] - horn low
   [2] - horn high
   [3] - horns on
SENSOR
[$][0] - return status address0
[$][l] - return line status   (l.c. L)
[$][L] - return line status
Future use - [$][f] - return feeler status
Future use - [$][g] - return ground status
GRIPPER
[g][0-3] - Address1 D3,D2 control on P1 (aux gripper)
OTHER
[Z][digits][,] - send a byte to robot
[S][digits][,] - sound 76489
[T][digits][,] - talk say phoneme, SP0256  - will hang if no Zero2   
BEHAVIOUR      uses # because 'b' already used by QL for 'b'ackward
[#][0] - reload behaviour
   [S] - Save current behaviour
   [a] - set AutoAct 1-8, 0 no autoact
   [m] - set defaultMove
   [t] - set defaultTurn
   [s] - set stepScale500, steps for 500mm
   [r] - set rotateScale360, steps for 360deg
   [v] - set verbose printing on
   [q] - quiet, set to quiet printing
   [#] - do[Q] same as Bamduino
SHOW   
[?][?] - print acts
   [a] - '??' prints all acts 
   [0] - prints acts 0, and changes '??' to just print current page (for QL zero2 program)
   [b] - print behaviour - thisprog,
                         - baudrate
                         - autoAct  [#][a][0-8]
                         - Pen state
                         - steptimeC  [s][1-9]
                         - steptime =steptimeC *2
                         - min steptimeC [s][m]
                         - rotateScale360 [#][r]{digits}[,]
                         - stepScale500 [#][s]{digits}[,]
                         - auto 9v power down [P][0,1]
                         - default Turn [#][t]{digits}[,]
                         - default Move [#][m]{digits}[,]
   [d] - dump all acts to PC without descriptions, suitable for loading
   [h] - print help
SYSTEM   
[*][d] - toggle debug
   [r][0 1-8] - record act, 0 use page0
   [l][0 1-8] - load act, 0 use page0
   [c][0 1-8][0 1-8] - copy Act to Act, 0 use page0
   [f][9] - set Zbaud to 9600
      [4] - set Zbaud to 4800 - default   
Notes
[(] - will show its location in EEPRO< when played eg (=263
[)] - will show its location in EEPRO< when played eg )=285
If a call to another Act is made from within Mind then the location to return to will be shown, eg (267)
Acts by default are stored in page 1, 0 changes to page 0 for the next command only.
Page 0 ia EEPROM bytes 0-255, Page 1 is EEPROM bytes 256-511 etc.
In immediate mode all commands will be executed before any Act is played, 
  an Act number just sets the pointer to Acts,
  so "U12D" will do
    U
    set the pointert to Act1
    set the pointer to Act2 overwriting the pointer setting to Act1
    D
    then execute Act2 

IR-COMMANDS  (see also IRin.ino)
=========== 
to enter a default for FBRL press [+] instead of ',' or '.' 
it is the only non numeric key available, there is no '+' command so Zero2 will indicate 'bad key'
  [keyPOWER] - '.' will abort number entry
  [keyUP]    - 'F'
  [keyDOWN]  - 'B'
  [keyRIGHT] - 'R' if(f_hashcmnd) { Ccmnd ='>'; }
  [keyLEFT]  - 'L' if(f_hashcmnd) { Ccmnd ='<'; }
  [keyBAR]   - 'r'
  [keyTENT]  - 'a'
  [keyVCROSS]- '?'
  [keyXCROSS]- '#'
  [key0]     - '0'
  [key1]     - '1'
  [key2]     - '2'
  [key3]     - '3'
  [key4]     - '4'
  [key5]     - '5'
  [key6]     - '6'
  [key7]     - '7'
  [key8]     - '8'
  [key9]     - '9'
  [keyMINUS] - '-'
  [keyPLUS]  - '+'
=============================================================
TVR010_PicAxe_IR_controller:
'---------------------------
'Before use, the transmitter must be programmed with the ‘Sony’ transmit code.
'1. Insert 2 AAA size batteries, preferably alkaline.
'2. Press [S] and [B] at the same time. [S] is in the centre of the arrows.
'  The top left red LED should light.
'3. Press [0]. The LED should flash.
'4. Press [1]. The LED should flash.
'5. Press [3]. The LED should go out.
'6. Press the red power button (top right).
'-------------------------------------------
'IRin cmnds using PicAxe controller
'DO NOT PRESS OTHER KEYS
'ie [A] [B] [C] [D] [E] [F] [G]
'They change the Mode and [B] has to be pressed to change back.
'[square] [triangle] [()] [L] [X] [backwards F]  have no effect
=============================================================
NOTES
=====
{digits} is an optional string of digits, 
must be ended with comma, space or next command letter.

[(] - will show its location in EEPROM when played eg (=263
[)] - will show its location in EEPROM when played eg )=285
If a call to another Act is made from within a Do then the location to return to will be shown, eg (267)

Acts by default are stored in page 1, 0 changes to page 0 for the next command only.
Page 0 ia EEPROM bytes 0-255, Page 1 is EEPROM bytes 256-511 etc.

Upper-case is used for single letter commands and 
Lower-case will be used for parameter commands.

Until programming mode is entered any of the commands have immediate effect.
In immediate mode keys 1 - 8 will play the corresponding Act, whatever has
been recorded. 
If 'r' is entered then the next key must be 1 - 8 to select the Act to be
recorded.
If '.' is entered instead then recording will not start.
Any of the keys can be entered in recording mode including 'r' but that 
makes no sense and is blocked during recording by setting f_recordC to false.
'?' operates but is also blocked from being recorded by setting f_recordC
to false.
When recording has started keys (0) 1 - 8 will record a jump to the
corresponding Act.
However in record mode playback of that Act is suppressed, hence after
entering an Act number it makes no sense to add more commands since they
will never be done
because control will jump to the new Act; so just enter '.' to quit
recording.
E.g. "r1FFRR1."    records "FFRR1." in Act1 
if in immediate mode '1' is entered then Act-1 will be played giving
Forward, Forward, turnRight, turnRight, jump to Act 1
So Act 1 will play forever, Act 1 could also be invoked from another Act
eg "r21."       here Act 2 does nothing except jump to Act-1.
'.' or Esc quits a playing Act.

The command 'l','1'-'8' - loads an Act directly from the Serial Monitor
without acting
E.g. "l7VVVFFV." loads Act-7 with "VVVFFV."
You can load command strings which either won't Play or do odd things,
so beware.
E.g. keys l7?bVV. will load "?bVV." into Act-7, but after '?b' the "VV"
will never be done.
E.g. "l7VV?2VV." will load "VV?2VV." into Act-7 and when played Bambino
plays VV then does '?' which expects an Act number for the Act to print,
when the Act is printed the EEPROMindex will point to the end of the
printed Act so Play will end.
However if '.' is entered instead of an Act number then the '7' after '?'
will be read and Act-7 will be done again.

=============================================================
