loading
 
open COM ports in VBScript Program
iand  [10 posts]
16 year
Hi,

I tried to read data from COM1 RS232 with the serial module. Attached to the COM port is a sensor which is able to send either ASCII or binary data. I can access the sensor via the hyper terminal. The sensor is broadcasting data permanently. However, with the serial module I was failing to read data. Data are sent in a way x = ..  y = .. (this is what I can see on the hyper terminal).

I was successful in connecting the port with the serial module, buy if I am declaring variables like x and y I get no results. Maybe the sensor is broadcasting its data to quick (100 Hz). I was switching the type of data coming from the sensor from ASCII to binary output but this wasnt helpful.

Another idea would be maybe to open the port from the VBScript module??

I dont know how to proceed.

Any ideas would be great!!

Many thanks

iandi


Frank Zhao from Canada  [6 posts] 16 year
are you using GetVariable?

x_in_vbscript = GetVariable("x_in_pipeline")
iand  [10 posts] 16 year
Frank, many thanks for your quick reply.

I did know


SetVariable("x_in_vbscript"), x_in_vbscript
SetVariable("x_in_pipeline"), x_in_pipeline

x_in_vbscript = GetVariable("x_in_pipeline")


in the VBScript module


and

[x_in_pipeline]

in the serial module.


The value for [x_in_pipeline] showing in the VBSCript module is still 0.

I am doing something wrong here I know but I dont know how to proceed.

Many thanks again

iandi
iand  [10 posts] 16 year
Just to add this:

When I write in the serial module

[x_in_pipeline][y_in_pipeline]


I get the error message


Delimiter ] missing in receive sequence!

Anonymous 16 year
iandi,

The technique used in the serial module requires that you match what is being sent with what is in the receive sequence for things to work. Thus if you are seeing

x=100 y=234

for example in hyperterminal and want to grab JUST the numbers into RoboRealm variables you would use

x=[x_var] y=[y_var]

essentially you replace the numbers with variables. Note that this should be placed in the receive sequence.

The reason for the error above is that you did not show RR how to know when the first variable ended and the second one begins. The code above is attempting to match

100234

but because they are all digits is the correct parsing

10 0234

or

1 00234

or 1002 34

??

I.e. you need something inbetween the two numbers (a delimiter) that tells when one number ends and another begins. If you are dealing with binary numbers then the delimiter is not needed as binary numbers normally have a fixed 1, 2 or 4 byte length.

Also, be sure to download the most recent copy of RoboRealm as we did have an issue last week in the receive sequence ... if no data was in the send sequence then the receive sequence did not even execute. This has been fixed and might be part of your issue.

FYI, there is no way to open a COM port in the VBScript module that we are aware of. Thus the reason for the serial module to exist.

STeven.
iand  [10 posts] 16 year
Hi STeven,

many thanks for your quick reply.

After downloading the newest version of RR I tried now the following:

Defining variables in the VBScript module:

SetVariable("x_var"), x_var
SetVariable("y_var"), y_var

Then writing

x=[x_var] y=[y_var]

into the receive part of the serial module.


I still cannot see data in the VBScript module.

The format of the numbers shown in the hyper terminal is e.g.

X= 0.266 Y= 0.382  (ASCII mode)


Is there anything obvious Im still doing wrong??

Many thanks!!

iandi

iand  [10 posts] 16 year
BTW I tried to change    

x and y     to     X and Y

as the hyper terminal is showing captitol X and Y, but this didnt change anything..
Anonymous 16 year
iandi,

You don't need to define the variables. In fact we're not even sure what

SetVariable("x_var"), x_var

does as it would normally be

SetVariable "x_var", 0.266

which will "hardcode" the variable to x_var. Try removing the VBScript module for now and see if the values change. The way you currently have it it will always set those variables to 0.

Can you also include your robofile if things still do not work? That helps us to debug.

STeven.




iand  [10 posts] 16 year
Hi STeven,

many thanks for taking care.

I took out VBScript.

Please find attached the robo file. Also, if that helps, I have attached the hyper terminal file.

I am taking the RR watch_variables for looking if the values are changing, correct?

Many, many thanks

iandi

iand  [10 posts] 16 year
sorry, I tried to attach the robo file as an jpg ;-)) now its attached
program.robo
Anonymous 16 year
iandi,

Yes, the watch should show when those variables change.

You may need to add a <lf> or <cr> at the end of the receive sequence to deal with the newline character that I assume is at the end of the receive sequence.

But that should do it ...

If not can you paste in what hyperterminal sends back and we'll continue testing here.

STeven.
iand  [10 posts] 16 year
Hi STeven,

I added first  <lf> and then  <cr>  but this doesnt change anything.

Below there is what hyperterminal sends back

Best wishes

iandi



