Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

device.ocx?

Feb 27, 2011 7:07AM PST

Hello CNET!
can anyone help me pls.?
i have a serial device with manufacturer's provided device.ocx, how could i connect my device trough vb6 coding with the use of the provided device.ocx?
tnx!

Discussion is locked

- Collapse -
Stumper
Feb 27, 2011 11:46AM PST

Your post makes more questions such as what device? What maker? And why not ask them?

Love to comment but the lack of details only leads to more questions.
Bob

- Collapse -
device.ocx
Mar 1, 2011 12:58PM PST

I'm so sorry mr. Stumper.

This is my detailed problem:
I have a device that controls DC motors(24v), IR sensors, relays, etc.
I wanted to make an ocx for this device so that i can easily send command to it using my simple program in VB6.0.
Now my problem is, what will be my starting point to do this? i know how to make ocx in VB6.0 and i know how to use MSCOMM.ocx but i dont know how and what to send a command. Can i use an AT command or whatelse can i use? The main IC of my device is ATMEL 91RM3400.
anyway thanks for replying. i really appreciate that.
Hoping for your immidiate reply.
thanks again.

- Collapse -
Small world.
Mar 2, 2011 12:22AM PST

"Can i use an AT command or whatelse can i use?"

I author such apps but most are used inside companies. The basic sequence of functions I use looks like:

FindMotorController() - Call to find which com port to use.
Motor(Cmd.ON) - Example call to energize the motor.

You ask if the AT command is used but that would suppose the single board computer with the ATMEL had code that responded to such commands.

But let me give you a very important tip. DO NOT IMPLEMENT MOTOR CONTROLS WITHOUT A SAFE PROTOCOL.

Let's say to spin up the motor to 1,000 RPM you use some ATM=1000 command. Since serial lines can be noisy who is to say that the controller didn't see ATM=9000 ?

This is something I'm beginning to think beginners have to learn first hand and the better beginners will figure it out and use some sort of check sum to validate the command.
Bob

- Collapse -
command set
Mar 4, 2011 10:22AM PST

This is the interface information of my device. The problem is i dont know how to use it on vb6.

asynchronous, half duplex

command frame format:
|SOH|null|length|STX|CMD|DATA|ETX|BCC|

Positive response format:
|SOH|null|length|STX|CMD|GOOD|0x01|DATA|ETX|BCC|

example command:
"C11"= get status

- Collapse -
Sorry.
Mar 4, 2011 12:13PM PST

I'm left to guess you need a course in programming (VB6)?

I can discuss programming in general but have to stop if folk want me to conduct classes.

In a nutshell you use that information to write code. Here's the psuedo code:

Open the com port at the speed indicated.
Construct a string with the command.
Send the string.
Read a string from the com port.
Display the result.

Hope this helps,
Bob

- Collapse -
Thanks.
Mar 4, 2011 1:25PM PST

Ive already tried using mscomm and also tried to send a command but i receive no response from it.

Here's a part of my code:

Sub CMD_Send()
Dim CMD As Variant
CMD = "C11"
MSComm1.PortOpen = False
MSComm1.CommPort = 1
MSComm1.Settings = "38400,N,8,1"
MSComm1.PortOpen = True
MSComm1.Output = CMD
End Sub

- Collapse -
(NT) So why didn't you send the rest of the command?
Mar 4, 2011 1:53PM PST
- Collapse -
thanks again.
Mar 4, 2011 3:51PM PST

i've already tried it but nothing seems to happen.
the manufacturer of this device give me an ocx and it has an attribute of something like these:
Private sub form_load()
device.OpenPort
.move
.status
.detectdevice
.object
....etc.

but i really dont know how to use it.
when i tried to open the port:
device.openport 1,38400,true
its good but when i put next to that code:
device.detectdevice
it says error argument not optional.
thanks in advance.
i really appreciate your response.

- Collapse -
Which did not answer my question.
Mar 4, 2011 10:50PM PST

I asked why you didn't send the full command. I see "C11" but it's missing the SOH, NULL and more.

Your reply contains some other error you are encountering which is interesting but outside the boundary I must set for forum discussions. That is, teaching programming.

At least we see the glaring error on the command string.
Bob

- Collapse -
i am so sorry being not so specific for these.
Mar 5, 2011 10:28AM PST

ive already tried this:

Sub CMD_Send()
Dim CMD As Variant
'is these the appopriate format of sending the command or ill convert it first to hex or binary?
CMD = "SOH NULL LENGTH STX CMD DATA ETX BCC"
'or
CMD = Chr$(&H1) & Chr$(&H0) & Chr$(&HCool& Chr$(&H1)& Chr$(C11)& Chr$(&HCool...
MSComm1.PortOpen = False
MSComm1.CommPort = 1
MSComm1.Settings = "38400,N,8,1"
MSComm1.PortOpen = True
MSComm1.Output = CMD
End Sub

no response at all on any of that CMD.

thank you so much sir.
im so sorry again for being so lack of information.

- Collapse -
Much better.
Mar 5, 2011 10:54AM PST

I see you are at least trying to send the full command now. Be sure to research examples on the web about how to send your string properly.

Google vb6 serial port tutorial.

Remember I can't teach programming here or duplicate ready to use content. I will comment when I see a glaring omission.
Bob

- Collapse -
thanks!
Mar 5, 2011 2:58PM PST

after trying my code above,
-->(CMD = Chr$(&H1) & Chr$(&H0) & Chr$(&HCool& Chr$(&H1)& Chr$(C11) &Chr$(&HCool...)
a two parallel bar (||) character appears on my text1.text oncomm event.
I wonder what does this means.
my inputlen=2, but the device seems no response.

---> i have just read a thread that i should have create or
make some packet like structure to send a data from PC..
|| start byte || first byte || second byte || end packet ||
this synchronize the data send from pc to device...

thanks!