Welcome to Synthiam!

Program robots using technologies created from industry experts. EZ-Builder is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.
Get Started

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

United Kingdom
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. EZ-Builder 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.
Well those all look like they would work, but I still got nothing. I'm going to make sure all the hardware is connected correctly. With the ttl converter. I also want to see if i can get the new serial wi fi terminal to work to make sure the hardware is connected right. When I run the RS-232 to USB to the computer is works just fine. So I know everything is right upto the ttl converter.
United Kingdom
I'll look again in a bit, I have to admit I was feeling like death warmed up last night and know I made a few errors (which I think I corrected last night). I'll sit down with a coffee and have a proper read of everything and see what I can figure out.
Thanks Rich, no rush. Hope you are felling better.
United Kingdom
Nothing keeps me down for long. I expect it's just a mild case of exhaustion, nothing too serious:)

OK, taking the other guys code apart piece by piece and converting over to EZ-Script commands we get this;


SendSerial(D0, 19200, 0x0D) # Send a CR
Sleep(100) # Pause for 100ms
SendSerial(D0, 19200, 0x70) # Send the letter p
Sleep(10) # Pause for 10ms
SendSerial(D0, 19200, 0x6c) # Send the letter l
Sleep(10) # Pause for 10ms
SendSerial(D0, 19200, 0x61) # Send the letter a
Sleep(10) # Pause for 10ms
SendSerial(D0, 19200, 0x79) # Send the letter y
Sleep(10) # Pause for 10ms
SendSerial(D0, 19200, 0x20) # Send a space
Sleep(10) # Pause for 10ms
SendSerial(D0, 19200, 0x30) # Send a 0 (his code used a random track this uses track 0)
SendSerial(D0, 19200, 0x0d) # Send a CR

That's a lot of lines for not very much. It may be that those 10ms delays between each character being sent are important so I'd try that one first.

To be honest, if the above doesn't work I would concentrate on checking the wiring is OK since, at least in theory, the above is pretty much the same as his code.

If that works we can look at condensing the code to something a little less overwhelming and easier to work with. i.e. SendSerial(D0,19200, 0x0d, "play 0", 0x0d) which it seems is what I come up with yesterday...

Going back over older posts, the above is pretty much what DJ suggested to start with (but with the exclusion of the > before the play command and a carriage return before the command).

Try the long code with the sleeps. If that doesn't work then it's a case of triple checking the wiring.
Thanks Rich! I'll give it a try tonight! Get some rest;)