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:
That would play track 0 or the first track. So I wrote a line :
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.
Upgrade to ARC Pro
ARC Early Access will give you immediate updates and new features needed to unleash your robot's potential!
>>The serial port operates at 19.2kbps, 8 data bits,
one stop bit, and no parity.
The port implements
a standard RS232 interface and conversion circuitry may be required to interface to a TTL
serial port (e.g., Basic Stamp or other microcontroller).
And the commands;
If the optional
parameter is supplied, this comm
and sets the current playback mode.
If the mode parameter is not
supplied, this command retrieves the current playback mode
(0:play once, 1:repeat single, 2:
loop all, 3:random play).
play <track number>
This commands starts playback and requires an
argument that indicate
s the number of the
track to play (e.g., the fi
rst track is track zero).
SendSerial(d0, 19200, ">play 0", 13, 10)
or in hex it would be
SendSerial(d0, 19200, ">play 0", 0x0d, 0x0a)
Here is a reference chart for ASCII characters and their respective Decimal or Hex values:
One other thing Will. If you only have one wire connected between EZB and the RX of your device you may need to run a ground wire between the two also. So run it from theground pin of the same Digital port your sending from (use D0) to the control side ground of your serial device. Maybe that will help.
Another option is the hardware has a built in IR controller. So you can send commands with a stardard handheld tv remote control. Sooooo, possible to connect an Ir transmitter of some kind to the EZB? Is there an i2c or other hardware IR device the EZB can control?
Edit 2: Ok i see there is an IR reciever, in i2C folder, can a trasmitter used as well?
I'm sure DJ has way more experience and advice on these methods than I have as I've only really briefly touched on them myself (it's always been on the list of things I need to look at but always been bumped down the list by something else so I'm not 100% clear on ARC's capabilities).
As for the original question, I think everyone else has covered everything I would have said anyway. The only additional thing I would say is, and I don't think it makes a scrap of difference but it's what I did with the TellyMate when I had a few issues, is to break down the data. I suspect doing so must have fixed a syntax error in the data that I hadn't spotted but it may have more to it.
Basically, split the data up a bit more in the SendSerial() command;
SendSerial(d0, 19200, 0x3E, "play", 0, 0x0D, 0x0A)
The data sent should be exactly the same as DJ's example however, like I said, when I had a few issues with the TellyMate doing this seemed to fix them but I am pretty certain it was just really a case of redoing it fixed an error I overlooked. For the sake of a copy and paste it's worth a shot though.
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:
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)
while (kbhit()) //this clears the buffer
putc(32); // space
//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
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
track 2 would be
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.
Drop the $track and just have it "play 0" or "play 1" where the "play " is...
or maybe even
or use hex
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.
OK, taking the other guys code apart piece by piece and converting over to EZ-Script commands we get this;
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.