Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

NetduinoGo - PC Serial Communication


  • Please log in to reply
8 replies to this topic

#1 PhillipMorris

PhillipMorris

    Member

  • Members
  • PipPip
  • 17 posts
  • LocationSerres, HELLAS

Posted 18 May 2012 - 09:41 AM

Hello there, I wonder if there is a way to serial communication from/to PC - NetduinoGo. I am planning to write a windows app to send some strings or boolean values to Netduino in order to open/close relays. Can NetduinoGo send values to serial comm port ? Do I need a special board to do it ? eg convert Rx/Tx to USB ? Thanks.

#2 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 18 May 2012 - 10:14 PM

I am assuming the NGO is like the ND+ where you would need an FTDI cable or FTDI board.

#3 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 19 May 2012 - 05:55 AM

I'm pretty sure there will be a USB-Serial go!module for Netduino Go later this year.

In the meantime, I use the Sytech USB Serial Gadgeteer Module with mine. It takes up a whole channel (4 sockets), but it works great. I then open either COM1 (sockets 1-4) or COM2 (sockets 5-8) from my Netduino Go app...and can chat back and forth to the PC.

You could also break out the socket with an FTDI chip, cables, etc.

Chris

#4 Jeffistan

Jeffistan

    New Member

  • Members
  • Pip
  • 2 posts

Posted 20 May 2012 - 03:31 PM

I don't have an FTDI or similar devic to convert USB to RS-232. Can I do serial comms between my Netduino and the PC directly with the PC's RS-232 port? Thanks, Jeff

#5 PhillipMorris

PhillipMorris

    Member

  • Members
  • PipPip
  • 17 posts
  • LocationSerres, HELLAS

Posted 20 May 2012 - 05:45 PM

I would like to share my experience so far.
I used this board : FOCA Board v2.1

