![]() |
![]() |
#1 |
old bearded fool
Join Date: Jan 2010
Location: Bangkok
Age: 56
Posts: 735
|
![]()
I've recently completed coding an Arduino variant of Txtzyme for Teensy++ 2.0 which can be used via UART to Serial with the Amiga. Instead of relying on USB alone, this version can do both, simultaneously by queueing the commands from both USB and UART ports on the Teensy. There are some other changes as well allowing longer command strings etc. I call this version AmiZyme.
This is great when you want to read/write the TTL and PWM pins on the Teensy (Atmel microcontroller) via simple commands over serial from the Amiga, and you can have another computer hooked up the same time via USB if needed, sharing the same Teensy device. For example, to blink a LED you can issue this command in Txtzyme syntax. Code:
5{ 6d 1o 100m 0o 100m } Here's the command list which can be triggered with 'h' when hooked with your Amiga terminal program, like NComm V3.06 (keyfile). Code:
AmiZyme commands: ------------------- 0-9<num> enter number <num>p print number via uart <num>P print number via usb <pin*>i digital read input <pin*><num>o digital write output <num>m msec delay <num>u usec delay <num>{} repeat k<num> loop count _<words>_ print words via uart -<words>- print words via usb <pin*>s analog read input (0-1023) <pin*><num>w analog write output (0-1023) v print version via uart V print version via usb h print help via uart H print help via usb (* Arduino pin reference is used followed by a 'd', eg. '6d' for the LED. https://github.com/WardCunningham/Txtzyme Here's the AmiZyme source code for Arduino. Code:
// AmiZyme v1.2 by modrobert 2014 // Based on Txtzyme by Ward Cunningham // // Changelog: // 1.2 // * Added [w] digitalWrite command. // * Updated [h]elp info. // 1.1 // * Rewrote UART and USB handling to allow simultaneous input, // commands are queued. // * Changed project name from AmigaZyme to AmiZyme. // 1.0 // * Initial release. const int BUFSIZE = 1024; unsigned int x = 0; int d = 13; // This line defines a "Uart" object to access the serial port HardwareSerial Uart = HardwareSerial(); void setup() { // USB serial, baudrate below is meaningless, 12mbit. Serial.begin(9600); // Teensy++ 2.0 pin 2 RX, Pin 3 TX. Uart.begin(38400); } void loop() { char buf[BUFSIZE]; while (1) { if (Uart.available() > 0) { txtUartRead(buf, BUFSIZE); break; } if (Serial.available() > 0) { txtSerialRead(buf, BUFSIZE); break; } } txtEval(buf); } void txtUartRead (char *p, unsigned int n) { unsigned int i = 0; while (i < (n-1)) { while (!Uart.available()); char ch = Uart.read(); if (ch == '\r' || ch == '\n') break; if (ch >= ' ' && ch <= '~') { *p++ = ch; i++; } } *p = 0; Uart.print("\r\n"); } void txtSerialRead (char *p, unsigned int n) { unsigned int i = 0; while (i < (n-1)) { while (!Serial.available()); char ch = Serial.read(); if (ch == '\r' || ch == '\n') break; if (ch >= ' ' && ch <= '~') { *p++ = ch; i++; } } *p = 0; Serial.print("\r\n"); } void txtEval (char *buf) { unsigned int k = 0; char *loop; char ch; while ((ch = *buf++)) { switch (ch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': x = ch - '0'; while (*buf >= '0' && *buf <= '9') { x = x*10 + (*buf++ - '0'); } break; case 'p': Uart.println(x); break; case 'P': Serial.println(x); break; case 'd': d = x; break; case 'i': x = digitalRead(d); break; case 'o': digitalWrite(d, x%2); break; case 'm': delay(x); break; case 'u': delayMicroseconds(x); break; case '{': k = x; loop = buf; while ((ch = *buf++) && ch != '}') { } case '}': if (k) { k--; buf = loop; } break; case 'k': x = k; break; case '_': while ((ch = *buf++) && ch != '_') { Uart.print(ch); } Uart.println(); break; case '-': while ((ch = *buf++) && ch != '-') { Serial.print(ch); } Serial.println(); break; case 's': x = analogRead(x); break; case 'w': // Analog write takes 0-255, analog read 0-1023, hence the division below. analogWrite(d, x/4); break; case 'h': Uart.print("AmiZyme commands:\r\n-------------------\r\n0-9<num>\tenter number\r\n<num>p\t\tprint number via uart\r\n<num>P\t\tprint number via usb\r\n<pin*>i\t\tdigital read input\r\n<pin*><num>o\tdigital write output\r\n<num>m\t\tmsec delay\r\n<num>u\t\tusec delay\r\n<num>{}\t\trepeat\r\nk<num>\t\tloop count\r\n_<words>_\tprint words via uart\r\n-<words>-\tprint words via usb\r\n<pin*>s\t\tanalog read input (0-1023)\r\n<pin*><num>w\tanalog write output (0-1023)\r\nv\t\tprint version via uart\r\nV\t\tprint version via usb\r\nh\t\tprint help via uart\r\nH\t\tprint help via usb\r\n(* Arduino pin reference is used followed by a 'd', eg. '6d' for the LED.\r\n"); break; case 'H': Serial.print("AmiZyme commands:\r\n-------------------\r\n0-9<num>\tenter number\r\n<num>p\t\tprint number via uart\r\n<num>P\t\tprint number via usb\r\n<pin*>i\t\tdigital read input\r\n<pin*><num>o\tdigital write output\r\n<num>m\t\tmsec delay\r\n<num>u\t\tusec delay\r\n<num>{}\t\trepeat\r\nk<num>\t\tloop count\r\n_<words>_\tprint words via uart\r\n-<words>-\tprint words via usb\r\n<pin*>s\t\tanalog read input (0-1023)\r\n<pin*><num>w\tanalog write output (0-1023)\r\nv\t\tprint version via uart\r\nV\t\tprint version via usb\r\nh\t\tprint help via uart\r\nH\t\tprint help via usb\r\n(* Arduino pin reference is used followed by a 'd', eg. '6d' for the LED.\r\n"); break; case 'v': Uart.println("AmiZyme v1.2 for Teensy++ 2.0 by modrobert in 2014."); Uart.println("Created with classic computers like the Amiga in mind."); Uart.println("A variant of Txtzyme with support for both UART and USB serial."); break; case 'V': Serial.println("AmiZyme v1.2 for Teensy++ 2.0 by modrobert in 2014."); Serial.println("Created with classic computers like the Amiga in mind."); Serial.println("A variant of Txtzyme with support for both UART and USB serial."); break; } } } Thanks to the wonders of AREXX in AmigaOS (WB3.1) I've also made a REXX script using NComm to send the commands directly from the Amiga shell using 'rx amizyme.rexx <"command">', or for use by other programs/scripts, here it is: Code:
/* amizyme arexx script! */ options results /* Turn on result codes */ address 'ncomm' /* Our port name */ inactivity 2 /* Even if we didn't receive a linefeed, we will get a copy of the last (current) line after 2 seconds of inactivity. If you only want to receive a line when a linefeed is received, set inactivity to 0 */ l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit if ~RMHReadArgs("CMD/A,SAY/S") then do call PrintFault() exit end cmd = parm.0.value"\n" if RC == 20 then exit /* Exit if user selected quit NComm */ clearbuffer send cmd do forever /* for (;;) */ address 'ncomm' wait /* Wait for anything, return current line */ if RC == 20 then exit /* Exit if user selected Quit NComm */ if parm.1.flag then say result /* Write line to CLI window */ else leave end First I was thinking about posting a thread specifically about AmiZyme here at EAB, but since I'm curious about other users here using Amiga in their lab (actually my hardware "lab" is more of a small shack with a soldering iron, but it sounds nicer calling it a "lab"). Amiga is great with its serial and parallel port for these types of projects. Please share your projects here, if you use the Amiga as a tool in your hardware (electronics) projects, and how you do it. Even if software related, for example, if you wrote or ported software for Amiga to interface with certain hardware devices. Last edited by modrobert; 02 February 2014 at 09:00. Reason: Spelling/grammar and stuff. |
![]() |
![]() |
#2 |
Registered User
Join Date: Oct 2011
Location: Estoril/Portugal
Age: 46
Posts: 115
|
I have an Arduino Uno and 2 Nano. I have done some small projects with them.
but i dont know what is this Txtzyme, can you explain a bit what it is? You connect an Arduino with a db25 port or something like that? That would be great to join both Miggy and Arduino! |
![]() |
![]() |
#3 | |
old bearded fool
Join Date: Jan 2010
Location: Bangkok
Age: 56
Posts: 735
|
Txtzyme is mainly an interpreter to control the TTL pins on an AVR device, so instead of writing code and flashing it to the device each time you have a small project (eg. read input of a pin and then set another pin high, or just send a series of states to one pin), with Txtzyme you can just send commands over the serial port instead, either from a terminal program, or from software you coded on the computer.
In general it makes "trial and error" testing a lot faster, just edit the command a bit, and send again. Here are some syntax examples of usage from Ward Cunningham's project page. Quote:
Also, the command buffer is 1024 Bytes instead of 60 as Txtzyme. I did that mainly because the command buffer also serves as a queue in AmiZyme, from both USB and UART serial ports. Last edited by modrobert; 06 February 2014 at 06:04. Reason: Added bullet points for the examples. |
|
![]() |
![]() |
#4 |
Registered User
Join Date: Oct 2012
Location: Germany
Posts: 585
|
I connected an Arduino to my Amiga 4000D via the "mystery header" a while ago. The Arduino reads a few temperature sensors inside the case and transfers the data to the Amiga (It can only send, not receive).
You can find pictures and description here: http://www.a1k.org/forum/showthread....t=mysteryduino It's in german, but google translate does a fairly good job. I'll come up with a better translation, if someone's interested. ![]() |
![]() |
![]() |
#5 |
Registered User
Join Date: Oct 2011
Location: Estoril/Portugal
Age: 46
Posts: 115
|
Hi,
what is the: "A4000D (and only on the non-cr version). " CR is cost reduction ? I have an 4000D Rev B Only works with A4000 non-cost reduction? |
![]() |
![]() |
#6 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,526
|
|
![]() |
![]() |
#7 |
Registered User
Join Date: Oct 2012
Location: Germany
Posts: 585
|
What hooverphonique said. CRs are quite rare compared to Rev 2 / Rev B, though.
|
![]() |
![]() |
#8 |
old bearded fool
Join Date: Jan 2010
Location: Bangkok
Age: 56
Posts: 735
|
I love it...hehe -> "Mysterious girl, I wanna get close to you ..."
|
![]() |
![]() |
#9 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,267
|
That's a great use of ARexx. It's cool how you can just tap into programs' functionality and glue them together. ARexx was definitely under-appreciated on the Amiga.
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
V-Lab Motion documentation | salax54 | request.Other | 3 | 09 April 2023 15:28 |
Atari C-lab Falcon For Sale!! | SPARKYPETE | MarketPlace | 22 | 11 September 2008 01:49 |
|
|