12f675_fuse_about_to_blow!


Closed Thread
Results 1 to 40 of 929

Hybrid View

  1. #1
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Well, what happens now is, the data is coming in (vertical line of numbers on the left hand side of the listbox) so I'm getting for example:

    1
    3
    5
    *
    *
    2
    0
    3
    *
    *
    1
    1
    *
    *
    The asterisk's represent what appears to be a number 1 in a thin bold square, which occurs after each transmitted BYTE with a four second delay as per the program, interesting. The Serial Communicator still worked a treat with ,$d,$a. I need to get the incoming numbers Horizontal and maybe spaced one line apart for ease of reading.

    Any other ideas?

    Dave

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    I think I may be confused.
    VB has the numbers
    1
    3
    5
    *
    *
    2
    0
    3
    *
    And Serial Communicator has them
    135
    203
    ??
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    That's spot on mackrackit.

    I think the VB prog maybe displaying the correct random BYTE sent from the PIC only vertically as opposed to horizontally.

    Dave
    Last edited by LEDave; - 8th September 2010 at 05:28.

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Are you DIMing the VB input as a string as shown here. "Dim recepcao As String"
    http://www.picbasic.co.uk/forum/show...2628#post92628
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Hi mackrackit,

    Sorry for the late reply.

    Are you DIMing the VB input as a string as shown here. "Dim recepcao As String"
    Well I tried to. The problem is with the posted program as I see it, is that it's not actually outputting any data to a Textbox or Listbox which is what I need to do .Also with VB 2008 you have to use INVOKE or an INVOKER to make a cross thread call else you incur an error(I think).

    Here are my two programs. One from the other thread below (Which doesn't receive data):

    Code:
    Public Class Form1
        Dim WithEvents SerialPort1 As New IO.Ports.SerialPort
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            SerialPort1.PortName = "COM1"
            SerialPort1.Parity = IO.Ports.Parity.None
            SerialPort1.BaudRate = 2400
            SerialPort1.DataBits = 8
            SerialPort1.StopBits = 1
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            If SerialPort1.IsOpen = False Then SerialPort1.Open()
            If SerialPort1.IsOpen = True Then MsgBox("com1 port opened sucessfully")
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            If SerialPort1.IsOpen = True Then SerialPort1.Close()
            If SerialPort1.IsOpen = False Then MsgBox("com1 port closed sucessfully")
    
        End Sub
    
        Private Sub DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
            Dim recepcao As String
    
            recepcao = SerialPort1.ReadExisting
    
    
    
        End Sub
    
    
        Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
            SerialPort1.Write(ListBox1.Text)
    The other using INVOKE which nearly works, it stacks the incoming data vertically (as previously discussed) but it does receive data from the PIC:

    Code:
    Imports System
    Imports System.ComponentModel
    Imports System.Threading
    Imports System.Windows.Forms
    
    
    Public Class Form1
    
    
        'Buffer for receievd data***
    
        Private Delegate Sub AddListBoxItemInvoker(ByVal item As Object)
    
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            SerialPort1.PortName = "COM1"
            SerialPort1.Parity = IO.Ports.Parity.None
            SerialPort1.BaudRate = 2400
            SerialPort1.DataBits = 8
            SerialPort1.StopBits = 1
    
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            If SerialPort1.IsOpen = False Then SerialPort1.Open()
            If SerialPort1.IsOpen = True Then MsgBox("com1 port opened sucessfully")
    
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            If SerialPort1.IsOpen = True Then SerialPort1.Close()
    
            If SerialPort1.IsOpen = False Then MsgBox("com1 port closed sucessfully")
    
        End Sub
    
        
    
        Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
    
            Me.AddListBoxItem(SerialPort1.ReadExisting)
    
    
        End Sub
    
        Private Sub AddListBoxItem(ByVal item As Object)
    
            If Me.ListBox1.InvokeRequired Then
                'We are on a secondary thread so delegation is required.
                Me.ListBox1.Invoke(New AddListBoxItemInvoker(AddressOf AddListBoxItem), (item))
    
            Else
                'We are on the primary thread so add the item.
                Me.ListBox1.Items.Add(item)
            End If
        End Sub
    End Class
    Any ideas? Or maybe a passing VB'er might have the answer.

    Should I post this over on the other thread do you think?


    Dave

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Should I post this over on the other thread do you think?
    yup
    I would. Makes no sense to me.
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Hi mackrackit,

    I've posted it over on the VB thread (link below). Will be interesting to see if anyone has any ideas.

    http://www.picbasic.co.uk/forum/show...3607#post93607

    Dave

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts