Asked — Edited

Help With Connecting A Serial Device

I'll try to make this quick and to the point. Trying to interface a device that has a rs-232>ttl converter attached to it (the device is like a controller). I attach the signal from EZB D0 to the RX on the ttl converter. The red LED lights with a small green flashy led on the converter. So far so good. I'm not sure I understand all the functions on the serial terminal, so i skipped and went to the sendserial command to try and get it to work. The device uses baud 19,200 to communicate. The device uses several commands, each command is preceded by a ">". IE to send a command to trigger and play a track would be:

play 0

That would play track 0 or the first track. So I wrote a line :

SendSerial(d0,19200,">play 0")

I get no error in my syntax, and i do see the blue light go on the ezb when i start the script, but nothing happens on my device. I am sure everything is working on the device, as i tested it all before i connected the ezb and its fine. Maybe I just have no idea how to write the proper code, or perhaps I need some other wire to be connected to the ttl converter. Hopefully I can get it working with some suggestions. I feel I am close.

Below is an image of the ttl converter and my pin on the rx.

User-inserted image


ARC Pro

Upgrade to ARC Pro

Unleash your creativity with the power of easy robot programming using Synthiam ARC Pro

PRO
USA
#9  

Great additional info Rich, I will give it a try!

#10  

One other silly thought.. I have a USB to TTL adapter that has the tx and rx lines mis-labeled. Maybe this device is from the same manufacturer and they mis-label consistently? Try connecting to the tx instead and see if it hears your signal.

#11  

Good point Alan... Used to need to use a "null" modem adapter when communication to two serial devices (swapping the Rx and Tx so that the devices weren't receiving and transmitting on the same pins))

PRO
USA
#12  

Ok I heard back from them. They were making sure I had it connected correctly. And added that I need to be sure to send the line end (in C++ this would be "/r/n"). Also that I need to drop the ">" which is simply the prompt if you open up in a serial terminal with tx and rx active. I I will try a couple of new lines today with the changes and try the tx/rx switch around, ground etc. If I knew I had the code right then I could work on making sure the the hardware was connected correctly. Too many variables to change at once!

PRO
USA
#13  

Ok,

I'm going to need some help here. To recap, the manufacturer of the device have no docs beyond the serial terminal usage. Ther are no libraries on using serial commands (via ttl). So I scoured the internet for anyone using this device. I found one guy who owns a prop house who actually wrote some code to use a controller with it (PIC). You can read below his email to me. If anyone has programmed the pic controller and knows how to transfer this code to match what you need to do in the EZB serial commands, please help me to get this to work. He randomized playing of his routines. I want to play "x" by send the code. But it seems everything is in his code adn directions. Any help figuring this out I would be grateful.

His email and code:

Hi Will,

I was using a PIC microcontroller to monitor n IR sensor and then tell the Rapu unit to randomly choose one of 7 routines to run. Looks like I send a cr character first (ascii 13) but not exactly sure why I do this. (I wrote this years ago) Here is the routine I used:

void TransmitCommand(int8 intRandomValue) { int8 BufferVal;

putc(13);
delay_ms(100);
while (kbhit()) //this clears the buffer
  BufferVal=getc();

putc(112); //"p"
delay_ms(10);

putc(108); //"l"
delay_ms(10);

putc(97); //"a"
delay_ms(10);

putc(121); //"y"
delay_ms(10);

putc(32); // space
delay_ms(10);


//put numeric value of routine here (0-7)

putc(48+intRandomValue); //send ascii equiv of the number 0 - 7; the

number zero is ascii 48 delay_ms(10);

putc(13);

}

United Kingdom
#14  

I'm no expert on PIC programming (in fact I'm on the other end of that spectrum) but looking at his code I guess he is using the equivalent of


$track = GetRandom(1,7)
SendSerial(port, baud, 0x13, "play ", $track, 0x13)

Obviously replace port & baud as required.

To explain a little (so you can try to follow what I did to work it out). His code is sending a carriage return (13 in his code, 0x0D in mine) then the word play (done with dec. for the ascii characters one by one in his code, then a space in dec., then the track number (again in dec.) and followed by another carriage return in dec.

If you wanted you could use just the hex i.e. for track 1

SendSerial(port, baud, 0x0D, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x31, 0x0D)

track 2 would be

SendSerial(port, baud, 0x0D, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x32, 0x0D)

track 3

SendSerial(port, baud, 0x0D, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x33, 0x0D)

You should be able to see which part is changing to change track number. 0x31 is hex for a 1, 0x32 is a 2 and so on up to 0x39. 0x30 is a 0.

Like I said, I'm no expert and outside of my actual knowledge so it's guess work... Let me know, I'm interested in knowing if I assumed correctly.

Edit: I used the wrong hex for the CR, updated above.

PRO
USA
#15  

If I were to drop the $track in the serial line, just to play a single track, track "0", would the code include the track number with in the "" with play, or outside the "" where you have $track after the comma?

United Kingdom
#16  

Just edited my reply with a bit more info.

Drop the $track and just have it "play 0" or "play 1" where the "play " is...

SendSerial(port, baud, 0x0D, "play 0", 0x0D)

or maybe even

SendSerial(port, baud, 0x0D, "play ", 0, 0x0D)

or use hex

SendSerial(port, baud, 0x0D, "play ", 0x30, 0x0D)

Any is fine. ARC knows a 0 is the decimal so can be outside the quotes or inside the quotes.

Edit: I used the wrong hex for the CR, updated the above.