Skip to content

Instantly share code, notes, and snippets.

@Glitchbone
Last active November 19, 2023 23:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Glitchbone/4a721f4f92d01191c8e67eef52f50eea to your computer and use it in GitHub Desktop.
Save Glitchbone/4a721f4f92d01191c8e67eef52f50eea to your computer and use it in GitHub Desktop.
Canon X-07 <> PC using Arduino UNO

Canon X-07 <> PC with Arduino UNO

Comments

  • Output from X-07 is ASCII with CRLF line terminators (converted to LF using igncr stty flag)
  • EE1F routine only needs CR
  • Input files should have UNIX style LF line terminators (converted to CR using tr)
  • Maximum baud rate seems to be 240bps when sending data to the X-07 using the EE1F routine. As it is not supported by the Arduino, it is simulated when sending using pipeviewer pv -L 30 (the unit is bytes per second).

Schematics

  GND D10 D12
   ├10K┤   |
  (2) (4) (6) (8)
(1) (3) (5) (7) (9)
         |   |
        D11 D13
Pin no. Signal name Direction Contents
1 LTxD -> OPT transmission DATA
2 FG Frame ground
3 N.C.
4 TxD -> Transmitted DATA
5 RxD <- Received DATA
6 CTS <- Other device receiving
7 RTS -> X-07 receiving
8 SG Signal ground
9 VBB -> Unstable power supply

Arduino sketch

#include <Arduino.h>
#include <SoftwareSerial.h>

#define BAUDS 4800
#define RX_PIN 10
#define TX_PIN 11
#define RTS_PIN 12
#define CTS_PIN 13

SoftwareSerial serial2(RX_PIN, TX_PIN, true);

void setup()
{
    Serial.begin(BAUDS);
    while (!Serial);
    serial2.begin(BAUDS);
    digitalWrite(RTS_PIN, HIGH);
}

void loop()
{
    while (serial2.available()) Serial.write(serial2.read());
    while (Serial.available() && digitalRead(CTS_PIN) == HIGH) serial2.write(Serial.read());
}

PC serial configuration

Assuming that the Arduino USB serial interface is assigned to /dev/ttyACM0 :

$ stty -F /dev/ttyACM0 4800 raw -hupcl -echo igncr

From X-07 to PC

  1. Start the reception on the computer :
$ cat /dev/ttyACM0 | pv > prog.bas
  1. Configure the serial port on the X-07
INIT#1,"COM:"
  1. Create a new BASIC program in X-07 text memory :
NEW
10 INPUT "NAME";A$
20 PRINT "HELLO ";A$
30 END
  1. Send the BASIC listing to the serial port :
LIST#1
  1. Press Ctrl-c on the computer once the X-07 reaches the end of the listing (prompt is back). The BASIC listing will be saved in prog.bas.

From PC to X-07

  1. Clear the X-07 text memory and set its standard input to serial :
NEW
INIT#5,"COM:"
EXEC &HEE1F
  1. Send the content of the file to the X-07 (convert LF to CR & throttle output to 240bps) :
$ echo -e '\nEXEC &HEE33' | cat prog.bas - | tr '\n' '\r' | pv -L 30 > /dev/ttyACM0

Scripts

RECV (X-07)

10 INIT#5,"COM:"
20 EXEC &HEE1F

x07comm (bash script)

#!/usr/bin/env bash

set -e

X07_BAUDS="${X07_BAUDS:-4800}"
X07_TTY="${X07_TTY:-/dev/ttyACM0}"

help() {
    echo "
Usage: 
    ${0##*/} [command] filename

Commands:
    send        Send file to X07
    receive     Receive file from X07"
}

send() {
    echo -e '\nEXEC &HEE33' | cat $1 - | tr '\n' '\r' | pv -L 30 > $X07_TTY
}

receive() {
    cat $X07_TTY | pv > $1
}

case $1 in
  send|receive)
    [ ! -n "$2" ] && echo "Missing filename" && help && exit 1
    stty -F $X07_TTY $X07_BAUDS raw min 0 time 20 -hupcl -echo igncr
    $1 $2
    ;;
  *)
    echo "Unknown command: $1" && help && exit 1
    ;;
esac

exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment