Interrupt Driven Rotary Table controller

Home Model Engine Machinist Forum

Help Support Home Model Engine Machinist Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
Did you uncomment the definition in LCD.h as per my instructions in Post#93? As far as I know the Sainsmart is identical to the DFRobot in relation to resistor values used.
You should be able to create a new device in settings and define a linear device and swap between your brake and your rotary table.

The menu options are there, take the time to fully explore each menu option. There is no need to change #defines in the code.
 
Could try these LCD files instead of the ones provided earlier?
DFROBOT is enabled
It looks like I did not finish off the code so LCD.cpp was not selecting code based on the #define you uncommented and always used DFROBOT settings. Sounds like that is wrong for your screen..
Tested on a DFRobot. If this does not work, comment the #define out again and try again
If it still does not work, you need to compare your resistor values against the ones here
https://www.dfrobot.com/product-51.html

Once you have a keyboard working.,
left arrow to <config>
press down arrow
To create a new device, from <config> left arrow to <Devices> press down arrow and add a new device (up arrow to yes and select).
Devices are numbered from Zero
Left arrow to get to <Setup> down Arrow to select.
Find DevTyp option in this menu and set to Linear and select.
Then configure your device and save it.

If you get stuck, bump the CONFIG_VERSION up by 1. This will force the script to erase the EEPROM on the next startup but it can be erased from the device menu. We usuualy only need to do this if the globals structure changes.
 

Attachments

  • LCD11.zip
    6.9 KB · Views: 574
I think I'll take a break from this for awhile. I've spent hours trying to get this to work. I went back to version 10 of your software and installed the old Libraries to get the Rotary part working again. Has anybody used the Linear feature before?
 
I am able to get into the setup parameters but can not change some of them for the Linear function. When I do get into the Setup parameters there are no numbers there for Dis/Rv, T/Rat and JgMM. I can cursor left and right but clicking Up and Down does nothing. Adds no numbers. Am I still doing something wrong here?
 
A bit of feedback :

RotaryTable11.zip downloaded from post#93 compiles and uploads as it should .
I have made my dfrobot board sainsmart/freetronics compatible by modifying the hardware and all works as expected .
The backlight pin is still dfrobot , and as expected does not work with the freetronics settings .
Did not try the dfrobot settings as I no longer have a real dfrobot board .

