DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Serial Interface

Started by RWMURRAY, July 03, 2009, 02:24:19 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

RWMURRAY

Has anyone managed to bring serial data into a designcad macro. I know there are serial wedges which use the keyboard buffer but is there any other way.

Thanks

Richard

Mark Laing

You're aware of the Sysex() and 'open file' functions, right? You're talking about something else, aren't you?

dcadRob

I don't think there is anything in BasicCAD that will hook into a serial port. You need to write a program in another language, use it to read the serial port and connect to DC using OLE. You can either pass the data back to a macro or directly control DC with OLE automation.

RWMURRAY

I am aware of Sysex() but your right this is different, I'm trying to bring in data from a gps receiver RS232 port if you have any suggestions on using Sysex() I would appreciate the help.

As as far as using ole automation has anyone tried a serial interface using ole. I was told back in the good old days when someone was there to talk to, in this case Steve Ledbetter at Designcad that OLE was slow and difficult to implement so I've never tried it.

Regards

Richard

RWMURRAY

Does anyone have any info on the Sys(1029) & Sys(1030) functions, they may be helpful as they appear to allow data transfer fron a DLL.

Richard

Mark Laing

We use GPS and data collection (almost similar) and our instruments download text files. If yours does too, that's the way to go. Designcad is pretty good about reading text files. Plenty quick enough. Can you download a text file from your instrument?

dcadRob

#6
OLE is fairly well documented with lots of examples so it's not that hard to get running. It's slower than BasicCAD but I don't think that would be a problem with a GPS application, unless you are moving really fast and doing real-time mapping.

RWMURRAY

I'm already have data transferring once persecond in real time using a powerbasic subroutine I wrote a couple of years ago which I call from within designcad but it's slow, only one data set per second, I'm trying increase that a hundred fold.

dcadRob

How many samples do you need? 100 per second? PB is pretty fast so I assume the bottleneck is moving data between DC and PB. Are you loading PB every time you call it or is it running in the background? How are you transferring the data now?

RWMURRAY

I'm not really sure what the maximum speed of the link using pb is but likely 4 transfers per second, I'm likely going to need 20 transfers per second. There are various bottle necks and the system is akward to say the least but it works.  I realize OLE is a possibilty but it is simple not as fast as the macro language. The dll data links proved by Sys(1028-1030) would be much quicker as the data availability is regulated by the windows operating system quite effectively. That's not going to happen as Desgncad has no plan to activate this functionallity. I'm told they don't work I've been thinking about trying to see if they do but writing a DLL is something I've never done although PB make it look pretty straight forward. Does anyone else have the skills to test the Sys(1028-1030) to see if they work.

Richard

impulse

There is a guy (a DCAD old timer like me) ... PRL ... who was very good with DCAD & it's OLE interface. He doesnt post here very often now. If you could get him interested, I'm sure that he could render a viability assesment.

Have you considered trying to pass data to DCAD via the sys$(40) interface?
This assumes that PB can write to the Windows clipboard. I dont have a clear Idea of how to synchronize it though.

I have not moved to v19 and I see no reference to sys(29) through (31) in my basiccad help files... Were they mentioned in a release notes somewhere?

impulse

dcadRob

I've been around here for a while and have never heard of sys(1029) or sys(1030). It's not in my doc and I never heard of anyone using it.

I tried an OLE speed test which passes data through a text file. I established an OLE connection. Then I repeatedly wrote 3 numbers to a text file and used OLE to run a macro which read the numbers from the file and displayed them on screen in dc. Using Win XP, Celeron 2.6GHz, late binding in Foxpro, I managed to move 100 x-y-z coordinates in 3 seconds.

You don't even need OLE. You could have PB read the device at regular intervals and dump the results to a file. DC would pick up the file as required.

RWMURRAY

Rob

Sorry I haven't responded to your reply, I've been using the file transfer method for quite a while now with moderate speed, could you post the ole code, perhaps I could give
it a try, I've avoided using it because it's supposedly very slow, however your results would indicate that's not the case.

Regards

Richard

Bob P

I've got an old digital camera with a serial upload connection.  It does a 0.5 Mb picture in about a minute.  Could be worse.

dcadRob

#14
I just saw your February post.

You probably don't have Foxpro so I converted the test program to Powerbasic 8.

PB connects to a running DC with any document open. It writes coordinates X,Y,Z to a work file (OLETEST.TXT) and runs a DC macro (OLETEST.BSC) which reads the file and displays the coordinates in the status bar. On a 1.9GHz Athlon it can do 100 coordinates in 2.8 seconds.

Components:
OLETEST.EXE
OLETEST.BSC in the default macro directory in this case C:\MACRO\
OLETEST.TXT in the default drawing directory in this case C:\DCDRAW\

Output:
INIT is the time in seconds to make a connection to DC
DURATION is the time in seconds to run the test

OLETEST.EXE
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN () AS LONG

   DIM oDCAPP AS DISPATCH
   DIM oDCDOCS AS DISPATCH
   DIM oDCDOC AS DISPATCH
   DIM oVNTS AS VARIANT
   DIM oVNT AS VARIANT
   DIM vCOUNT AS VARIANT
   DIM vMACRO AS VARIANT
   DIM vTRUE AS VARIANT
   DIM vFALSE AS VARIANT
   DIM TIMEINIT AS DOUBLE
   DIM TIMESTART AS DOUBLE
   DIM TIMEEND AS DOUBLE
   DIM I AS INTEGER


   vTRUE=1
   vFALSE=0

   TIMEINIT=TIMER
   LET oDCAPP=  DISPATCH IN "DESIGNCAD.APPLICATION"
   IF ISOBJECT(oDCAPP)=0 THEN
     MSGBOX "DC IS NOT RUNNING"
   EXIT FUNCTION
   END IF

   OBJECT LET oDCAPP.VISIBLE=vTRUE
   OBJECT GET oDCAPP.DOCUMENTS TO oVNTS
   SET oDCDOCS=oVNTS
   OBJECT GET oDCDOCS.COUNT TO vCOUNT
   IF VARIANT#(vCOUNT)=0 THEN
       MSGBOX "NO DOCUMENTS OPEN"
      GOTO NODOC
      END IF
  OBJECT GET oDCAPP.ACTIVEDOCUMENT TO oVNT
   SET oDCDOC=oVNT
    vMACRO="\MACRO\OLETEST.BSC"
    TIMESTART=TIMER
   FOR I=1 TO 100
       OPEN "\DCDRAW\OLETEST.TXT" FOR OUTPUT AS #1
       WRITE #1,I,I+1,I+2
       CLOSE #1
       OBJECT CALL oDCDOC.RUNBASICCAD(vMACRO)
       NEXT I
   TIMEEND=TIMER

       MSGBOX "INIT " & STR$(TIMESTART-TIMEINIT,2) & " DURATION " & STR$(TIMEEND-TIMESTART,2)
   NODOC: 'IF NO DOCUMENT OPEN  BRANCH HERE

       LET oDCAPP=NOTHING
       LET oDCDOCS=NOTHING
       LET oDCDOC=NOTHING

     END FUNCTION
                           


OLETEST.BSC
'ole speed test
open "i",1,"\dcdraw\oletest.txt"
input #1,x,y,z
close #1
print x,y,z

end