Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 03, 2016, 10:50:05 22:50


Login with username, password and session length


Pages: [1]
Print
Author Topic: Communication with PC and pic by FTI-232 and VB6  (Read 2989 times)
0 Members and 1 Guest are viewing this topic.
rollins
Guest
« on: April 28, 2008, 03:59:54 15:59 »

I'm tryng to communicate in full duplex with a pc (vb6)  and a pic 16f628

When I put a button with send command to the pic , the pc send , the pic receive and after send.
But without button it doesn't work

someone has in the past the same problem ?

Best regards* Huh
Logged
locus
Newbie
*
Offline Offline

Posts: 9

Thank You
-Given: 1
-Receive: 15


« Reply #1 on: April 28, 2008, 04:56:28 16:56 »

You may need to put a delay routine for the PC
Logged
Ahmad_k
SCG Moderator
Hero Member
*****
Offline Offline

Posts: 604

Thank You
-Given: 111
-Receive: 1059



« Reply #2 on: April 28, 2008, 06:03:09 18:03 »

Put your code here to check it.
Logged
rollins
Guest
« Reply #3 on: April 29, 2008, 09:59:41 09:59 »

Thanks but the delay is not important, the problem I Think is when you use the commevent, you can't put a send statment in case of receive for exemple

t

Posted on: April 29, 2008, 09:51:20 09:51 - Automerged

Here vb code:

Private Sub Comm1_OnComm()
Select Case Comm1.CommEvent
    Case comEvReceive
    byterec = Comm1.Input
    If Asc(byterec) = 13 Then
        fin = Len(Text1.Text)
       
        temp = Val(Text1.Text)
        ' here the code for data treatment
       
       
        Text1.Text = ""
        '
        '   Here I want to put a send statment but nothing append !!
        '
        Comm1.Output = Format(adress, "00000") & Chr(0) & _
                Format(ordre, "000") & Chr(0)


    Else
        Text1.Text = Text1.Text + byterec
    End If

End Select
 Huh
End Sub
Logged
Ahmad_k
SCG Moderator
Hero Member
*****
Offline Offline

Posts: 604

Thank You
-Given: 111
-Receive: 1059



« Reply #4 on: April 29, 2008, 11:53:43 11:53 »

I think this code wait for data receive (byte : 13) if it is received then the PC send the required string. So it will not work like you said.

In your first post you said that the PC send first and then PIC respond, so now the PIC is not respondind because the PC isn't sending anything. If you can also put you PIC code.
Logged
locus
Newbie
*
Offline Offline

Posts: 9

Thank You
-Given: 1
-Receive: 15


« Reply #5 on: April 29, 2008, 12:28:06 12:28 »

The problem is that you try to send a message from within the receive event.
The receive event should finish first before a send command can be issued.
This is because the oncomm event handles both send and receive events

Try put a timer.
Logged
Ahmad_k
SCG Moderator
Hero Member
*****
Offline Offline

Posts: 604

Thank You
-Given: 111
-Receive: 1059



« Reply #6 on: April 29, 2008, 03:55:54 15:55 »

The problem is that you try to send a message from within the receive event.
The receive event should finish first before a send command can be issued.
This is because the oncomm event handles both send and receive events

Try put a timer.
This is what i talking about, but we must be sure from his code to be ok, and then use a timer on visual basic.
Logged
sherm
Junior Member
**
Offline Offline

Posts: 44

Thank You
-Given: 14
-Receive: 9


« Reply #7 on: April 29, 2008, 04:08:55 16:08 »

Go here and look at these two excellent examples of how to communicate between a PC and PIC using VB6 and PicBasic Pro. They're both good code for basing your own applications on.

Sending data from a PC ... http://www.rentron.com/sending_data.htm

Receiving data from a microcontroller ... http://www.rentron.com/receiving_data.htm
Logged
rollins
Guest
« Reply #8 on: April 29, 2008, 05:30:53 17:30 »

Thanks but I don't know why I 've been put down with restriction !

Would you please send link to me by email at lidyb@laposte.net

best regards


Posted on: April 29, 2008, 05:20:44 17:20 - Automerged

to Ahmad_k

No at first I ask to the pic to answer and after, it's would be automatic.
You right for the commevent behaviour, so I can use a timer , but do you think that It could be possible to work without a
MSCOMM ?

 best regards
Logged
Ahmad_k
SCG Moderator
Hero Member
*****
Offline Offline

Posts: 604

Thank You
-Given: 111
-Receive: 1059



« Reply #9 on: April 30, 2008, 09:35:55 09:35 »

For my projects i use MSCOMM_OnComm() only for initializing and then i use Timer on VB, on each timer overflow, i check i check the InBufferCount size to see if the whole data has been received if yes i respond with some fonctions and procedure calls.

When you use TIMERS in your VB code the usage of the CPU will be lower. So keep going and we are here to help you.
Logged
rollins
Guest
« Reply #10 on: May 05, 2008, 10:54:17 10:54 »

Thank Ahmad , I will have a look on this method and I keep you in touch

Many thanks again


Posted on: April 30, 2008, 04:35:22 16:35 - Automerged

To sherm

Not able to get the link, would you please send it to me by mail at lidyb@laposte.net
Logged
UNIDIFF
Guest
« Reply #11 on: May 05, 2008, 11:12:57 11:12 »

Hi

What is a Fti 232 Huh do you means FT-232 from FTDI Huh

br
Logged
rollins
Guest
« Reply #12 on: May 05, 2008, 11:48:12 11:48 »

Ho yes FT-232 from FTDI,

Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC