Jump to content
IGNORED

Atari 1050 - Track Display


macsonny

Recommended Posts

6 hours ago, TGB1718 said:

What controller are you using ? 

 

It may be a timing issue i.e. too fast or too slow responding

 

Unfortunately I've not had time to try mine in a 1050 which is using a Raspberry Pi Pico, I do anticipate some timing

issues as it's a lot faster than the teensy.

Teensy 4.0. What settings should I have?

Link to comment
Share on other sites

10 hours ago, TGB1718 said:

Maybe @Chri O. can advise, I believe he's using a Teensy

Hi @Chri O. - what was the configuration of the Teensy 4.0 you used as I still can't get mine going.

 

Also, you talked about a different way of building the circuit by removing the voltage divider and using a SN74HC245N IC. Do you have a schematic for that?

Link to comment
Share on other sites

No special settings necessary, everything is set up in the CODE assuming you have no issues with wiring.

22 minutes ago, macsonny said:

Also, you talked about a different way of building the circuit by removing the voltage divider and using a SN74HC245N IC. Do you have a schematic for that?

Sorry not yet.

Link to comment
Share on other sites

I am thinking maybe you have issue with the Track 0 sensor wiring connection ?  

Perhaps editing the loop() slightly for testing like this will get you going.

void loop() {
  noInterrupts();
  NewTcount = Tcount;
  interrupts();
  /* // bypassing Track 0 test.
     if (digitalReadFast(N_TRACK00_Pin) == HIGH) { // if Track 0 sensor @5volts then set TRACK count to 0
      NewTcount = 0;

      //Serial.print("N_TRACK00_Pin:"); // debug print
      //Serial.println(digitalReadFast(N_TRACK00_Pin)); // debug print
      //delay(50); // debug delay
    }
  */

  if (OldTcount != NewTcount) {
    OldTcount = NewTcount;
    display.clearDisplay();
    display.setCursor(10, 4);
    if (NewTcount < 10) {
      display.print("0");
    }
    display.print(NewTcount);
    display.display();
  }
}

 

 

 

 

Link to comment
Share on other sites

6 hours ago, Chri O. said:

I am thinking maybe you have issue with the Track 0 sensor wiring connection ?  

Perhaps editing the loop() slightly for testing like this will get you going.


void loop() {
  noInterrupts();
  NewTcount = Tcount;
  interrupts();
  /* // bypassing Track 0 test.
     if (digitalReadFast(N_TRACK00_Pin) == HIGH) { // if Track 0 sensor @5volts then set TRACK count to 0
      NewTcount = 0;

      //Serial.print("N_TRACK00_Pin:"); // debug print
      //Serial.println(digitalReadFast(N_TRACK00_Pin)); // debug print
      //delay(50); // debug delay
    }
  */

  if (OldTcount != NewTcount) {
    OldTcount = NewTcount;
    display.clearDisplay();
    display.setCursor(10, 4);
    if (NewTcount < 10) {
      display.print("0");
    }
    display.print(NewTcount);
    display.display();
  }
}

 

 

 

 

Sorry to be painful and ask so many questions. I'm a bit confused about the suggested code here. Do I comment out the If (DigitialReadFast.......... and put in the lines starting with Serial.print.....?

 

 

Link to comment
Share on other sites

void loop() {
  noInterrupts();
  NewTcount = Tcount;
  interrupts();
  /* // bypassing Track 0 test.
     if (digitalReadFast(N_TRACK00_Pin) == HIGH) { // if Track 0 sensor @5volts then set TRACK count to 0
      NewTcount = 0;

      //Serial.print("N_TRACK00_Pin:"); // debug print
      //Serial.println(digitalReadFast(N_TRACK00_Pin)); // debug print
      //delay(50); // debug delay
    }
  */

  if (OldTcount != NewTcount) {
    OldTcount = NewTcount;
    display.clearDisplay();
    display.setCursor(10, 4);
    if (NewTcount < 10) {
      display.print("0");
    }
    display.print(NewTcount);
    display.display();
  }
}

 

 

 

The temporary fix is commenting out the reading of the track 0 sensor, not the /* and later */, that comments out

that whole block (in bold above), so ignoring the track 0 read, if your wiring is ok , you should see the counter increase or decrease