Then I downloaded the LCD11.zip and commented the define dfrobot .
That gives me a compile error . Somthing like { expected .
Did not persue this .

To my knowledge sainsmart and freetronics use thesame resistor values , but sainsmart has a different backlight pin .
Dfrobot has a 2K2 resistor instead of the 2K and thesame backlight pin as the sainsmart does .


That aside , I mentioned a nano problem when writing to eeprom .
I noticed when compiling and uploading the sketch :
Uno : 28478 bytes ( 88%) of memory
Nano : 28478 bytes (92%) of memory .
Altough they both use thesame processor , something is different .
I also have to set my nano to "old bootloader" otherwise it will not upload .
But it does work .


Pat
 
Ooops on line 353 of LCD.cpp, I should have deleted one more comment.
It should read as per the second last line
Code:
#ifdef DFROBOT
static uint8_t const buttonMappings[] PROGMEM = {
    2, 0, 3, 3, 0, 0, 0, 4, 4, 0, 0, 0, 1, 1, 0, 0,
    0, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
#else
static unsigned char const buttonMappings[] PROGMEM = {
    2, 0, 0, 0, 3, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 1,
    1, 0, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0
};   // deleted the comment
#endif

These mappings are created with a utility in the original LCD library as mentioned earlier.

Also the backlight pin should be able to be enabled on different hardware with a change to around line 31 (// = comment)
Code:
//#define LCD_BACK_LIGHT         3        // Default LCD backlight is on D3 - Freetronics
#define LCD_BACK_LIGHT          10        // Default LCD backlight is on D3 - DFROBOT and others
#define LCD_BUTTON_PIN          A0        // Button state is on A0
So you just need to uncomment one line and recomment the other.

And the memory usage of the nano is probably going to break the script due to memory overruns. The bootloader must be bigger.

The bootloader is burnt to the chip using am Atmel Risp programmer. I have used one of these to download a script when I've busted the USB on an Arduino. There will be instructions around on how to do this and also how to make your own Risp programmer. This may increase available RAM as the bootloader is no longer there but I really don't know.

And yes, most boards except Freetronics use the 2k2 resistor.
 
Hmm, that was easy. It looks like external relays are now supported. I won't share it yet as I have not tested it with real hardware unless somebody really wants to try it but a hardware interrupt on pin 2 fires if it receives a 5 volt signal and after indexing is completed, pin 13 is briefly enabled (currently for 0.3 seconds) signifying the indexing move has been completed. To implement this you'd need two relays (optoisolated preferred). One relay would be triggered on the external device and it would switch 5 volts from the Arduino power supply to pin 2.

Another relay would be attached to the Arduino PIN13 and Arduino GND. It would switch field power on the external device to an input signifying the machine could continue. Apparently some machjines (eg with Fanuc controls) are provided with macro relays that can be triggered with something like an M40 in gcode.

You could also do this from LinuxCNC/Tormach PathPilot out of the box with a M64/M65 followed by a M66 wait on input something like
Code:
M62 P0  (turn on digital output 0)
G4 P0.1  (pause to catchup to avoid breaking blending)
M66 P1 L1 Q10  (wait for 10 seconds for digital output 1 to go true at end of indexing)
M63 P0 (turn off digital output 0)

Of course you'd need to add a bit of error handling. The Linuxcnc docs say "If the timeout is exceeded, the wait is interrupted, and the variable #5399 will be holding the value -1."

I wonder where Scott is....


Rod, This is Scott and I am back to playing around with this project again. I am done farming for the year and can dedicate some time to getting this to work with my Milling machine with the fanuc control. I have successful got it wired up the the mill and am able to make it index wit a m40 signal from the fanuc control. After the indexing operation finishes the delay pulse I sent from within the code sends a pulse that cancels the M40 comand and the mill continues with the program. It work about 80% of the time and as I suspected there is a problem with using the delay command in the arduino code. Occasionally it triggers the end of m40 during a indexing movement. So I came back to the forum and read the posts since I got busy with work. It sounded like you had been working on this problem while I was busy.

So right now I am piggybacking on the right button push switch with a m40 index command from the fanuc relay. The command to cancel m40 comes from a dfrobot relay shield that is hooked to the d10 pin. It sounds like you are doing the same thing with pin 2 (start) and pin 13 (index done). My problem is my poor coding with the delay function i believe. I would appreciate if you could share the work you had done so I could try it out. I am assuming I could change from pin d10 to d13 in the code and use pin 2 instead of my piggyback on the right button. I really appreciate all of the trouble you have gone to with this project
Thanks
Scott
 
Scott, I'll have to dig out the code to see what I ended up doing. I only ever bench tested it. I was trying to incorporate a rotary encoder into the menu but it really is designed for a keyboard so I don't think I could make it work nicely.
 
Thanks rod, I tried implimenting what you had mentioned a couple of posts prior to the one I replied to but ended up with compiler errors. I appreciate your help thanks
Scott
 
My system consists of CW250 controller,HF100W-SF-24 power supply,57BYG-310D stepper motor, Arduino Uno,Sainsmart LCD,and used rotary table 10 . The LCD display shows the menu for the program, but the steppermotor makes a noise and doesn't rotate. When i tested the stepper with a independent circuit it rotates just fine. What can i look for? Need Help.
 
I'm no expert but two things come to mind for why a stepper motor makes noise and doesn't rotate. One is too fast of pulses and the motor can't keep up. The other is reversed leads on one of the coils so the motor steps one way and then tries to step back. I'd try reversing the polarity of one set of motor leads first.
 
I suspect you are trying to drive the stepper faster than it is able to do so. In frequency. settings, reduce the frequency. Too many people have used this script for it to be a software issue. It has to be a configuration or wiring issue.
 
Rod i sent the company my proposed wiring diagram before i built this wooden turntable, like a lazy susan and they said everything looks ok. Could it be the rotary table 10 code? I could go through the entire menu on the sainsmart lcd. rotary indexer2.jpeg
 

Attachments

  • rotary indexer2.jpeg
    rotary indexer2.jpeg
    37.3 KB · Views: 614
What is the value in the setup menu for MaxHz?
Try halving it and make sure MinHz is less than that number.
This is what determines stepper speed and at the beginning of a move, it ramps up from minHz to MaxHz then ramps down the other way at the end. Low speeds have more torque.

The other possibilities are:
1. Not enough Torque to turn your table.
2. Stepper Voltage too low (which causes 1)

So looking at your parts, it looks like you have a Stepper driver that will handle 60 volts which your NEMA23 stepper will easily handle but you are only feeding it 24 volts. If you double the power to 48 volts, you will more than double the torque.
 
Good Lord! Bunch of rocket scientists. The only stepper I know of is the Two Step!!!:)
 
Rod i am new at this code stuff, can you tell me where i can find this MaxHz. Is there a line number in the Rotary Table 10 code? I removed the stepper from the turntable and have the same results.
 
I have got my 5C HAAS index head working with the mill! I have implemented a M40 command from the Fanuc 0mc control to activate an index move. an arduino driven relay then resets the m40 index move and continues on with the code. I am going to try and ad a link to a video of it at work. The part is a 72 to 1 worm gear being cut with a thread mill. Thanks Rod for all your work on this project what used to take me an hour and now be done in 8 min.
 
very nice is that hardinge indexer cnc ? or did you convert it ... would love to see more pics / specs of that

JOe
 
Its a Haas 5c indexing head. I think they were a copy of the Hardinge one. Its driven by a stepper motor and was originally controlled by a haas driver. My system uses the Arduino code from this thread and a relay shield. With some small changes to the code the arduino sees a relay cycle generated by the cnc with a M40 command in the code. when the index is done it then sends a signal back to the cnc to cancel M40 and continue. The driver is a Gecko controller driven by a 48 volt power supply.
 
Back
Top