View Full Version : Visual Basic Controller Project
dwwright 02-28-2005, 10:20 AM Thanks for setting up the new VB Forum. I'm going to continue posting my work log of my visual basic controller from here (http://www.cnczone.com/forums/showthread.php?t=8105).
To bring it up to date, I haven't had much time to work on it. I was last working on recompiling and converting the gcode back to a dxf file for export. I got stumped on trying to convert a ellipse, but found that other commercial programs don't import them either. The code that I'm using for the dxf also will help on parsing out the positions to move the xyz motors. I should have time in the next couple of weeks to work on it again.
Here is a screen shot:
http://www.cnczone.com/forums/attachment.php?attachmentid=5010
dwwright 05-06-2005, 09:27 PM I've not had anytime to work on this. The vb timer doesn't give very good performance, maybe someone else will have better luck. I haven't done any documentation and it has been a while since I dug into it, if you have a question I'll do my best to answer it. The source is in VB6.
cboudreau 12-05-2005, 10:43 PM Can I help you with this project? If so what is the issue with the timer?
By the way, I see your into stainglass. Have you made a machine that would dispence the liquid lead onto a glass using CNC?
Carl
cboudrea@pressenter.com
SeQueNcer 08-30-2006, 10:37 PM I've finished my Software which controls through parallel port...but i've problems with the timer...it give slow performance...if i made loop for sending -for ex. "255"- 1000 times without timer it talkes about 1 second ...if i used timer with 1 mms interval it takes about 17 Seconds...this means it sends 60 mms not every 1 mms ...how can i overcome this .....thanks
cboudreau 08-31-2006, 08:11 AM By threading the timer routine, you separate it from the main process which would be your CNC application. Isolate the timer functions in another form and create a separate process for that form. This is called multi threading, and it allows the processor to give that thread the attention needed for this process (your CNC application).
Lets use people as an example. Picture yourself standing in the middle of 6 people, who are giving you command. 5 of those people represent a diffrent process running on the computer, and the 6th person is your CNC application. You as the processor turns to each person in your circle and asks for instructions. As each person gives to an instruction to you, you complete it and turn to the next person in the circle. When you get an instruction from the CNC person, you execute it and move on to the next person.
So if the CNC person, asks you for the current system time, you give it to him or her, and then move on. By the time you get back to the CNC person, the process as a whole has actually lost ns(nano seconds). Lets say the CNC hears the time from you and it is time to move a Motor, the next command he will give you is to move the motor. You as the CPU comply and move onto the next person (process). When you get back to the CNC person again, he has a list of commands for you but is limited to only one command at time. This limit is your timing issue.
By creating another person(process) and call her Timer Girl. You will actually give your CNC application more face to face time, and therefore speed up your application. Because now you have two people working on your CNC application.
It has been a long time, since I have heard from anyone on this project, if you would like more help, can you update the Zip file and post it here please
Carl Boudreau
Developer / Architect
VB.Net , ASP.Net, VB6, ASP, MSSQL, mySQL - and more...
612-220-8720
cboudrea@pressenter.com
cboudreau 06-19-2007, 11:27 AM Anyone working on this project?
dwwright 07-07-2007, 12:43 PM Can I help you with this project? If so what is the issue with the timer?
By the way, I see your into stainglass. Have you made a machine that would dispence the liquid lead onto a glass using CNC?
Carl
cboudrea@pressenter.com
Sounds like a feasible task since I use a glass design software that can output dxf files. However that would take all the fun out of the glass work for me personally, so doubt I'll pursue it.
w102acd 10-08-2007, 12:43 PM I am new to this forum/site. I noticed that they had VB forums and was just poking around. I do all of my coding in VB and have just started playing around with the parallel port, stepper motors, etc.
I ran into a similar problem and found that there is a much higher resolution timer in vb than just the "timer" function. I was able to get 500 steps per second using this timer a ULN2003A and some Vexta 12V stepper motors. I was.am trying to build a translating XY table using 1/4-20 all thread. This will result in 7.5 inches per minute. Not bad. Not sure what limits this, but beyond ~600 the steppers really start losing steps and are not reliable anymore. If the limiter is the computer than it might be increased for a faster computer. I am using a very old 500 MHz AMD for this and have not tried any other.
The functions are queryperformancefrequency and queryperformancecounter. These functions use the actual speed of the processor as the timer. I've heard that they are accurate to ~5 microseconds!!!!
I have been able to plot things using an etch a sketch very quickly using this method and simply a X,Y coordinate linear interpolation strategy which works alright for the spacial resolution of an etch a sketch. I would post a picture, but my etch a sketch has since broken. Also taking a picture of an etch a sketch is like taking a picture of yourself in the mirror. All your going to see is a nice reflection of my camera and hand.
Not sure if anyone is still watching this thread!!!! If so hope this helps. I can post a better description later if anyone would like it.
cboudreau 10-08-2007, 02:21 PM I am watching this thread. And I am interested in continuing the WinCNC application, although I'd like to see it done in VB.Net2005.
innova 12-09-2007, 12:09 PM Gentlemen, I am trying to port my dos based app to a VBA app run within Autocad and I am currently up against the timer issue. Would the new dual core processors help out here? One core devoted to the stepper control thread and the other left to take care of Windows needs? I would hate to run out and buy one only to find out it doesn't work that way. Thanks
cboudreau 12-10-2007, 03:57 PM Of course a Dual Core is faster, and if you need validation to ask Mrs. Santa for a New Computer, then your answer is yes “You have to have it.”
But unfortunately, the timer issue is a software operating system issue, and not hardware. I don’t think you can isolate the AutoCAD application to use only one processor would go against the foundation of the hardware architecture.
The fundamental issue if the time is based on the OS. The operating system can still only do one process at a time. A dual core only gives the OS to double the process speed because it duals out the work load to two processors in stead on just one. The OS was not designed to be a PLC, there fore there was no separate timer control built into the OS. Although it looks like things are running at the same time, it is only an illusion, much like to see in an old movie projector, The projector like the OS simply flashes still pictures in your eyes so fast that they seem to be animated. But in reality they are just single pictures or single processors. So if we could speed our brains up to the speed of the computer we would see one process at a time, like we would see one image at a time in the old movie projectors.
The timer is inaccurate because, depending on how many processes are running will determine when the timer process will run. It isn’t, but if the timer process was the only thing running then you could say it is accurate, but if there are 50-60 processes running the timer process runs every 61 times.
Carl Boudreau
Senior Developer VB.Net, VB, ASP.net VB, VBA
Gentlemen, I am trying to port my dos based app to a VBA app run within Autocad and I am currently up against the timer issue. Would the new dual core processors help out here? One core devoted to the stepper control thread and the other left to take care of Windows needs? I would hate to run out and buy one only to find out it doesn't work that way. Thanks
pikovv 02-14-2008, 02:13 PM Dear Mr. Darren Wright,
I hope you can help me in reviving this project. I am quite experienced in VB but am quite a newbie in CNC and motor control. I hope you can explain to me a couple of things in the function Move_Steppers (in the "main" form):
1. Why did you choose CreateWaitableTimer approach for timing control? It appears that its nanosecond resolution is an overkill for this since this function needs to be called 50,000 times a second at most for a regular microstepper controller. So, we only need 20 ms resolution which is attainable with regular VB timer. There is also a more precise ActiveX timer available at http://www.easycode.cat/English/ActiveX.htm which is easy to use in VB.
2. To increment time between the motor steps you are using mySleeper.SleepTime to evoke GoToSleep in the CSleeper. During each increment, you are switching between the STEP and STOP states while the joystick is kept activated. During the STOP state, you send 0 to the step line but keep the value for the direction line.
Then, at the end of the function, you send 0s to all lines but just briefly (probably a few nanosecs) until the function is called again and output is set to the next state. Is this nanosec-long zeroing of outputs between states important? :confused:
Thank you,
Victor
ADucci 02-15-2008, 12:59 AM Hi Victor
I would also like to help if i can. I am not a VB programmer by trade, but can help out here and there. i also have a Stepper table as well as a small test board to run the steppers via pc interface.
it would be nice to see this project revived.
cheers
Anthony
Hi,
1. Why did you choose CreateWaitableTimer approach for timing control? It appears that its nanosecond resolution is an overkill for this since this function needs to be called 50,000 times a second at most for a regular microstepper controller. So, we only need 20 ms resolution which is attainable with regular VB timer.
I'm no VB expert but 50,000 times per second = 50kHz = 0.02mS = 20uS as in microseconds, not 20mS. Can you really get 20uS resolution with an ordinary VB-timer?
w102acd 02-15-2008, 09:37 AM I have read other places that a pulse frequency anywhere close to this high is impractical for Windows (without serious hacking of the operating system). I would love to be proven wrong about this!!! I think timers might help, but I don't think they are the entire problem. I have been very interested to finding out what limits the pulse frequency. Is it Windows, VB, timer used, circuit, stepper motor, etc??????
Love to help out with this anyway I can!!!
To date, I can get maybe 650 pulses per second with my very simple circuit (ULN2003), but as I mentioned above, I cannot put my finger on the limiting component. My suspicion is that it is indeed Windows; therefore, a timer with nanosecond resolution that has to run through a millisecond resolution platform is irrelevant.
w102acd
JonLed 03-20-2008, 01:33 PM A little bit of documentation would be a great addition, any notes available?
Jon
pikovv 04-07-2008, 07:19 PM I decided to use simple For-Next loops for obtaining sub-msec resolution in outputting the microstep signals. This way, a user controls not individual microsteps but groups of 4000-40000 microsteps in 0.1 - 1 sec intervals. This is adequate for my application, which is lasing/etching of simple rectangular shapes. Here I attach the VB program along with notes and a picture of my setup. The main advantage of this versus an earlier program is the ability to control the X-Y stage based on the visual input from the CCD camera mounted on the microscope. The program also has an Autolasing feature, where the user can click on the left-top and right-bottom corners of the rectangle and the program will automatically etch the specified shape. Feel free to use and modify this program for your application.
Victor Pikov
lex_ph 06-30-2008, 04:36 AM Anyone still working on this project?
neilw20 06-30-2008, 10:37 AM I would like to keep this alive. I am looking...
I am using the LPT for a 4 bit data analyzer at 400MHz. With a fifth line for start/stop.
That is data change capture with 2.5nS resolution, time stamped into a file after I fill memory or turn off the switch.
If you were using windows then this would be not possible. It is DOS.
In Windows if you disable() interrupts Windows just says you are not interested in interrupts, and honors your enable() in some future timeslice if you ask it to. Because everything is virtual it only looks like timers and stuff work well. Windows goes off into the weeds on a regular basis. If you use a fast enough machine you can get VB6 to do respectable controlling. A few low level hooks via some drivers can overcome some timing problems like running timers/counters without Windows introduced errors.
Mach3 handles these problems well. Look inside the Mach3 drivers to get some idea of how this can be made to work. You need to be able to feed a queue that is processed by a low level driver to defeat Windows timeslice theft when you need the CPU most.
louste 07-16-2008, 09:32 AM i have just started leaning VB2008.net and i have managed to get most of WinCNC working in .net
is anyone else trying to do this i would be interested in their code!
Ron111 07-31-2008, 12:56 PM Just stumbled onto this thread, and I too am investigating using visual basic express 2008 to control stepper motors via inpout.dll and the printer port and am also in the beginning stages of coming up to speed on visual basic. (I've converted 2 minilathes which is documented is the mini lathe section but using mach2). My current project is tracking solar collectors, and I visualize using visual basic and outputting az & el data from a data base to move the collector every 15 minutes or so. With the price of electric going up I want to develope a tracking scheme where I can drive multiple collectors and PV panels (the price of the PV is suppose to drop in the near future because of some new technology). By tracking the sun, the effeciency of the panel can increase some %50 percent. By tracking using calculations, instead of actually tracking the sun, you are able to track even during cloudy days on the days when you are only able to catch a little sun here and there.
So, anyway maybe we can keep this thread going for a little while longer.
Ron
wayneosdias 04-24-2009, 02:06 PM Total cnc noob, several years vb coding and considerable uC/embedded programming exp.
Again Im just getting my feet wet w/cnc, so be gentle. Is the goal of the VB project to have the pc run the motors realtime? If so I think this will be very difficult w/any windows based platform.
I would think a better approach would be to have an uC based controller run the stepper drivers while being updated by the pc. Isnt this the typical operating scheme for cnc?
I can tell from exp attempting to use vb.net < version 3.5 (2008) has some severe bugs in IO components. Since version 2008 tho I havnt expd any issues.
Im very interested in this project.
pminmo 04-24-2009, 03:20 PM VB is a great tool to build a quick user interface, but this is no simple task to do it correctly. The meat of a cnc controller though has to be a precise timed IO routine. MACH3 for example has a minimum 25khz kernel, and can have up to a 100khz kernel. Someone familiar with Windows Internals and drivers is really needed to build that kernel. My educated guess is the kernel timing needs to output step/dir pulses based on a buffer the background builds as it's intrepreting G-code and doing trajectory planning. That needs to be a low latency timed event. At 50khz that's an update every 25us which doesn't seem like a real difficult task, but you don't want that 25us wondering from 50us one iteration to 15us the next iteration. The emc guys have some applicable documentation:
http://www.linuxcnc.org/content/view/42/13/lang,en/
http://wiki.linuxcnc.org/cgi-bin/emcinfo.pl?Emc2HardwareDesign
Trajectory planning:
http://wiki.linuxcnc.org/cgi-bin/emcinfo.pl?Simple_Tp_Notes
wayneosdias 04-25-2009, 09:07 AM I agree, especially now that windows is designed around the net framework where everything is managed. You run into all kinds of "race" conditions which either corrupt or crash what your doing. I have little exp writing services which is a nightmare due to the inability to debug them and no exp writing kernels. When I do use vb it is usually to create a gui or database for an embedded system that is running io realtime.
wayne
cboudreau 04-25-2009, 10:45 AM Hi Wayne,
I have an MSDN Subscription that has expired, and it came with the eMbedded Visual Tools 3.0 - 2003 and eMbedded C++ 3.0 - 2003
Are these applications capable of building a bootable system? I ask, because I would like to build an application to control a robot. I have 4 mother boards that controls specific parts and functions. To reduce the electrical load, I would like to do away with as much hardware as possible like the hard drives and use USB thumb drives
I am a programmer by trade but never had the time to look into these packages.
Carl
I agree, especially now that windows is designed around the net framework where everything is managed. You run into all kinds of "race" conditions which either corrupt or crash what your doing. I have little exp writing services which is a nightmare due to the inability to debug them and no exp writing kernels. When I do use vb it is usually to create a gui or database for an embedded system that is running io realtime.
wayne
wayneosdias 04-25-2009, 11:53 AM Hi Carl
I have no exp w/windows eMbedded visual tools, just ansi c and c++ compilers for the given micro controllers (uC's) I use (microchip and freescale). Pardon my use of vague jargon. If you looking to minimize hardware I would definatley look to a uC vs a micro processor as uCs are designed with a wealth of onchip peripherals such as memory. Not to mention uCs run at MHz, not GHz greatly reducing power consumption.
Wayne
JamesG 02-23-2010, 08:52 AM Too bad this thread just kind of sputters along...
Are these applications capable of building a bootable system? I ask, because I would like to build an application to control a robot. I have 4 mother boards that controls specific parts and functions. To reduce the electrical load, I would like to do away with as much hardware as possible like the hard drives and use USB thumb drives
You are wanting to build the operator interface in VB or the onboard moton control system? I would not even mess with VB or windows on the 'bot itself, but follow Wayne's advice to going to a microcontroller, depends on how your connectivity is run. If you really wanted to us the PCs, and use PC wireless and controller HW, a barebones DOS or LUNIX with nothing but your motion controller and connectivity program on it. That ought to fit on a thumb drive.
|
|