Parallax Forums
  HomeLog InRegisterCommunity CalendarSearch the ForumHelp
   
Parallax Forums > Public Forums > Javelin Stamp > Bidirection serial communication  Forum Quick Jump
 
New Topic Post Reply Printable Version
[ << Previous Thread | Next Thread >> ] | Show Newest Post First ]

brianL
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Aug 2008
Total Posts : 8
 
   Posted 10/29/2009 5:36 AM (GMT -8)    Quote This PostAlert An Admin About This Post.

I’ve been trying to figure out why I can only send strings to my pic controller.  When I try using the Uart receiveByte() method I only get a solid 2vdc signal.  Below is some of the code I used to try and get this to work.  The parallax USB oscilloscope has helped a ton, but I’m still stuck with this problem.  Any help would be appreciated.

Thanks,

Brian

 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

package mainclasses;

import  stamp.core.*;

import Arobot.*;

 

public class Arobot2 extends VirtualPeripheral {

  public static picnet motor = new picnet();

  //public static picnet2 motor2 = new picnet2();   tried creating an object here first and also tried using a static method in picnet2 class

 

  public static void main() {

     char r = 'b';

     int j = 0, cnt = 0;

     motor.run();

     while (true) {

     cnt++;

     if (r == 'A')

      motor.stop();

     if (r == 'b')

      {

      if (cnt == 5)  {   // cnt being used because I don't know how to instantly switch from transmit to receive after string is sent when Uart is background VP

        j=picnet2.wildCard;                 // if I get rid of this line the controller will send the string to the pic

        continue;

        }

      else

        continue;

      }

     else      {

      motor.run();

      r='b';

      }

   }

  }

}

/////////////////////////////////////////////////////////////////////////////////////////

 

package Arobot;

import stamp.core.*;

 

public class picnet2 {

  public static int wildCard = 0;

  public static final int netPin = CPU.pin8;

  public static Uart UartReceive = new Uart(Uart.dirReceive, netPin, Uart.dontInvert, Uart.speed2400, Uart.stop1);

 

  public void showByte()  {

  wildCard=UartReceive.receiveByte();

  }

  }

Back to Top
 

Peter Verkaik
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jul 2004
Total Posts : 3860
 
   Posted 10/29/2009 10:06 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Hi,

First, do not declare
public class Arobot2 extends VirtualPeripheral {
but use
public class Arobot2 {

You can change a Uart from transmit to receive
by using
myUart.setDirection(Uart.dirReceive)

Also, since you use a single pin for transmit and receive,
use a 1k resistor between Javelin I/O pin and your PIC pin.
This is to protect the pins in case both devices transmit
at the same time.

regards peter
Back to Top
 

Kaderkhan
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Oct 2009
Total Posts : 1
 
   Posted 10/30/2009 9:08 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
HI guys

how are you? I would like to thanks for your comments and I think that Bidirectional Serial Communication Modules ... 1. Simplified bidirectional communication module, depicting ... Crosstalk in bidirectional serial communication.Serial ports, also called communication (COM) ports, are bidirectional. The bidirectional communication allows each device to receive and transmit data.


Thanks

















Plante grande surface
Back to Top
 

brianL
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Aug 2008
Total Posts : 8
 
   Posted 11/3/2009 3:05 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
I’ve had family in town so I’m just now getting a chance to try out some of your advice. I’m still having some trouble. I tried before using the setDir(Uart.dirReceive) method but wasn’t able to get it to work. Would this switch from transmission to receive instantly? I can’t remember if I even had to get a char ‘A’ back from my pic controller; I’m thinking that I used to just transmit a string with the distance as the last four bits and my motor would just stop when the pic read the distance from the enoder. My pic came preprogrammed so I don’t know exactly how it behaves (robot kit). I was also trying to use the compass AppMod in serial mode. This is parallax compass that is now obsolete. One of these days I’ll have more time to actually concentrate on my hobbies. .

Best Regards,
Brian
Back to Top
 
[ << Previous Thread | Next Thread >> ]
New Topic Post Reply Printable Version
 
Forum Information
Currently it is Saturday, November 21, 2009 11:37 AM (GMT -8)
There are a total of 393,861 posts in 55,536 threads.
In the last 3 days there were 84 new threads and 712 reply posts. View Active Threads
Who's Online
This forum has 17692 registered members. Please welcome our newest member, old guy.
52 Guest(s), 13 Registered Member(s) are currently online.  Details
Siri, Jay Kickliter, Mike Green, Jim Fouch, Dogg, hover1, ErNa, Harley, Sapieha, Electronegativity, Tubular, Leon, MicroDirk