Skip to content

Commit c866750

Browse files
committed
Uploaded_8_28_2020
1 parent f0ef8e9 commit c866750

File tree

3 files changed

+169
-0
lines changed

3 files changed

+169
-0
lines changed
+168
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
//
2+
//
3+
// File Name : Brother_Typewriter.c
4+
// Author : Ted Fried, MicroCore Labs
5+
// Creation : 8/27/2020
6+
// Code Type : Synthesizable
7+
//
8+
// Description:
9+
// ============
10+
//
11+
// Arduino-Leonardo converter for UART to Brother Word Processor Typewriter
12+
//
13+
//
14+
//------------------------------------------------------------------------
15+
16+
#define SHIFT_ON 0x80
17+
#define SHIFT_OFF 0x81
18+
19+
20+
unsigned int char_count=0;
21+
unsigned int decoded_character=0;
22+
unsigned int uart_character=0;
23+
24+
25+
26+
27+
byte decoder_array[128] = {
28+
/* 0 1 2 3 4 5 6 7 8 9 */
29+
/* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30+
/* 1 */ 0xb0, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31+
/* 2 */ 0x00, 0x49, 0x4b, 0x38, 0x37, 0x39, 0x3f, 0x4c, 0x23, 0x16,
32+
/* 3 */ 0x0c, 0x8c, 0x04, 0x8c, 0xe4, 0xcc, 0x2c, 0xac, 0xec, 0xe4,
33+
/* 4 */ 0x9c, 0x0c, 0x1c, 0xbc, 0xe4, 0xb4, 0x74, 0xf4, 0x0c, 0x8c,
34+
/* 5 */ 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0xdc, 0xdc,
35+
/* 6 */ 0x00, 0xbc, 0x59, 0xf4, 0x4c, 0x86, 0x46, 0xc6, 0x26, 0xa6,
36+
/* 7 */ 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
37+
/* 8 */ 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, 0x9e,
38+
/* 9 */ 0x5e, 0xba, 0x03, 0xba, 0x5e, 0xb4, 0x53, 0x86, 0x46, 0xc6,
39+
/* 10 */ 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6,
40+
/* 11 */ 0x76, 0xf6, 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
41+
/* 12 */ 0x1e, 0x9e, 0x5e, 0xba, 0x5e, 0xba, 0x53, 0x55 };
42+
43+
44+
45+
//------------------------------------------------------------------------
46+
//------------------------------------------------------------------------
47+
48+
void setup()
49+
{
50+
Serial.begin(300); // UART to the Host
51+
pinMode (10, INPUT) ; // hi-Z the CLK Pin
52+
pinMode (11, INPUT) ; // hi-Z the DATA Pin
53+
pinMode (12, OUTPUT) ;
54+
}
55+
56+
//------------------------------------------------------------------------
57+
//------------------------------------------------------------------------
58+
59+
void pause()
60+
{
61+
digitalWrite(12, LOW);
62+
digitalWrite(12, LOW);
63+
digitalWrite(12, LOW);
64+
digitalWrite(12, LOW);
65+
digitalWrite(12, LOW);
66+
return;
67+
}
68+
69+
70+
//------------------------------------------------------------------------
71+
//------------------------------------------------------------------------
72+
73+
void send_to_typewriter(unsigned char char_out)
74+
{
75+
76+
// Shift out the converted byte to the typewriter.
77+
// Send as "open collector", or drive logic '0', but
78+
// let bus go high-impedance (turn off IO output) for logic '1'
79+
//
80+
81+
if ((char_out&0x80) != 0) pinMode (11, INPUT); else pinMode (11, OUTPUT); pause(); // DATA 7
82+
pinMode (10, OUTPUT); pause(); // CLK = 0
83+
pinMode (10, INPUT); pause(); // CLK = hi-Z
84+
85+
if ((char_out&0x40) != 0) pinMode (11, INPUT); else pinMode (11, OUTPUT); pause(); // DATA 6
86+
pinMode (10, OUTPUT); pause(); // CLK = 0
87+
pinMode (10, INPUT); pause(); // CLK = hi-Z
88+
89+
if ((char_out&0x20) != 0) pinMode (11, INPUT); else pinMode (11, OUTPUT); pause(); // DATA 5
90+
pinMode (10, OUTPUT); pause(); // CLK = 0
91+
pinMode (10, INPUT); pause(); // CLK = hi-Z
92+
93+
if ((char_out&0x10) != 0) pinMode (11, INPUT); else pinMode (11, OUTPUT); pause(); // DATA 4
94+
pinMode (10, OUTPUT); pause(); // CLK = 0
95+
pinMode (10, INPUT); pause(); // CLK = hi-Z
96+
97+
if ((char_out&0x08) != 0) pinMode (11, INPUT); else pinMode (11, OUTPUT); pause(); // DATA 3
98+
pinMode (10, OUTPUT); pause(); // CLK = 0
99+
pinMode (10, INPUT); pause(); // CLK = hi-Z
100+
101+
if ((char_out&0x04) != 0) pinMode (11, INPUT); else pinMode (11, OUTPUT); pause(); // DATA 2
102+
pinMode (10, OUTPUT); pause(); // CLK = 0
103+
pinMode (10, INPUT); pause(); // CLK = hi-Z
104+
105+
if ((char_out&0x02) != 0) pinMode (11, INPUT); else pinMode (11, OUTPUT); pause(); // DATA 1
106+
pinMode (10, OUTPUT); pause(); // CLK = 0
107+
pinMode (10, INPUT); pause(); // CLK = hi-Z
108+
109+
if ((char_out&0x01) != 0) pinMode (11, INPUT); else pinMode (11, OUTPUT); pause(); // DATA 0
110+
pinMode (10, OUTPUT); pause(); // CLK = 0
111+
pinMode (10, INPUT); pause(); // CLK = hi-Z
112+
113+
114+
pinMode (11, INPUT) ; // hi-Z the DATA Pin
115+
116+
return;
117+
}
118+
119+
120+
//------------------------------------------------------------------------
121+
//------------------------------------------------------------------------
122+
123+
void caps_on(unsigned char char_in)
124+
{
125+
// Send the SHIFT key to the typewriter if required.
126+
//
127+
if (uart_character>62 && uart_character<92) send_to_typewriter(SHIFT_ON);
128+
if (uart_character!=39 && uart_character>32 && uart_character<44) send_to_typewriter(SHIFT_ON);
129+
return;
130+
}
131+
132+
//------------------------------------------------------------------------
133+
//------------------------------------------------------------------------
134+
135+
void caps_off(unsigned char char_in)
136+
{
137+
// Debounce the SHIFT key to the typewriter.
138+
//
139+
if (uart_character>62 && uart_character<92) send_to_typewriter(SHIFT_OFF);
140+
if (uart_character!=39 && uart_character>32 && uart_character<44) send_to_typewriter(SHIFT_OFF);
141+
return;
142+
}
143+
144+
//------------------------------------------------------------------------
145+
//------------------------------------------------------------------------
146+
147+
void loop()
148+
{
149+
150+
// Poll the Host-side UART for characters to send to the typewriter.
151+
// Decode the ASCII characters into the sequence of commands to send to the typewriter.
152+
//
153+
if (Serial.available())
154+
{
155+
uart_character = Serial.read();
156+
decoded_character = decoder_array[uart_character];
157+
158+
caps_on(uart_character);
159+
delay(1);
160+
send_to_typewriter(decoded_character);
161+
delay(1);
162+
caps_off(uart_character);
163+
delay(1);
164+
165+
}
166+
167+
}
168+
Loading

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Misc:
2626

2727
Wheelwriter - FPGA based Printer Option for the IBM Wheelwriter 5
2828
Wheelwriter2 - Arduino Leonardo based Printer Option for the IBM Wheelwriter 5
29+
Brother Typewriter - Arduino Leonardo converts Serial RX to a Brother Word Processor
2930

3031
3132
For questions email me at www.MicroCoreLabs.com

0 commit comments

Comments
 (0)