Search the Community
Showing results for tags 'au2porta'.
-
There were several issues left unresolved while programing the MIDI IN interface for the ATARI8 joystick ports. The first was to revert back to using the Cassette Motor Control pin on the SIO port for data flow control. This was accomplished with the AU2PORTA shield design. The second consideration was the startup default joystick pin status. The joystick pins are set to high on startup and then grounded to zero by the joystick switches. There is some reverse logic in all of this that still gives me headaches. An Arduino pin set HIGH will turn on the optocoupler transistor and grounds the Atari Joystick pin resulting in a LOW logic level. The Arduino was programed to set all the joystick direction pins to HIGH at startup. PORTA contained 0. The Arduino inverted the MIDI data, thus the Atari was able to read the MIDI note number directly. This could be made to work but here is where the problem lies…….. I wanted to us an ATARIMAX cartridge to hold the programs to be used to produce the sounds. Read MIDI note number from PORTA (joystick port 1 and 2) and use it as index into the tone tables. The problem lay in the fact that the ATARIMAX menu expected to see the joystick working normally but the Arduino was setting all the pins to ground, thus confusing the ATARIMAX. The problem was temporarily solved by unplugging the Arduino before starting/or restarting the computer. A better solution was required. The solution was to start with all Arduino data pins set LOW, when the Arduino was started or reset. The curser keys on the Atari could be used to select the menu program and space bar would run it. Then the Arduino would read the MIDI note number and set pins according to bits. The Atari would read PORTA as the inverted number. The Atari then used an EOR #255 command to invert it a second time and then use that number as an index into the frequency table. This works as long as the MIDI instrument has not send data to the Arduino before turning on the Atari. A MIDI data byte to be sent to the Atari will set the data pins and the trigger, again confusing the AtariMax menu. Press the Arduino reset to clear the serial data buffer and reset the pin logic before restarting the Atari. At least nothing has to be unplugged. Arduino UNO compatible - AU2PORTA shield - MIDI shield These are the test programs for the Arduino and Atari used to troubleshoot the data transfer. The Arduino reads the MIDI data stream and picks out a channel 1 note on or note off command. It then sends a note number to the Atari; where it is used to turn on the note or turn it off. .ATR contains the M65 source Code and related files. READBYTE.atr .ZIP of the Arduino sketch. Atari_Monosynth_AU2PORTA.zip I think I'm at a good place to decide on my next project. I don't think I will go beyond a mono instrument. Some day I may retry shaping the sound using ADSR envelopes and combine 2 - 16bit tones for some kind of harmonic distortion. Or…………..
-
Back in January of 2015, I wanted of use a PING)) ultrasonic sensor to measure distance and send it to the Atari using the 850 - RS232 ports. I initially thought that I could move my hand in front of the sensor and the resulting change in desistance could be used to change the frequency of the sound command. This might have worked if the SIO port could be used to make sound .AND. transmit data to the 850 interface at the same time. It doesn't. So, I forgot about the sound and just got the distance data to the Atari and wrote up the blog entry. Now that the Arduino Uno to PORTA shield (AU2PORTA) is at my disposal, I can bypass the SIO port and receive the data through the Joystick ports to control the sound frequency. The Arduino reads the sensor data, scales it from 0 to 255, and sets the joystick pins. The Atari simply PEEKs the memory for PORTA and sets the SOUND command. -------------------------------------------------------- Hardware setup - Plug the AU2PORTA shield into the Arduino UNO. Connect the PING)) sensor to the Shield. PING)) ------- Arduino GND GND 5V 5V SIG D2 Plug the AU2PORTA joystick cables into the correct Atari joystick port. Arduino UNO program - /* This Arduino program receives data from a PING))sensor. Then scales the reading to an 8 bit number. That number is send to the Atari Joystick ports using the AU2PORTA shield. Pitch data is also sent to the Arduino IDE serial monitor for troubleshooting. PING))code example used to read sensor (Examples/06.Sensors/Ping) Kevin Packard January 2019 */ // Atari PORTA(54016) mapped to pins on arduino int porta0 = 4; int porta1 = 5; int porta2 = 6; int porta3 = 7; int porta4 = 8; int porta5 = 9; int porta6 = 10; int porta7 = 11; int trig1 = 3; const int pingPin = 2; PING)) //sensor data pin byte pitch = 0; byte lastPitch = 0; byte zero = 0; void setPorta(byte byteToMap){ // Sets digital pins to transfer data to Atari joystick ports(PORTA) // When digital port high, joystick pin shorted to ground or logic 0 if (byteToMap & B00000001){digitalWrite(porta0,HIGH);} else {digitalWrite(porta0,LOW);} if (byteToMap & B00000010){digitalWrite(porta1,HIGH);} else {digitalWrite(porta1,LOW);} if (byteToMap & B00000100){digitalWrite(porta2,HIGH);} else {digitalWrite(porta2,LOW);} if (byteToMap & B00001000){digitalWrite(porta3,HIGH);} else {digitalWrite(porta3,LOW);} if (byteToMap & B00010000){digitalWrite(porta4,HIGH);} else {digitalWrite(porta4,LOW);} if (byteToMap & B00100000){digitalWrite(porta5,HIGH);} else {digitalWrite(porta5,LOW);} if (byteToMap & B01000000){digitalWrite(porta6,HIGH);} else {digitalWrite(porta6,LOW);} if (byteToMap & B10000000){digitalWrite(porta7,HIGH);} else {digitalWrite(porta7,LOW);} } void setup() { pinMode(porta0,OUTPUT); pinMode(porta1,OUTPUT); pinMode(porta2,OUTPUT); pinMode(porta3,OUTPUT); pinMode(porta4,OUTPUT); pinMode(porta5,OUTPUT); pinMode(porta6,OUTPUT); pinMode(porta7,OUTPUT); pinMode(trig1,OUTPUT); setPorta(zero); Serial.begin(9600);// } void loop() { long duration; // from Ping example pinMode(pingPin, OUTPUT); digitalWrite(pingPin, LOW); delayMicroseconds(2); digitalWrite(pingPin, HIGH); delayMicroseconds(5); digitalWrite(pingPin, LOW); pinMode(pingPin, INPUT); duration = pulseIn(pingPin, HIGH); // if(duration < 200 || duration >3500){duration = 200;} // duration 200 us note off pitch = map(duration,200,3500,0,255); // Scale duration for Atari pitch setting if(pitch != lastPitch){ // look for pitch change from last setting digitalWrite(trig1,HIGH); // let atari know not to read pitch while port is being set setPorta(pitch); // set pins with pitch data digitalWrite(trig1,LOW); // let atari know data ok to read lastPitch = pitch; // store latest pitch Serial.print(pitch); // display pitch in Serial Monitor window(if connected) Serial.println(); } delay(100); // delay for PING)) and atari to sync. }// End of Listing Atari BASIC code example - 100 IF STRIG(0)=0 THEN 100 200 PITCH=PEEK(54016) 210 IF PITCH=255 THEN VOLUME=0 220 IF PITCH<>255 THEN VOLUME=10 300 IF PITCH=LASTPITCH THEN 100 400 SOUND 0,PITCH,10,VOLUME 500 LASTPITCH=PITCH 510 ? PITCH 600 GOTO 100 While the programs are running, you should be able to move your hand (or other sound reflective object) closer and further from the PING)) sensor to hear a change in pitch.
-
Over the years I've been using an Arduino UNO to setup data for transfer to the Atari Joystick ports. The first attempt was to read the data from a Wii nunchuk and translate it to joystick movements. Lately I've been experimenting reading midi data using an Arduino Midi Shield, along with using the Cassette Motor Control pin on the SIO port as feedback to the Arduino. You may have read some of these blogs. During the "Switched On POKEY" music experiments, there were many modifications tried and some were put off for later evaluation. At first the cassette motor control(CMC) pin on the SIO was used to signal the Arduino. Then bit 7 of PORTA(joystick) was set as output and trigger 2 was set and used for bit 7 input. It worked but didn't solve a click problem I thought I was having when switching the CMC. MIDI setup then and now: It seemed time to gather my thoughts and solder together a prototype shield. And to, establish a point of reference for beginning future experiments. From now on I will refer to this Arduino Uno shield as AU2PORTA. This shield will be able to set the joystick direction pins (PORTA) and the 2 triggers. With 1 bit output from the Atari's CMC pin, wired to be used to signal the Arduino when needed. The parallel data transfer used most of the digital lines. D0 and D1 are used for serial communication with the MIDI shield (or computer) leaving D2 free for other uses. The Analog signal lines are still avalible for analog input, I2C devices or reading voltages of digital logic signals. The ground for each of the joysticks are separate. This allows the shield to be hooked up to a joystick port of different computers and maintain separate grounds. This might come in handy someday. The circuits use 11 optocouplers (PS2501). Some people may think I am being overprotective of my Atari computers but I prefer to think of it as being very protective of my computers. These isolators will keep the Arduino and Atari circuits from harming each other, no matter what gets hooked up to the Arduino. Note: The prototype circuit uses the PS2501 for CMC feedback bit and worked. I grabbed a PS2502-1 optocoupler from the parts bin while building the shield. The PS2501 has one transistor while the PS2502 has two in a Darlington configuration. They both work. The next shield that gets built will use a PS2501-1. The shield was soldered and tested using the following Arduino program that set all the digital pins HI and then LOW. *The Arduino toggles the pins wired for the Atari to read. * *The CMC circuit is not tested. * */ // Atari PORTA(54016) mapped to pins on Arduino int porta0 = 4; int porta1 = 5; int porta2 = 6; int porta3 = 7; int porta4 = 8; int porta5 = 9; int porta6 = 10; int porta7 = 11; int trig1 = 3; int trig2 = 12; int digPin=0; void setup() { pinMode(porta0,OUTPUT); pinMode(porta1,OUTPUT); pinMode(porta2,OUTPUT); pinMode(porta3,OUTPUT); pinMode(porta4,OUTPUT); pinMode(porta5,OUTPUT); pinMode(porta6,OUTPUT); pinMode(porta7,OUTPUT); pinMode(trig1,OUTPUT); pinMode(trig2,OUTPUT); } void loop() { for (digPin = 3; digPin<13; digPin++) { digitalWrite(digPin,HIGH); } delay(200); for(digPin = 3; digPin<13; digPin++) { digitalWrite(digPin,LOW); } delay(200); } Then when the Arduino and Shield are hooked up to the joystick ports this next small Atari BASIC program was used to read the trigger and joystick. 15 means all Arduino controlled digital pins are LOW. 0 for all HIGH. Triggers; Arduino is HIGH and Atari reads 0.(Note the reverse logic. Arduino - LOW/Atari - HIGH. Very important when programing) 10 ? STICK(0),STRIG(0),STICK(1),STRIG(1):LAST = STRIG (0) 20 IF STRIG(0)=LAST THEN 20 30 GOTO 10 Once the 3 bad solder connections were fixed, the following program was used to toggle the Cassette Motor control on the SIO port. A Volt meter was used to read the voltage drop across the 1K resistor as it was switched. Atari HIGH - Arduino HIGH. 10 POKE 54018,52:REM TURN ON CMC 20 FOR X=1 TO 200:NEXT X 30 POKE 54018,60:REM TURN OFF CMC 40 FOR X=1 TO 200: NEXT X 50 GOTO 10 The next task is to optimize the data transfer routines and resolve problems that are caused by the reverse pin logic and the startup logic defaults.