Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

VB and PIC

Status
Not open for further replies.

sandeepa

New Member
Hello all

I have recently started to learn VB and have managed to get data transferred to the PC from the PIC.
What I cant figure out is how do I detect that the ckt connected to the serial port has been switched OFF?
Like I had thought the CommEvent property would be the indication of data present or not,but apparently it is not the case.Getting really confused with all the properties in MSCOMM.Please help.
Thank You.
 
sandeepa said:
Hello all

I have recently started to learn VB and have managed to get data transferred to the PC from the PIC.
What I cant figure out is how do I detect that the ckt connected to the serial port has been switched OFF?
Like I had thought the CommEvent property would be the indication of data present or not,but apparently it is not the case.Getting really confused with all the properties in MSCOMM.Please help.
Thank You.

I don't think there is any way to detect the external circuit has been turned off, unless you're using handshake lines?.
 
sandeepa said:
Will check out the link...but like I said before,right now I am not using the handshaking lines.

So you're not likely to be able to detect it's turned off then, because there's nothing to detect. One possible way would be to send a data byte and wait for a reply, if it didn't receive a byte back within a certain time you would know it's turned off.

What exactly are you trying to do?, it could have a huge bearing on the thread!.
 
its easy

the comm object read from a buffer and thats the info you can work with.

if you want to detect the present of a pic just put something in the buffer..

Like the word "present" or in one byte just the P

then your VB prog can check the buffer every second (using a timer)

and then it knows if it is present..once present you could do the rest of protocol. if you make it i send something and the other sends an ack then you have a slower conection but a better quality..etc..

TKS
 
that's exactl how it's done with no handshaking. if you use handshaking,
let the pic control DSR for example (data set ready, pin6). this way you will be able to tell right away if connection is made and if device on the other end is talkative... personaly i'm ok with timeout and don't use handshaking since it's simpler wiring.
 
What exactly are you trying to do?, it could have a huge bearing on the thread!.
I am trying to do some sort of multichannel data aquisition,where every consecutive data is of a new channel.So I am not sending the channel number and only incrementing it with the arrival of every new data.But now,if my ckt gets turned off,the channel number has to get back to 0.Which is why I want to detect the turning off of the ckt.I hope this clear.

Is using a timer the usual way of doing this kind of stuff?

Thanks.
 
sandeepa said:
What exactly are you trying to do?, it could have a huge bearing on the thread!.
I am trying to do some sort of multichannel data aquisition,where every consecutive data is of a new channel.So I am not sending the channel number and only incrementing it with the arrival of every new data.But now,if my ckt gets turned off,the channel number has to get back to 0.Which is why I want to detect the turning off of the ckt.I hope this clear.

Is using a timer the usual way of doing this kind of stuff?

Simple answer! - send channel ID with each sample, that way you are assured of routing the samples correctly - any other way will be 'mostly' correct (if you're lucky!).
 
ok...

its easy...

the best way to do it is including Channel number because the windows buffer miht be shaken a bit by windows...

also use a special symbol like ";" for example later in VB you can split the data using that symbol..(on the pic side let every var end with this symbol)

depending on the time between data arival (its the time in wich you pc knows if the pic is conected or not..!!)

it depends if you need "Alive" msges or not...

for example if you send a channel data every minute or every second..

every minute might need a alive msg every 5 sec or so..depending on your needing / willings...

TKS
 
Finally did it the way you suggested,sending the channel id with the data.Checking for ckt present would indeed give a lot of other problems.
Thanks for all your inputs.
TKS,I didnt get what you meant by "Alive" messages.What exactly are you referring to?
Thanks.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top