Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : CMM2 CNC
Author | Message | ||||
Bryan1 Guru Joined: 22/02/2006 Location: AustraliaPosts: 1344 |
G'Day Guy's, Well getting there I have made a start on the code and it needs a lot to go but I do think I have it ready or not to test for the limits. option console serial colour RGB(white), RGB(black) ' ref numbers const x_dir = 1, x_step = 2, x_enable = 3, x_position = 4 const y_dir = 5, Y_step = 6, Y_enable = 7, y_position = 8 const z_dir = 9, z_step = 10, z_enable = 11, z_position = 12 const e_stop = 13, x_limit = 14, y_limit = 15, z_limit = 16 'sprite load "mouse.spr",1 gui cursor on 0, mm.hres\2,mm.vres\2 'draw the controls gui caption x_position, "0.000", mm.hres/2, mm.vres/3,, rgb(blue) gui caption y_position, "0.000", mm.hres/3, mm.vres/3,, rgb(blue) gui caption z_position, "0.000",mm.hres/4, mm.vres/3 ,, rgb(blue) GUI button x_limit, "X Limit", mm.hres/2,mm.vres/8 ,, RGB(green) GUI button y_limit "Y Limit", mm.hres/4,mm.vres/8 ,, RGB(green) GUI button z_limit "Z Linit", mm.hres/6,mm.vres/8 ,, rgb(green) ' set X axis up pin 3 = x_step setpin 3, dout pin 5 = x_dir setpin 5, dout pin 11 = x_enable setpin 11, dout setpin 7, cin it cnt ' set Y axis up pin 19 = y_step setpin 19, dout pin 21 = y_dir setpin 21, dout pin 23 = y_enable setpin 23, dout setpin 13, cin ' Set Z axis up pin 27 = z_step setpin 27, dout pin 28 = z_dir setpin 28, dout pin 33 = z_enable setpin 33 dout setpin 15, cin 'setup the limit switch's pin 8 = x_limit setpin 8, oc pin10 = y_limit setpin 10, oc pin 12 = z_limit setpin 12, oc ' setup the E-Stop pin 12 = e_stop setpin 12, oc 'pinouts for DM556 Microstepper and PP old trial for my old controller 'pin 3 = x_step ' pin 2 on PP 'pin 5 = x_dir ' pin 3 on PP 'pin 11 = x_enable ' pin 11 on PP 'pin 19 = y_step ' pin 4 on PP 'pin 21 = y_dir ' pin 5 on PP 'pin 23 = y_enable ' pin 12 on PP 'pin 27 = z_step ' pin 6 on PP 'pin 28 = z_dir ' pin 7 on PP 'pin 33 = z_enable ' pin 13 on PP ' pin 10 on PP is e_stop 'pin 1 on PP is global enable ' will need to test global enable do loop intl x-limit, y-limit, z-limit, e_stop Select Case click(REF) ' find out the control touched Case x_limit If CtrlVal(14) GUI Disable x_enable, y_enable, z_enable case y_limit if ctrval(15) GUI Disable x_enable, y_enable, z_enable case z_limit if ctrlval(16) GUI Disable x_enable, y_enable, z_enable case estop if ctrvl(12) gui disable x_enable, y_enable, z_enable Function MM.CURSOR( t As Integer) As Integer Static Float lasttime If Timer > lasttime + 20 Or timer < lasttime Then X = Mouse(x,1) Y = Mouse(y,1) Lb = Mouse(l,1) lasttime = Timer Gui Cursor x,y EndIf There is still alot I still have to learn and like I say in my cnc thread baby steps do need to happen. I did get the isolation board finished today and tomorrow the test with a led will happen to see if it works. Look I have wasted money just buying boards that won't work as one only buy's part of the system or they won't work on linux or win 10. My idea of the code so far is to detect the limits and e-stop but as it's dark a usb disk has my code so my laptop in the shed can transfer the code to the sdcard for the CMM2. Once I get this working it time to learn how to control these steppers where the idea is to count the steps to control the distance. Regards Bryan |
||||
PhenixRising Guru Joined: 07/11/2023 Location: United KingdomPosts: 857 |
A velocity profiler (multiple) is easily handled by the Picomite. -Distance to accelerate -Distance to slew -Distance to decelerate This is sampled to provide precise velocity control. 2ms or 4ms slices are more than enough. MMBasic loads a PIO register, each sample and PIO code generates pulses, distributed across that sample period. Voila. We have a stepper controller and a very high-performance one. Then, to be civilized , we attach low-cost encoders to each axis and the PicoMite keeps track of the actual axis position. I also have an s-curve (as opposed to trapezoidal) profile generator that causes no stress for MMBasic. |
||||
Bryan1 Guru Joined: 22/02/2006 Location: AustraliaPosts: 1344 |
So what your saying is we can use the CMM2 via spi to control 3 off pico's for each axis and stick an encoder on the end of each ball screw for position control? Man I'm a mechanical guy trying to learn code but if this can be done then I'm in for a huge learning curve. I do have 10 zero's here and 10 mother boards that could be used also 5 pico boards on the way but 2 of them are reversed for the 2.8" and 7" lcd's so if you guy's want to help I'm all for it. Regards Bryan |
||||
PhenixRising Guru Joined: 07/11/2023 Location: United KingdomPosts: 857 |
Well I don't want to derail what you have in mind but we have crazy potential here. One Pico-2 will easily handle 4-axes (you might want to add a rotary at some point) It could handle the step generation plus the encoder feedback The CMM2 I would use as the front-end for user interface and G-Code processing. I actually have free-to-use CNC controller source-code (albeit in C), somewhere. But maybe you want GRBL compatibility which would require some development. As is typical of moi, I'm going overboard and wanting to redevelop the entire controller But to reiterate, a single Pico 2 can handle all the heavy-lifting. I'd just need to go cap-in-hand to Volhout (again) |
||||
PhenixRising Guru Joined: 07/11/2023 Location: United KingdomPosts: 857 |
Could this be ported to CMM2 (PDF in zip)? pscnc.zip |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6779 |
You can't use a Pico as a SPI slave. They can only be masters. That's because they have no way to read the clock. (It's probably possible t6o create a SPI slave port using a PIO but that's beyond me). You can use I2C rather than SPI though - and it's simpler. You can also use multi-drop COM, but it's slightly more complex than I2C. It has the advantage that all messages are buffered though so there is less risk of things getting lost. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Bryan1 Guru Joined: 22/02/2006 Location: AustraliaPosts: 1344 |
Well this talk about using a pico is going over my head as I do think the CMM2 can do all of this. Now I uploaded that code and found that was there I was at the last time trying to write code only to find it won't work. I mean simply my thoughts and the CCM2 are different so I'm going to break it down and do it step by step include the setpin with a sub and just get the limits working. Once that code is done and tested include that in the new main code and do the next step and move on. Now the page read is the next step where the fist statement is X Y or Z then the travel etc is the next step. Now if I could find a driver for my pikit3 I do have some high end 18f's that can handle this in oshonsoft basic that I used to use and those old pic's used to rock. Regards Bryan |
||||
PhenixRising Guru Joined: 07/11/2023 Location: United KingdomPosts: 857 |
If you want to use a PIC I have this NMC (network machine control) binary protocol in MMBasic |
||||
Print this page |