Re: General VB program structure

From you explanation, if I understand correctly, it does sound as thought the VB side will be relatively straight forward and that the machine control side will be handled elsewhere (pics).

The interface between your VB6 program and RoboRealm, again should be straight forward and there are examples on their website on writing/reading variables amongst other more complex functionality (reading images back for example).

Again, you could probably make the VB6 program as simple or complex as you want. For example you could use a database to store the "recipe" information related to each product, with as little or much information as you need (part code, descr, image, etc.), but it might make sense to start simple and expand....get the functionality thereabouts then flesh it out.

Is the VB6 program going to be sitting polling the PIC for status information once the process is started and also, is the VB6 program going to "control" the process flow (start, stop)?

Just trying to understand the interlock side of things on what starts the process (i.e.: I assume you don't want the robo to start if nothing is loaded into RoboRealm for example).

In regards to the polling side of things, you can have VB sat in a loop reading a COM port, alternatively, you could have a time executing every so many milliseconds that reads the port, it's entirely up to yourself.

Again, if you need to control the start and stop of the system, again this is doable with something like below (just done off the top of my head, so please excuse any typos, it's for explaining a concept only):

dim blnRunning as boolean
'Click event handler for the Start Button
Private sub cmdStart_Click()
' Set flag to indicate we've started the machine
blnRunning=true
' Execute the programs main loop
subRunMachine()
End Sub
'Click event handler for the Stop Button
Private sub cmdStop_Click()
' Clear flag to indicate we've stopped the machine
blnRunning=false
End Sub
'Routine for running the machine
Private sub subRunMachine()
'Start a loop that will execute until the flag is cleared
Do While blnRunning
'DoEvents relinquishes control to the OS to process other events.
'without it in here the loop would be so tight, we wouldn't be able to
'click the Stop button (or at least see it's event)
DoEvents()
'In this loop, you would do what ever you needed to, such as calling a routine
'to read your com port and maybe update labels on screen, to indicate the current
'status of the process.
Wend
End Sub

I know this is very top level, but hopefully it gives you a couple of pointers on how you can do things.

Re: General VB program structure

Posted 30 August 2013 - 07:56 PM

Or, you could set up an asynchronous relationship between the machine and VB. There are two ways to do this: have the machine raise an event when it's done working, or pass it a pointer to a procedure that it can call when it's done. The latter is more precise but also more complicated.

Here's a sample using a separate EXE to handle the functionality and raising an event when done.