depending on the head direction, if it seem of with that, then as @Chri O. suggests there may be a problem

with the track 0 read.

Link to comment
Share on other sites

1 minute ago, xrbrevin said:

Ive managed to get the code to compile on the arduino nano but it still requires some pesky meddlement to get it functioning right.

the track zero works fine on boot but as soon as the head moves 1 track inward, the display shows 25 instead of 1. subsequent head movements flicker 00 then it returns to 25. after Goonies loads in, it loads demo levels. during this it flips between 6 and 7, 22 and 23 - its bizarre. im struggling to see a pattern of behaviour to diagnose it.

 

@Chri O. have you tried your version on a Tandon mech 1050?

 

the serial monitor shows Tcount movement around 253, 254, 255 so the OLED display is only showing the first two digits (as per the '25' above).

255 in binary is 11111111, the 3 count variables are set as bytes in the code - is there a correlation? i tried defining them as 'INT' instead but no joy. i thought about using a division formula to convert the 0-255 range into 1-40 but the Tcount readout is not changing proportionately in relation to the head movement.

 

Are you able to explain the roles of Tcount, OldTcount and NewTcount?

Cheers

 

 

 

Exact same results for me. I'm trying the new code suggested to see if that helps diagnose the issue.

Link to comment
Share on other sites

Ive managed to get the code to compile on the arduino nano but it still requires some pesky meddlement to get it functioning right.

the track zero works fine on boot but as soon as the head moves 1 track inward, the display shows 25 instead of 1. subsequent head movements flicker 00 then it returns to 25. after Goonies loads in, it loads demo levels. during this it flips between 6 and 7, 22 and 23 - its bizarre. im struggling to see a pattern of behaviour to diagnose it.

 

@Chri O. have you tried your version on a Tandon mech 1050?

 

the serial monitor shows Tcount movement around 253, 254, 255 so the OLED display is only showing the first two digits (as per the '25' above).

255 in binary is 11111111, the 3 count variables are set as bytes in the code - is there a correlation? i tried defining them as 'INT' instead but no joy. i thought about using a division formula to convert the 0-255 range into 1-40 but the Tcount readout is not changing proportionately in relation to the head movement.

 

Are you able to explain the roles of Tcount, OldTcount and NewTcount?

Cheers

 

 

 

Link to comment
Share on other sites

6 minutes ago, macsonny said:

Exact same results for me. I'm trying the new code suggested to see if that helps diagnose the issue.

yeah i saw that and weirder still, youre using the teensy so its closer to the original!

thats why i wondered if its a mech thing - i dont have a WST drive to try it on so i have to find a solution with what i have

Link to comment
Share on other sites

4 minutes ago, xrbrevin said:

yeah i saw that and weirder still, youre using the teensy so its closer to the original!

thats why i wondered if its a mech thing - i dont have a WST drive to try it on so i have to find a solution with what i have

I have both drive types - 2 of each actually.

 

Is TANDON the one made in Singapore or Hong Kong. I never get it right?

 

I have a Happy in one drive and a Mega Speedy (installed today) in another drive. 

Link to comment
Share on other sites

For info - my build doesnt use the voltage divider part of the circuit as the arduino can use 5v

also, i dont have any 15k resistors so i tried 10k and 20k but neither option seemed to make a diff'rence..!

Link to comment
Share on other sites

1 hour ago, xrbrevin said:

Are you able to explain the roles of Tcount, OldTcount and NewTcount?

Cheers

3 variables to keep track (excuse the pun) of where the head is, all initially set to zero.

Tcount is incremented or decremented during the interrupt routine depending if your stepping in or out.

 

In the main loop, NewTcount is set to Tcount.

Then it is compared to OldTcount and if different set OldTcount to NewTcount, then 

update the display with NewTcount.

This part of the routing will only change the display if there has been movement.

 

If track 0 is HIGH, set Tcount and NewTcount to zero and thus the display will be set to zero.

 

Hope that helps.

 

Where the timing might be out is the interrupt activates on either NS02 or NS04 RISING, it then checks

the other phase NS01 or NS04 and if high, increment or decrement, if you read too slow, then you miss the pulse

 

Link to comment
Share on other sites

thanks for the reply. i had deciphered as much but im trying to determine the overall procedure or 'flow-chart' of the design. primarily, im not clear on the role of NewTcount and OldTcount.

