Bidirection serial communication
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();
· }
· }
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();
· }
· }
Comments
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
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
Post Edited By Moderator (Bean (Hitt Consulting)) : 12/31/2009 3:50:56 PM GMT
Best Regards,
Brian
This means that if I were to create a TTL serial <-> USB convertor, for example, and had the serial port been full duplex, I would have to have large buffers on the serial port side to buffer in/out data until it got sent through the USB port?
1. Does that mean a TTL serial <-> USB convertor is never a true convertor? In other words a full duplex serial port after a TTL serial <-> USB conversion becomes a "virtual half duplex" serial port (if I wre to emulate a serial port on the USB side)?
2. What are good half duplex projects using VUSB?
Post Edited By Moderator (Bean (Hitt Consulting)) : 12/31/2009 3:51:38 PM GMT