Shop OBEX P1 Docs P2 Docs Learn Events
Talking to DC-16 output expansion board — Parallax Forums

Talking to DC-16 output expansion board

Nicholas BottNicholas Bott Posts: 12
edited 2006-10-13 15:03 in General Discussion
I can't seem to get Javelin to talk to the DC-16 Output Expansion Board (#31216). I wrote a Uart Library; but, it doesn't seem to be responding to my messages.

I attached my java code. Any help would be appreciated as I've stumbled over this issue with RC-4 and other serial controlled things. I can only find P-BASIC examples, so I'm sorta stuck.

Thanks much!

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-10-13 06:45
    You don't need to write your own Uart!
    The javelin has a class for Uart (see manual).
    For bidirectional you need 2 uart objects.

    import stamp.core.*;public class Testing{ static Uart serialTx = new Uart(CPU.dirTransmit,CPU.pin15,Uart.dontInvert,Uart.speed2400,Uart.stop1);
    static Uart serialRx = new Uart(CPU.dirReceive,CPU.pin14,Uart.dontInvert,Uart.speed2400,Uart.stop1);
    static Timer t = new Timer(); public static void main() {
    int n=0,c;
    serialTx.sendString("!DC16"); char block = 3; serialTx.sendByte(block); serialTx.sendByte('V'); System.out.println("Sending..."); //System.out.println(serial.SerOut(1000)); System.out.println("Receiving..."); while (true) { //Expect 3 bytes and wait up to 1000ms for them (sweet!)
    System.out.print("BINGO! ");
    t.mark(); //reset timer while (!t.timeout(1000) && (n<3)) {

    if (serialRx.byteAvailable()) {
    c = serialRx.receiveByte(); System.out.print((char)c);
    n++; }
    }
    System.out.print('\n'); } }}
    That should give you an idea how to use the Uart object.
    regards peter

    Post Edited (Peter Verkaik) : 10/13/2006 6:49:04 AM GMT
  • Nicholas BottNicholas Bott Posts: 12
    edited 2006-10-13 07:37
    I haven't had any luck with your example. I tried dontInvert and invert, I also tried swapping pins. Is Red generally Input or Output?

    I have only been able to get 0 (byte) reply from the DC16 unit. (which is just based upon the invert / dontInvert / Pin)

    There are a few things I need to verify. The BASIC example they give is:
    SEROUT Pin, Baud, ("!DC16", %11, "V")
    SERIN Pin, Baud, v1, v2, v3

    Do you see anything wrong with my attempt in the attached file?
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-10-13 08:21
    I checked the DC16 manual. It appears the DC16 board uses a single pin
    to transmit and receive.
    I adapted my psc class for the DC16 board.
    This class must be stored in folder
    %IDE path%\lib\stamp\peripheral\relay\dc16\

    Read this class how to connect the javelin to the DC16 board, using either 1 or 2 javelin
    I/O pins.

    regards peter
  • Nicholas BottNicholas Bott Posts: 12
    edited 2006-10-13 12:49
    Thanks for writing a wrapper, Peter. Unfortunately it seems to return a random number for the Firmware Version every time - and although I don't really care about the version, I just want to get it to do *something*, it doesn't seem to be responding to my invokes. (I checked the output with a meter)

    Not sure if you have any more advice about this, since I know you don't have the component to test with.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-10-13 13:20
    I don't have the component.
    Check the wiring. You need to have a 0V connection (GND dc16 to GND javelin)
    and a TX/RX connection (Javelin I/O pin to dc16 pin).·I·think the dc16 pin to use
    is the one marked W (there is a 3pin connector labeled RWB on the dc16 board)
    I know the communication worked on the psc board.

    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-10-13 13:27
    Do you use the one pin or the two pin connection
    as described in the DC16 class?

    regards peter
  • Nicholas BottNicholas Bott Posts: 12
    edited 2006-10-13 13:55
    I got it working! Thanks for your help!
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-10-13 14:15
    Great.
    How do you connect the dc16 board to the javelin to make it work?

    regards peter
    ·
  • Nicholas BottNicholas Bott Posts: 12
    edited 2006-10-13 14:20
    I am using the one pin setup. The white wire turned out to be the one I needed to talk to. The ground is plugged into VSS and the White wire is plugged into Pin14.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-10-13 14:23
    Thanks.
    I updated the DC16 class with that info.

    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-10-13 14:44
    I optimized the DC16 class so it takes less code space.

    regards peter
  • Nicholas BottNicholas Bott Posts: 12
    edited 2006-10-13 15:03
    Thanks!
Sign In or Register to comment.