can the loop function without NewTcount and OldTcount?

surely only Tcount is needed?

Link to comment
Share on other sites

38 minutes ago, xrbrevin said:

can the loop function without NewTcount and OldTcount?

I hope you understand that the loop gets executed thousand times per second.

Trying to print to the screen thousand times per second probably not going to work.

Yes my 1050 is WST type.

Edited by Chri O.
WST
Link to comment
Share on other sites

if (OldTcount != NewTcount) { // Comparison Operators != (not equal to)

   // do something only if the comparison result is true

}

 

 

It's very important to turn off the printing inside the interrupt routine

especially if you port this to Arduino Uno and compatible.

It works ok on Teensy 4.0 but not recommended.

 

void IRQ_NS02() {

  if (digitalReadFast(interruptPin_NS01) == HIGH) {

    Tcount ++;

  } else {

    Tcount --;

  }

  // Serial.print("T NS02 :"); // debug print

  // Serial.println(Tcount); // debug print

}

void IRQ_NS04() {

  if (digitalReadFast(interruptPin_NS03) == HIGH) {

    Tcount ++;

  } else {

    Tcount --;

  }

  // Serial.print("T NS04 :"); // debug print

  // Serial.println(Tcount); // debug print

}

Link to comment
Share on other sites

Arduino uno code.

/*********************************************************************
  MIT License
  Copyright (c) [2022] [Chris O.]
  Atari 1050 - Track Display, ver 01.

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  SOFTWARE.
*********************************************************************/

// https://github.com/wonho-maker/Adafruit_SH1106
/*********************************************************************
  Change the adafruit SSD1306 to SH1106
  SH1106 driver don't provide several functions such as scroll commands.
*********************************************************************/
// Teensy SH1106 driver fix https://forum.pjrc.com/threads/68174-OLED-problems

const byte VER = 2;

// ARDUINO UNO
const byte interruptPin_NS01 = 4; // NS01 @  U2 ic pin 2, NOT USED FOR interrupt.
const byte interruptPin_NS02 = 2; // NS02 @  U2 ic pin 7
const byte interruptPin_NS03 = 5; // NS03 @  U3 ic pin 2  NOT USED FOR interrupt.
const byte interruptPin_NS04 = 3; // NS04 @  U3 ic pin 7
const byte N_TRACK00_Pin =     6; // Q5 @ R#59 Track 00 sensor.

/* // TEENSY 4.0
  const byte interruptPin_NS01 = 2; // NS01 @  U2 ic pin 2, NOT USED FOR interrupt.
  const byte interruptPin_NS02 = 3; // NS02 @  U2 ic pin 7
  const byte interruptPin_NS03 = 4; // NS03 @  U3 ic pin 2  NOT USED FOR interrupt.
  const byte interruptPin_NS04 = 5; // NS04 @  U3 ic pin 7
  const byte N_TRACK00_Pin =     6; // Q5 @ R#59 Track 00 sensor.
*/

volatile byte Tcount = 0;
byte NewTcount = Tcount;
byte OldTcount = Tcount;

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH1106.h> // OLED 1.30" @ I2C addr. 0x3C

#define OLED_RESET -1 // -1, NO RESET
Adafruit_SH1106 display(OLED_RESET);