X=-0.104 Y= 0.197 Z=-0.950
X=-0.104 Y= 0.182 Z=-0.955
X=-0.096 Y= 0.179 Z=-0.976
X=-0.101 Y= 0.176 Z=-0.968
X=-0.109 Y= 0.179 Z=-0.968
X=-0.116 Y= 0.182 Z=-0.968
X=-0.109 Y= 0.169 Z=-0.968
X=-0.101 Y= 0.166 Z=-0.979
X=-0.101 Y= 0.189 Z=-0.958
X=-0.096 Y= 0.176 Z=-0.958
X=-0.114 Y= 0.200 Z=-0.968
X=-0.119 Y= 0.189 Z=-0.950
X=-0.124 Y= 0.174 Z=-0.958
X=-0.106 Y= 0.176 Z=-0.971
X=-0.104 Y= 0.166 Z=-0.955
X=-0.119 Y= 0.169 Z=-0.968
X=-0.109 Y= 0.169 Z=-0.958
X=-0.119 Y= 0.184 Z=-0.968
X=-0.121 Y= 0.187 Z=-0.976
X=-0.114 Y= 0.187 Z=-0.968
X=-0.104 Y= 0.179 Z=-0.968
X=-0.116 Y= 0.197 Z=-0.958
X=-0.106 Y= 0.176 Z=-0.968
Anonymous 16 year
Note that space after the Y= in the text that is not in your sequence. Try

X=[x_var] Y= [y_var]

instead and see if that helps.

STeven.
Anonymous 16 year
iandi,

We've just made some modifications to the serial module that will better aid in debugging such as the console log. It will probably be easier if you download the newest version and do your testing using that. In that way you should be able to see the incoming data and be able to modify the receive sequence in order to get the variable matching to work.

v1.8.6.14

STeven.
Anonymous 16 year
Hi STeven,

first of all, I have to say I am amazed by the support you and your team is providing!!!!!!!!!!!!!!!!

I entered the sequence of what I see in the hyper terminal which is

X= 0.007 Y= 0.105 Z=-0.989

however, you can see that the sequence starts with a blank before the X and there is a blank with positive numbers only, as the Z value shows, there is no space between the Z and the negative number following. So I am not quite sure about the spaces now.

Also, I was not able to see incoming data in ASCII mode.

I have attached the robo file as well.

When I change the modus of the sensor itself to binary output and hit then the "Send Now" button in the console area, I get the following

Connected!
\255


Many thanks

iandi
program.robo
Anonymous 16 year
iandi,

Thanks for sending the robofile.

We have once again updated the system. Please download v1.8.6.15 which includes some minor updates to the serial module.

We noticed that the device you are using allocates a space just after the = to be used for a minus sign when needed. Thus whenever the number is positive there will be a space and when negative there will be a minus sign. Thus your receive pattern needs to be

either

X=[x_var]Y=[y_var]Z=[z_var]<cr>

or

X=[x_var]Y=[y_var]Z=[z_var]<lf>

the ending is in question. Some devices return \r\n while others return either one. We cannot tell which from your posting.

Note that there are NO spaces in that pattern either within it, before it or after it. That is needed since the spaces within your sequence are optional.

Also, you should see the data within the console log in red. If you do not check your baud, port, etc. If you don't see the text in the console the receive sequence will not work as apparently no text is being received by RR at all. So first work on the console issue and then once text is flowing in, add in the receive sequence.

STeven.
Anonymous 16 year
Hi STeven,

many thanks for the last RR update.

I havent seen anything in RED in the console log but one line which I have pasted here

Module Stopped!
Module Started ...
Connected!
\255\194\154R<cr> (this is written in RED)
Module Stopped!
Module Started ...
Connected!

This was when it was neither in the ASCII nor in the binary mode, it was a 3rd mode called "Raw Mode".

In the hyperterminal once the sensor is in raw mode there is the following output

X=0x01D9 Y=0x0239 Z=0x0088

iandi
Anonymous 16 year
iandi,

Ok, lets back up a minute. Do you intend to run the device in Raw mode or can you set it to ASCII mode and try RR with that?

Also what is the device that you are communicating with? Knowing that might help us understand the signals coming from that device a little better.

For example, now the output appears to be in Hex as apposed to a decimal (base 10) number. Is that something you did? Would you need to convert that to base 10?

STeven.
Anonymous 16 year
STeven,

basically for me its ok either way (running either in raw mode or ASCII or binary). I just played with the modes because I was hoping that this might chance something.

The device is an accelerometer and there is an example application available at

http://www.sparkfun.com/datasheets/Sensors/SerialAccel-Control-Example.zip

With the hyperterminal you can change the mode (raw, ASCII, binary).

Have a great weekend and many thanks

iandi
iand  [10 posts] 16 year
Hi STeven,

I hope you are fine.

Do you had a chance to look deeper into this topic? Would be great, if you could provide a small update if you have any news.

Best wishes

iandi
Anonymous 16 year
In case others are reading this, it turns out to have been an issue with the DTR signal in the serial module. RoboRealm sets this to false (disabled) by default. With the new addition to the serial module the DTR flow control can be enabled. Seems like that did the job!

STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index