This commit is contained in:
Arti Zirk 2017-04-19 10:46:05 +03:00
commit b12d602075
5 changed files with 429 additions and 0 deletions

96
charmap.txt Normal file
View File

@ -0,0 +1,96 @@
_
.
t
f
h
s
p
u
q
k
y
z
w
,
W
'
M
!
B
°
Z
C
F
"
R
S
?
E
U
D
:
G
V
L
P
J
T
A
Y
I
O
H
;
N
^
K
Q
X
/
*
Ü
1
2
3
4
0
5
6
7
8
9
-
$
+
£
%
=
ü
Ö
ä
(
)
&
Ä
´
ö
x
m
`
g
j
v
d
l
b
c
r
o
n
e
a
i

23
convert.py Normal file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env python3
orig = {}
with open("charmap.txt" ) as f:
for n, line in enumerate(f):
line = line.strip()
if line:
orig[n] = line
else:
print(n, "-empty-")
clist = {}
for pos, char in orig.items():
ascii = ord(char)
clist[ascii] = pos, char
print(pos, char, ascii)
for x in range(0xff):
print(x, *clist.get(x, (0, '')))
print("unsigned char charmap[] = {", end="")
for x in range(0xff):
print('{:>0}'.format(clist.get(x, (0, 0))[0]), end=", ")
print("};")

32
slowcat.py Executable file
View File

@ -0,0 +1,32 @@
#! /usr/bin/python2
# slowcat.py - print a file slowly
# author : dave w capella - http://grox.net/mailme
# date : Sun Feb 10 21:57:42 PST 2008
############################################################
from __future__ import print_function
import sys, time
delay = .02
if len(sys.argv) > 1:
arg = sys.argv[1]
if arg != "-d":
print("usage: %s [-d delay]" % (sys.argv[0]))
print("delay: delay in seconds")
print("example: %s -d .02 < vtfile" % (sys.argv[0]))
sys.exit()
if len(sys.argv) > 2:
delay = float(sys.argv[2])
while 1:
try:
for c in raw_input():
print(c, end="")
sys.stdout.flush()
time.sleep(delay)
print()
except:
break
######################################################################
# eof: slowcat.py

246
stepper.ino Normal file
View File

@ -0,0 +1,246 @@
/*
Stepper Motor Control - one step at a time
This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 - 11 of the Arduino.
The motor will step one step at a time, very slowly. You can use this to
test that you've got the four wires of your stepper wired to the correct
pins. If wired correctly, all steps should be in the same direction.
Use this also to count the number of steps per revolution of your motor,
if you don't know it. Then plug that number into the oneRevolution
example to see if you got it right.
Created 30 Nov. 2009
by Tom Igoe
*/
#include <Stepper.h>
unsigned char charmap[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 24, 0, 64, 67, 74, 16, 72, 73, 51, 65, 14, 63, 1, 50, 57, 53, 54, 55, 56, 58, 59, 60, 61, 62, 31, 43, 0, 68, 0, 27, 0, 38, 19, 22, 30, 28, 23, 32, 42, 40, 36, 46, 34, 17, 44, 41, 35, 48, 25, 26, 37, 29, 33, 15, 49, 39, 21, 0, 0, 0, 45, 0, 82, 94, 88, 89, 86, 93, 3, 83, 4, 95, 84, 9, 87, 81, 92, 91, 6, 8, 90, 5, 2, 7, 85, 13, 79, 10, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 70, 0, 0, 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 71, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 78, 0, 0, 0, 0, 0, 69, 0, 0};
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper columnStepper(stepsPerRevolution, 8, 9, 10, 11);
Stepper charWheelStepper(stepsPerRevolution, 7, 6, 5, 4);
int charWidth = 11; // how many steps between char prints
int currentPos = 0;
int currentChar = 0;
int limitPin = 12;
int headMotorLimitPin = 13;
int hammerPin = 22;
int Motor1A = 2;
int Motor1B = 3;
int Motor2A = 23;
void setup() {
// initialize the serial port:
Serial.begin(1200);
// configure limit pin
pinMode(limitPin, INPUT);
digitalWrite(limitPin, HIGH);
pinMode(headMotorLimitPin, INPUT);
digitalWrite(headMotorLimitPin, HIGH);
pinMode(Motor1A, OUTPUT);
pinMode(Motor1B, OUTPUT);
pinMode(Motor2A, OUTPUT);
pinMode(hammerPin, OUTPUT);
digitalWrite(hammerPin, LOW);
columnStepper.setSpeed(90);
charWheelStepper.setSpeed(90);
Serial.println("Finding home");
findHome();
Serial.println("Home found!");
}
void loop() {
delay(1000);
unsigned long lastCharTime;
while(0) {
for (int i = 0; i < 98; i++) {
printChar('0');
}
while(1) {lineFeed();}
}
while(1) {
if (Serial.available() > 0) {
// read the incoming byte:
lastCharTime = millis();
unsigned char in = Serial.read();
if (in == '\n') {
lineFeed();
lineFeed();
home();
} else {
printChar(in);
}
}
if (millis() - lastCharTime > 1000) {
releaseSteppers();
}
}
while(1) {
lineFeed();
delay(500);
}
while(1) {
//charWheelStepper.step(96);
charWheelStepper.step(1);
delay(100);
Serial.println(digitalRead(headMotorLimitPin));
}
bool limit = digitalRead(limitPin);
if(!limit) {
// step one step:
columnStepper.step(-1);
} else {
columnStepper.step(1200);
}
Serial.println(limit);
delay(3);
}
void printChar(unsigned char c){
int newLoc = charmap[c];
/*Serial.print("char ");
Serial.print(c);
Serial.print(" at ");
Serial.print(newLoc);*/
if (newLoc == 0){
charWheelStepper.step(1);
delay(30);
charWheelStepper.step(-1);
delay(30);
} else {
/*aSerial.print(", cur: ");
Serial.print(currentChar);
if (currentChar > newLoc) {
Serial.print(" > ");
newLoc = newLoc - currentChar;
currentChar += newLoc;
} else if (currentChar < newLoc) {
Serial.print(" < ");
} else {
Serial.print(" = ");
// that char is already selected
newLoc = 0;
}*/
newLoc = newLoc - currentChar;
currentChar += newLoc;
if (currentChar > 97) {
currentChar -= currentChar - 96;
}
/*Serial.print(" calcPos: ");
Serial.print(newLoc);
Serial.print(" new: ");
Serial.print(currentChar);*/
charWheelStepper.step(newLoc);
delay(30);
hammer();
freshTape();
}
columnStepper.step(charWidth);
currentPos += charWidth;
}
void hammer() {
digitalWrite(hammerPin, HIGH);
delay(13);
digitalWrite(hammerPin, LOW);
delay(10);
}
void freshTape() {
unsigned long start = millis();
char backTime = 13;
digitalWrite(Motor2A, LOW);
while(digitalRead(headMotorLimitPin)){
digitalWrite(Motor2A, HIGH);
if (millis() - start > 1000) {
digitalWrite(Motor2A, LOW);
return;
}
}
digitalWrite(Motor2A, LOW);
}
void home() {
columnStepper.step(-currentPos);
currentPos = 0;
}
void lineFeed(){
unsigned long start = millis();
char backTime = 13;
digitalWrite(Motor1A, LOW);
digitalWrite(Motor1B, LOW);
while(!digitalRead(limitPin)){
digitalWrite(Motor1A, HIGH);
if (millis() - start > 1000) {
digitalWrite(Motor1A, LOW);
digitalWrite(Motor1B, HIGH);
delay(backTime);
digitalWrite(Motor1B, LOW);
return;
}
}
start = millis();
while(digitalRead(limitPin)){
digitalWrite(Motor1A, HIGH);
if (millis() - start > 1000) {
digitalWrite(Motor1A, LOW);
digitalWrite(Motor1B, HIGH);
delay(backTime);
digitalWrite(Motor1B, LOW);
return;
}
}
digitalWrite(Motor1A, LOW);
digitalWrite(Motor1B, HIGH);
delay(backTime);
digitalWrite(Motor1B, LOW);
}
void findHome() {
currentPos = 0;
currentChar = 0;
bool limit = 0;
lineFeed();
while (!limit) {
columnStepper.step(-1);
delay(3);
limit = digitalRead(limitPin);
}
charWheelStepper.step(-100);
columnStepper.step(20);
charWheelStepper.step(-1);
limit = digitalRead(limitPin);
if (limit) {
lineFeed();
Serial.print("Column limit error!");
findHome();
}
}
void releaseSteppers(){
for (int i = 4; i < 12; i++) {
digitalWrite(i, LOW);
}
}

32
welcome.txt Normal file
View File

@ -0,0 +1,32 @@
Lapikute arendusmasin
lap-dev login: purustaja
Password: *****
I------------------------------I
I Kas oled Rekorditeks valmis? I
I------------------------------I
$ sudo apt-get rekt