#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH  16
static const unsigned char PROGMEM logo16_glcd_bmp[] =
{ B00000000, B11000000,
  B00000001, B11000000,
  B00000001, B11000000,
  B00000011, B11100000,
  B11110011, B11100000,
  B11111110, B11111000,
  B01111110, B11111111,
  B00110011, B10011111,
  B00011111, B11111100,
  B00001101, B01110000,
  B00011011, B10100000,
  B00111111, B11100000,
  B00111111, B11110000,
  B01111100, B11110000,
  B01110000, B01110000,
  B00000000, B00110000
};

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  while (!Serial && millis() < 4000 );
  Serial.println("Basic ARDUINO UNO 1050 Test:");

  display.begin(SH1106_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64), SH1106 addr 0x3C.

  // Show image buffer on the display hardware.
  // Since the buffer is intialized with an Adafruit splashscreen
  // internally, this will display the splashscreen.
  display.display();
  delay(1000);

  // Clear the buffer.
  display.clearDisplay();
  // Show the display buffer on the hardware.
  // NOTE: You _must_ call display after making any drawing commands
  // to make them visible on the display hardware!
  display.display();

  display.setTextSize(2);
  // display.setTextColor(WHITE);
  display.setTextColor(BLACK, WHITE); // 'inverted' text
  display.setCursor(0, 5);
  display.println("Atari 1050");
  //
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(10, 30);
  display.println("Track Display Test");
  //
  display.setCursor(10, 55);
  display.print("V.0");
  display.println(VER);
  display.display();
  // display setup for loop()
  display.clearDisplay();
  display.setCursor(5, 5);
  display.setTextSize(9);
  delay(1000);
  if (NewTcount < 10) {
    display.print("0");
  }
  display.print(NewTcount);
  display.display();

  //pinMode(ledPin, OUTPUT);
  pinMode(N_TRACK00_Pin, INPUT_PULLUP);
  pinMode(interruptPin_NS01, INPUT_PULLUP);
  pinMode(interruptPin_NS02, INPUT_PULLUP);
  // edge-triggered interrupt on rising edge (low to high).
  attachInterrupt(digitalPinToInterrupt(interruptPin_NS02), IRQ_NS02, RISING); //RISING, CHANGE, FALLING
  pinMode(interruptPin_NS03, INPUT_PULLUP);
  pinMode(interruptPin_NS04, INPUT_PULLUP);
  // edge-triggered interrupt on rising edge (low to high).
  attachInterrupt(digitalPinToInterrupt(interruptPin_NS04), IRQ_NS04, RISING); //RISING, CHANGE, FALLING
}

void loop() {
  // put your main code here, to run repeatedly:
  noInterrupts();
  NewTcount = Tcount;
  interrupts();


  if (digitalRead(N_TRACK00_Pin) == HIGH) { // if Track 0 sensor @5volts then set TRACK count to 0
    NewTcount = 0;
    //noInterrupts();
    //Tcount = 0;
    //interrupts();
  }

  if (OldTcount != NewTcount) {
    OldTcount = NewTcount;
    display.clearDisplay();
    display.setCursor(10, 4);
    if (NewTcount < 10) {
      display.print("0");
      Serial.print("0");
    }
    display.print(NewTcount);
    display.display();
    Serial.println(NewTcount);
  }
}

void IRQ_NS02() {
  digitalWrite(LED_BUILTIN, LOW);
  if (digitalRead(interruptPin_NS01) == HIGH) {
    Tcount ++;
  } else {
    Tcount --;
  }
  //digitalWrite(LED_BUILTIN, LOW);
  //Serial.print("T NS02 :"); // debug print
  //Serial.println(Tcount); // debug print
}

void IRQ_NS04() {
  digitalWrite(LED_BUILTIN, LOW);
  if (digitalRead(interruptPin_NS03) == HIGH) {
    Tcount ++;
  } else {
    Tcount --;
  }
  //digitalWrite(LED_BUILTIN, LOW);
  //Serial.print("T NS04 :"); // debug print
  //Serial.println(Tcount); // debug print
}

 

Link to comment
Share on other sites

 

1 hour ago, kheller2 said:

I thought the WST vs Tandon used different stepper encodings.

thanks, for reminding me of this, it explains my results

at one stage in my tweakings i saw the display advance 1 track then immediately back 1, then it advanced 2. in doing so it was sort of correct on every other step(!)

having now seen it, i have a (slightly) better understanding of the half-step operation of the tandon mech in the above link. although it doesnt make the arduino code any easier!

Edited by xrbrevin
bremp
Link to comment
Share on other sites

1 hour ago, xrbrevin said:

 

thanks, for reminding me of this, it explains my results

at one stage in my tweakings i saw the display advance 1 track then immediately back 1, then it advanced 2. in doing so it was sort of correct on every other step(!)

having now seen it, i have a (slightly) better understanding of the half-step operation of the tandon mech in the above link. although it doesnt make the arduino code any easier!

You know sometimes discreet logic chips are simpler….

  • Like 1
Link to comment
Share on other sites

17 hours ago, macsonny said:

Ok. I will try a WST drive in the next few days and will report back. Might be drive model specific.

I can confirm that after installing in a WST drive that it 100% works - so it's a difference between the Tandon and WST drives.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...