Asked — Edited
Resolved Resolved by thetechguru!

Working With Serial Terminal &Amp; System Variables

I have a device that is sending information in on a serial port. I want to evaluate the incoming string then if it = a specific value to set a system variable. Something like this:

If the serial input = "MOTION" then system variable Motion = "1"

Thanks. :)


ARC Pro

Upgrade to ARC Pro

Experience the transformation – subscribe to Synthiam ARC Pro and watch your robot evolve into a marvel of innovation and intelligence.

#1  

You need to use one of the 3 UART ports on the ezb4.... In ARC there is an example on how to use the UART port for reading data...

#2  

I have the port connected and I can see the incoming input. I just need to read it and evaluate it. I have been looking for that info, but it eludes me.

User-inserted image

#3  

In the Script Syntax examples installed with ARC, open the UART Peripheral example project. It shows how to read UART data into a variable. (add a Variable Watcher object to get a better view of how you would use the data).

Alan

#4  

My input is not from an EZ-Board it is from an old project that I'm trying to integrate it from. My input is not from an EZ-Board it is from an old project that I'm trying to integrate it from. The old project puts info in to the serial from a USB. I can get ARC to see the port in serial terminal. What I found in the Talks about getting it from the EZ-B4. But I need to get it from the computers serial on a USB port. If this makes any senses.

#5  

If I understand, you have something connected to the comm port of your PC and want to read the data into a variable in ARC rather than connecting to the UART port on the EZ-B?

There are no script commands to support that at this time.

Do you know how to program in .NET? If so, you can write a simple serial reader that uses the EZ-B SDK to write data to an EZ-B variable.

Other options are (again, through some coding) writing to a file and using the readfile functions, writing to a web page and using the http functions, enabling the TCP terminal and sending from an app via TCP/IP socket (telnet) to the script interface, probably more I am not thinking of, but all would involve some external code.

What was the original application? do you have the source code, or documentation of what it can do with the data?

Alan

#6  

Well, hold on a second. There is no specific Read command for PC serial.

Buttttttttttttttttttt (that's a big BUT)


:loop

$x = GetControlValue( "Serial Terminal", pause )

print("Received: " + $x)

sleep(1000)

goto(loop)

The GetControlValue script option might, maybe, possibly, (don't hold your breath) work. This at least ran for me, but I don't have anything to read from a serial port on my PC, so, I'm not sure. If you look up GetControlValue in the script manual, in the example you'll see "pause" is the condition it was looking for...how that would work for what is incoming in the serial terminal I am again not sure.

#7  

Interesting. I totally missed GetControlValue. I wonder if I can find any serial devices around the house. Used to have some, but I think I traded them all for robot parts or threw them away (hmm... do any of my PC's even still have a serial port.. I am sure one of them does).

That might just work.

Alan

#8  

Never mind, that does not work. In order for it to work, it too must include script commands that are recognized. "Pause" appears to be hard coded to work with anything, even "Serial Terminal" which has no GetControlValue parameters.

I would like having this feature myself. But, rather than waiting on it to be added (maybe) to ARC, one option is to use an external application custom made to pass the value onto ARC. OR, if your device has an option to send data via UDP....like with an IP address, ARC does have a scripted function for that.

If you are reading motion...is that from a motion sensor? Perhaps an alarm or security system?

#9  

Welp that would explain why I cant find it. BUMMER. I have a large Arduino based program. Ok I have several to tell the truth. I have a full scale R2-D2 that is Arduino based. The Arduino's pas information back and forth via Serial ports. I was thinking I could add the EZ-B4 to the existing "systems" without complete rewiring of my droid. I thought ID do a test or proof of concept first. So I set up an Arduino UNO with a PRI sensor. The Arduino sends motion and time between motion detected out on the USB / Serial. I got the Serial Terminal in ARC to display the info that the Arduino is sending. I just wanted to look at each line and look to see if it matched a code then set a system variable accordingly. The current Arduino system sees a condition having been met ( say The command for turning on the view screen has been received) and sends out a code like 8999 from the main Arduino in the body to the Arduino in the head. When the main Arduino in the head sees the code 8999 come over the serial it then turns on the view screen.

In short I was hoping to more easily integrate the EZ-B4 into my existing systems. I have many systems that R2 can do many things by him self. He will look in the direction where he sees motion, talk when hearse you talk. But I can see how the EZ-B4 could really improve his ability's. A total re wire... well ummm..... The below picture may put this into perspective.

Richard R. and Thetechguru and JustinRatliff Thanks for your help. :)

User-inserted image

#10  

Wow! that's a whole fricken' computer back there in your R2... Serious electronics skills, dude... :)

#11  

Here's a picture of my current project's guts.... My 75% finished inMoov....

User-inserted image

#12  

You could continue to use the Arduino as an intermediary. Instead of connecting the serial port to the computer, you connect it to one of the UARTs on the EZ-B and then use the UART script commands to receive (and if needed send) the data.

Take a look at this thread where Luis interfaces to an Arduino to drive an LCD display. Sending instead of receiving data, but concepts are similar and would certainly work (if you look at his other posts, I think he has done some 2-way integration with another device too).

https://synthiam.com/Community/Questions/6577

Here is a thread where Luis hooked up several ping sensors and a compass to an Arduino and is reading the data into the V4 using the UART port.

https://synthiam.com/Community/Questions/6491

Alan

#13  

thetechguru ,

Thanks I'll look into that. Sounds like the way to go.

Richard R,

Nice robot. I love those hands, did you make them?

#14  

@Slee The Sloth... It's the inMoov project.... you download (litterly hundreds and hundreds of parts) the STL files and print them on a 3d printer.... When it's all said and done it will probably over 600hours of printing...

you can have a look here inMoov project if you're interested...

#15  

Richard, Would you consider a new thread for Inmoov and document a little of what you have done. I've just started and want to ask you questions but don't want to hijack this thread. Did you put arduinos in the arms? I see the EzB in the back. I'm amazed at how quickly you have built this.

#16  

@Checksumff No worries happy to answer some questions for you... There are also a couple of other guys on here who have built inMoovs and can help as well... So start another thread for yourself and ask a way... Quickly to answer your question, though... I am not using any arduinos in my inmoov... Just one EZB4 and a lynxmotion SSC-32 serial servo controller (for the hands and wrists... everything else is driven directly from the ezb4....

Cheers :)