xrbrevin #1 Posted October 22, 2019 (edited) despite no formal training, im attempting to create a track display for the 1050 using an arduino nano. i have acquired a 2-digit display unit with integrated shift registers and resistors etc so it just receives data clock and latch (and 5v/gnd) from the arduino. unfortunately, i have no experience of arduino code but i am steadily 'absorbing' it. the only electronics i know is from other people's build guides and basic common sense..(?) hehe looking for relevant signals from the drive, it appears that the FDC chip WD2793 has everything required: PIN 34 is "track 0" - i tested this and it reads +5v when head is at track 0 PIN 15 is "step" - sam's computerfacts states 'pulse' but i am unable to test it in operation at this time PIN 16 is "direction" - sam's computerfacts states high when the head is stepped in and low when the head is stepped out but i am unable to test it under normal use (3d printer is in the way, currently active for several hours...days...!) I have found a sample code online that that uses push-buttons to increase/decrease and reset to 0. i have butchered the code to work with my display but i now need to make these increases/decreases automatically with the above signals from the FDC chip. however, this is where my lack of electronics experience stalled the idea.. the track zero is sorted, it will just be a digital pin HIGH as per the current button version however, as the FDC uses a direction signal method, i need an electronic component solution to automatically use this signal to switch the STEP signal between the +1 or -1 pins on the arduino. see crude diagram. i thought maybe a transistor would do this but i can only see on/off transistor switches, not ones that control an output of A or B. so i would be grateful if anyone could advise. if it works, i'll put it out for the forum community to share. to be honest, i didnt think i'd even get the code to work like it does! here is a vid of the progress so far. thanks in advance! track 0 arduino.MOV Edited October 22, 2019 by xrbrevin Quote Share this post Link to post Share on other sites
xrbrevin #2 Posted October 22, 2019 further pondering... maybe i should change the code for the buttons to behave the same way as the FDC signals food for thought... 🤔 Quote Share this post Link to post Share on other sites
xrbrevin #3 Posted October 22, 2019 i bit of trial and error meddling in the code and i got it to work as intended! next step is to hook it up to the 1050 FDC and see if it goes beserk hehe track 0 arduino v2.MOV Quote Share this post Link to post Share on other sites
xrbrevin #4 Posted October 22, 2019 so i answered my own question in the end... hehe i'll report my findings after i have attached it to the 1050 apologies for the darkness of the vids, my stills cam isnt that good at vids so here is a pic of it in all its prototype glory (button tops now added since vids) 4 Quote Share this post Link to post Share on other sites
Gavin1968 #5 Posted October 23, 2019 I love it when just posting out thoughts on here is a help! You asked a question, no one answered, and you worked your way though it! This is so awesome! Great job! I look forward to watching your progress! 3 Quote Share this post Link to post Share on other sites
xrbrevin #6 Posted October 23, 2019 (edited) thanks, its very ironic. i thought i'd reached the limit of my ability and decided to create the new topic to get help but just by typing it all out, it helped me see the other possibility. i still think im out of my depth tho but im not quitting! Edited October 23, 2019 by xrbrevin Quote Share this post Link to post Share on other sites
Mclaneinc #7 Posted October 23, 2019 Can't help due to being thick as a plank when it comes to that (kind of ironic I ran an electronic companies branch) but I just love the fact you are working it all out without any experience, brilliant stuff and I'm sure when the time zones allow you will get some good feedback. Paul. Quote Share this post Link to post Share on other sites
Fierodoug5 #8 Posted October 23, 2019 Looking foward to seeing your further progress! Quote Share this post Link to post Share on other sites
xrbrevin #9 Posted October 23, 2019 4 hours ago, Mclaneinc said: love the fact you are working it all out without any experience my coding experience is BITD 8bit atari basic type-ins. it has a few cobwebs but its still there. i used the 1050 FSM to figure out when/how the stepper motor moves and also to find a track zero logic location. the sample code for the 2-digit display unit would automatically count up or down. i found another code that would do the counting via button-operations however this didnt work properly with my display as it was designed for 3-digits. i tweaked things to try and get an idea of what was going on but i couldnt make proper sense of it. the best i could get was 10x button presses to increase by 1 but the 'tens' digit was always garbled. in the end i used the display code from one and the button code from the other, sorted the mess of pins/variables/integers and it became the one that now works in principle/prototype. i had to try out random ideas with no guidance to get from post#2 to post#3 of this topic and one of them worked! it was all in the "IF" statements... hehe Quote Share this post Link to post Share on other sites
TGB1718 #10 Posted October 23, 2019 To get this working with the 1050, you probably need to attach an interrupt to the Step signal, have a read of this https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/ that way, you don't miss any steps, your interrupt routine should check (high or low) on the direction and then increment/decrement your display accordingly. As its stepping a motor, the Arduino will have plenty of time to action your routine and return ready waiting for the next step. below is some code that uses interrupt. I used it for a heart monitor, but may still help, the basics work. #include <LiquidCrystal_I2C.h> #define True 1 #define False 0 #define APin A0 // AnalogRead pin (Monitor Input) #define IPin 2 // Interrupt Pin for Frequency Measurement int val; // Value from APin unsigned long Clock = 0; unsigned long Clock1 = 0; float Diff = 0.0; float ResArray[10]={0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}; int Index=0; boolean Changed = False; boolean Plotter = True; ; // to turn Serial Plotter on/off boolean LON = False; // Flag for LED int LedDelay; String Scaled = ""; LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display void setup() { Serial.begin(115200); pinMode(APin, INPUT ); pinMode(IPin, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(IPin), GetTime, FALLING); pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); LedDelay=0; lcd.init(); // initialize the lcd lcd.backlight(); lcd.clear(); } void loop() { String res = ""; int len, i,j; float Average=0.0; if(Changed )// && !Plotter) { digitalWrite(LED_BUILTIN, HIGH); LedDelay = 0; LON = True; ResArray[Index++]=1/(Diff*0.000001)*60; if(Index ==10) Index=0; // Serial.println(1/(Diff*0.000001)*60); // convert to BPM Average = 0.0; for(j=0;j<10;j++) Average=Average+ResArray[j]; Average=Average/10; lcd.setCursor(0,0); res = "BPM "; //res += String(1/(Diff*0.000001)*60); res += Average; len = res.length(); len = 16 - len; for(i = len;i < 16; i++) res+=" "; lcd.print(res); Changed = False; if(!Plotter) { up(); delay(100); down(); } digitalWrite(LED_BUILTIN, LOW); } if(Plotter) { val = analogRead(APin); Scaled = "200 "; Scaled += val; Scaled += " 850"; Serial.println(Scaled); delay(10); } } void GetTime() { Clock = micros(); Diff = float(Clock - Clock1); Clock1 = Clock; Changed = True; } void up() { int i; for(i=0;i<16;i++) { lcd.setCursor(i,1); lcd.print("*"); delay(10); } } void down() { int i; for(i=15;i>0;i--) { lcd.setCursor(i,1); lcd.print(" "); delay(10); } } 1 Quote Share this post Link to post Share on other sites
xrbrevin #11 Posted October 23, 2019 many thanks for your sophisticated contribution, i may have to refer to it yet. i would like to see the current state through for now - caution of inexperience and i need to try and keep a toe on the ground!! there is a disturbance in the GND... i rigged the thing up to the 1050 and powered it on. the display lit up but the drive head went to track zero then 'gibbered' constantly. i tried removing each wire in turn and retried the power. the only wire that would stop the gibber was GND so i have deduced that my 3x pulldown resistors must be pulling down the 3x pins on the FDC chip (d'oh!). muddling its logic. would a diode on the 3x wires prevent GND from going back to the FDC pins? if so, can anyone recommend which diode to use? i have knocked up a diagram of the current status to help thanks in advance! Quote Share this post Link to post Share on other sites
+kheller2 #12 Posted October 24, 2019 Are STEP an DIRC even connected on the 1050? DIR seems connected to TP10. Remember, on the 1050, motor stepping is controlled by the 6532, not the WDC. Quote Share this post Link to post Share on other sites
Rybags #13 Posted October 24, 2019 1050 actually does half-steps so you'll probably have to cater for that. Quote Share this post Link to post Share on other sites
BillC #14 Posted October 24, 2019 (edited) 2 hours ago, kheller2 said: Are STEP an DIRC even connected on the 1050? DIR seems connected to TP10. Remember, on the 1050, motor stepping is controlled by the 6532, not the WDC. I checked the Sobola schematics which show the signals on PB2/PB3/PB4/PB5 of U7(6532) pass thru U2/U3(5713)on the way to the stepping motor. I believe this is the correct 5713 datasheet: https://www.allegromicro.com/-/media/Files/Datasheets/UDN5713-Datasheet.ashx?la=en&hash=C45AABA6E210D7A47DBABC0C078ADA471D019005 Edited October 24, 2019 by BillC Quote Share this post Link to post Share on other sites
xrbrevin #15 Posted October 24, 2019 (edited) 8 hours ago, kheller2 said: Are STEP an DIRC even connected on the 1050? DIR seems connected to TP10. Remember, on the 1050, motor stepping is controlled by the 6532, not the WDC. hi, yes i saw this in the manuals but as the FDC is a 3rd party component, im hoping it still operates/mirrors the STEP command and that the atari design just ignores it. just keeping it as simple as poss but i will cross that bridge if necessary. the FDC has the means to provide the CPU with track reference but im not sure what format it is provided in, plus i would have to invoke the command synthetically. hence i'd rather try the binary logic command signal version first Edited October 24, 2019 by xrbrevin Quote Share this post Link to post Share on other sites
xrbrevin #16 Posted October 24, 2019 (edited) 5 hours ago, BillC said: I checked the Sobola schematics which show the signals on PB2/PB3/PB4/PB5 of U7(6532) pass thru U2/U3(5713)on the way to the stepping motor. I believe this is the correct 5713 datasheet: https://www.allegromicro.com/-/media/Files/Datasheets/UDN5713-Datasheet.ashx?la=en&hash=C45AABA6E210D7A47DBABC0C078ADA471D019005 these are the power output signals from the PIA/RIOT to the stepper, via U2 and U3 which amplify it (clockwise/anticlockwise). i did wonder about tapping into them but im hoping the binary logic command signal method will be simpler. Edited October 24, 2019 by xrbrevin Quote Share this post Link to post Share on other sites
xrbrevin #17 Posted October 24, 2019 7 hours ago, Rybags said: 1050 actually does half-steps so you'll probably have to cater for that. cheers, i never knew that and i'll keep it in mind. i should be able to calibrate it in software after ive got it to respond properly! Quote Share this post Link to post Share on other sites
xrbrevin #18 Posted October 24, 2019 im thinking i can lose the 3x pulldown resistors as i suspect they are only required for the pushbutton prototype function. this should eliminate any backbleed to the 3x FDC contacts... my next objective is to just get the track 0 pin to operate the display for now and add the other 2 connections once ive got my head round it Quote Share this post Link to post Share on other sites
xrbrevin #19 Posted October 24, 2019 here is a copy of the current code for anyone who is fluent. i wonder if my IF statements should be based on HIGH / LOW states rather than 0 / 1. ill try and research it or trial and error it (again) if i cannot find reference hehe current code.txt Quote Share this post Link to post Share on other sites
TGB1718 #20 Posted October 24, 2019 For logic circuits, they usually use Pull UP resistors, but are not always required. It's rare to use Pull Down as you will see the issues, like you have. For the Arduino if you require pullups, you can use pinMode to set this :- void setup() { pinMode(13, INPUT_PULLUP); // sets the digital pin 13 as input with pullup } Quote Share this post Link to post Share on other sites
BillC #21 Posted October 24, 2019 6 hours ago, TGB1718 said: For logic circuits, they usually use Pull UP resistors, but are not always required. It's rare to use Pull Down as you will see the issues, like you have. For the Arduino if you require pullups, you can use pinMode to set this :- void setup() { pinMode(13, INPUT_PULLUP); // sets the digital pin 13 as input with pullup } Pull-up resistors are common with logic chips because their outputs typically can't supply as much current as they can ground. Quote Share this post Link to post Share on other sites
xrbrevin #22 Posted October 24, 2019 the signals from the FDC are mainly HIGH so i will see if the arduino can default to pulldown when i next tackle it. i will also see if will make a difference in the code using HIGH / LOW instead of 0 / 1 logic. i minimised my test setup to just aim to get track 0 behaviour to work as i know it sends 5v which is what the arduino is expecting. i tried a 1N1002 diode from the FDC pin 34 and although it worked, it was not completely reliable. i wonder if there is a glue logic chip that can help prevent backfeed current.. (i ought to get a breadboard really) Quote Share this post Link to post Share on other sites
TGB1718 #23 Posted October 25, 2019 From experience and safety as you don't want to damage your 1050 chips, I always use buffers between output/inputs something like a 7404 hex inverter buffer, it does obviously invert the signals but as you would only be using 3, you could link inverter output to input, see diagram below, also, you could use a 7407, but it would need pullups as it's open collector Quote Share this post Link to post Share on other sites
xrbrevin #24 Posted October 25, 2019 (edited) thanks, this is the sort of info im lacking. i tried INPUT_PULLDOWN in the code but it would not compile. INPUT_PULLUP does compile but my drive is becoming unstable (head location) so results are difficult to ascertain and conditions are not consistent. even after i disconnect the arduino wires it takes a short while to get back to normal. i think INPUT_PULLUP is not useful because the 1050 signals are (mostly) high. the hex inverter buffer suggestion with relevant code tweaks will hopefully sort that. i also hope it will stop the backfeed interference that is destabilising the 1050 behaviour. i also tried using HIGH and LOW instead of 0 and 1 and it did compile ok. i shall obtain the hex inverter and a breadboard to make component changes easier. also, i have been using TP14 (12v) for VIN on the arduino. this may have an implication on the drive behaviour, ive not looked at it in earnest but i think the solution is to solder a wire from the 7812 regulator for the arduino. Edited October 25, 2019 by xrbrevin Quote Share this post Link to post Share on other sites
xrbrevin #25 Posted October 25, 2019 one thing occurred to me, do you know if it is necessary for the arduino to be powered by the 1050 in order for the logic signals to be received? do they have to share the same GND & VIN? Quote Share this post Link to post Share on other sites