Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 23, 2024, 12:24:07 12:24


Login with username, password and session length


Pages: [1]
Print
Author Topic: Communication with PC and pic by FTI-232 and VB6  (Read 6963 times)
0 Members and 1 Guest are viewing this topic.
rollins
Guest
« on: April 28, 2008, 02:59:54 14: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, 03:56:28 15:56 »

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

Posts: 763

Thank You
-Given: 173
-Receive: 1298



« Reply #2 on: April 28, 2008, 05:03:09 17:03 »

Put your code here to check it.
Logged
rollins
Guest
« Reply #3 on: April 29, 2008, 08:59:41 08: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: 763

Thank You
-Given: 173
-Receive: 1298



« Reply #4 on: April 29, 2008, 10:53:43 10: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, 11:28:06 11: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: 763

Thank You
-Given: 173
-Receive: 1298



« Reply #6 on: April 29, 2008, 02:55:54 14: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, 03:08:55 15: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, 04:30:53 16: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 [email protected]

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: 763

Thank You
-Given: 173
-Receive: 1298



« Reply #9 on: April 30, 2008, 08:35:55 08: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, 09:54:17 09: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 [email protected]
Logged
UNIDIFF
Guest
« Reply #11 on: May 05, 2008, 10:12:57 10: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, 10:48:12 10: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