Connections
NetduinoGo gobus (Socket#1) pin 4 (Rx) to FOCA Board Tx
NetduinoGo gobus (Socket#1) pin 5 (Tx) to FOCA Board Rx
NetduinoGo gobus (Socket#1) pin 10 (Grd) to FOCA Board Grd

Here is the code :
Imports System.IO.Ports
Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware
Imports SecretLabs.NETMF.Hardware.NetduinoGo
Imports System.Text
Imports Microsoft.VisualBasic.Constants

Module Module1
    Dim IncomingText As String = ""

    Dim reading As Boolean = False
    Dim count As Integer
    Dim readLength As Integer
    Dim InTray As Byte()
    Public WithEvents SerialPort As New SerialPort("COM1", 9600, Parity.None, 8, StopBits.One)


    Sub Main()

        SerialPort.Open()
        AddHandler SerialPort.DataReceived, New SerialDataReceivedEventHandler(AddressOf serialPort_Datareceived)
        AddHandler SerialPort.ErrorReceived, New SerialErrorReceivedEventHandler(AddressOf serialPort_ErrorReceived)
        Thread.Sleep(Timeout.Infinite)

    End Sub

    Sub serialPort_ErrorReceived(ByVal sender As Object, ByVal e As SerialErrorReceivedEventArgs)
        Debug.Print(e.ToString)
    End Sub

    Sub serialPort_Datareceived(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs)
        'Debug.Print("Data Received")

        'Incoming Bytes
        Dim IncomingBytes As Integer = SerialPort.BytesToRead
        ' Create a new temporary store
        Dim DataStore(IncomingBytes) As Byte
        'Read in the bytes
        SerialPort.Read(DataStore, 0, IncomingBytes)
        'Convert Bytes to String
        IncomingText = System.Text.Encoding.UTF8.GetChars(DataStore)
        'Check for CarrageReturn and trim
        If IncomingText.IndexOf(vbCrLf) > 0 Then
            IncomingText = IncomingText.Trim
            Debug.Print(IncomingText & "  Len: " & IncomingText.Length)
            IncomingText = ""
        Else
            Debug.Print(IncomingText & "  Len: " & IncomingText.Length)
        End If

        'Send Data back
        'SerialPort.Write(Encoding.UTF8.GetBytes(strDataStore), 0, strDataStore.Length)

        'Do something with the data
        CheckRecievedData(IncomingText)
    End Sub

    'Do something with the data
    Sub CheckRecievedData(ByVal strData As String)
        Select Case strData
            Case ""

            Case "ON"

            Case "OFF"

        End Select
    End Sub

End Module

I will post the code of the Windows Application which accepts and send data from/to NetduinoGo probably tomorrow.
I hope that somebody will find it usefull.

#6 DioVievaCoare

DioVievaCoare

    New Member

  • Members
  • Pip
  • 1 posts
  • LocationParis

Posted 22 May 2012 - 06:48 PM

I want to use serial communication in ipodlinux. but in Project Status Page on hardware compatibillity section, serial is not supported by ipodlinux. Is that mean I cant receive data from serial port UART? best regards, ikhwan

#7 Gorf

Gorf

    Advanced Member

  • Members
  • PipPipPip
  • 96 posts

Posted 17 July 2012 - 08:59 AM

I would like to share my experience so far.
<snip>
I hope that somebody will find it usefull.

Thank you for posting this, Phillip. It was a huge help.

#8 Andy J

Andy J

    New Member

  • Members
  • Pip
  • 5 posts

Posted 12 February 2013 - 10:08 PM

[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;font-size:12px;font-weight:bold;]PhillipMorris, thanks for your explanation.  I believe I followed it but am unable to achieve IO.  Here's my current setup:[/color]

 

[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;font-size:12px;font-weight:bold;]- Foca v2.2[/color]

- Netduino Go and shield base

 

Connections

[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]NetduinoGo gobus (Socket#1) pin 0 (Rx) to FOCA Board Txd[/color]

[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]NetduinoGo gobus (Socket#1) pin 1 (Tx) to FOCA Board Rxd[/color]
[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]NetduinoGo gobus (Socket#1) pin GND or 14 (Grd) to FOCA Board Grd[/color]

 

using System;using System.Threading;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware;using SecretLabs.NETMF.Hardware.NetduinoGo;using System.IO.Ports;using System.Text;namespace _4._2{    public class Program    {        public static void Main()        {            //NetduinoGo.ShieldBase sb = new NetduinoGo.ShieldBase(GoSockets.Socket1);                        SerialPort p = new SerialPort(SerialPorts.COM1, 9600, Parity.None, 8, StopBits.One);            p.ReadTimeout = 10;            p.DataReceived += new SerialDataReceivedEventHandler(p_DataReceived);            p.ErrorReceived += new SerialErrorReceivedEventHandler(p_ErrorReceived);            p.Open();            while (true)            {                p.WriteByte(40);                p.Write(Encoding.UTF8.GetBytes("test"), 0, 4);                Thread.Sleep(100);            }        }        static void p_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)        {            throw new NotImplementedException();        }        static void p_DataReceived(object sender, SerialDataReceivedEventArgs e)        {            throw new NotImplementedException();        }    }}

 

The foca module has rx and tx micro led lights signalling data flow.  Tx lights up when I send data to device from pc.  The netduino is unable to capture any inbound data nor send outbound data.  I tried every permutation of netduino pins 0 - 5, 10 and standard gnd to the foca rx/tx/gnd pins.  I'm not sure how Phillip arrived at using pins 4,5 and 10 vs 0,1 and gnd.  Hari uses pins 0 and 1 though he's using a standard netduino.

 

Any thoughts welcome.



#9 Andy J

Andy J

    New Member

  • Members
  • Pip
  • 5 posts

Posted 18 February 2013 - 12:00 AM

Wanted to report I solved my own problem.  Being a newb, I interpreted pins 4,5 and 10 as the same as the shield base pins when in actuality, PhillipMorris was referring to the raw GoBus socket 1 bus of 10 pins.  I wasn't aware people were "hacking" the sockets to achieve serial IO.  Also, Chris released new firmware for the shield-base which let me use the digital io pins as intended.  Together with this update and the handy pin-out picture illustrated by Gutworks, I've successfully communicated between PC and MCU in both directions using the Foca v2.2.  Very excited to move forward thanks to the community.  Cheers






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.