User/Integer Variable naming and indexing

5 years 2 weeks ago #29531206 by timj0909
Trying to get clarification on user vs script variables in my HBL2360:

I noticed there's room for 1024 integer variables in the controller's memory. Are the user variables included in this count? The HBL23XX documentation doesn't mention "User" variables as being different than "integer" variables.

The Documentation specifies different calls for reading Integer vs User variables--what's the difference between a Microbasic and User integer variable (_MBV vs _VAR)? I.e. do any of them share the same indexes when I try to read them? Can one only be written from the internal script and one written from the outside, but both read from the internal script?

Also then if _MBB reads a Microbasic user variable, how do I map a VarNbr to a name I've used to declare it in the script? I.e. if I have:
DIM myVar as Integer

How would I read the value of myVar from the serial port (assuming using GetValue(_MBB, )?) Also then could I write to myVar? Or do I have to write to a user variable using setCommand(_VAR, index, val) and copy that value to myVar?

An aside as a last question:
There's no way for a microbasic script to see the incoming serial buffer to the controller, is there? It'd be easier if I could just read custom serial text commands rather than encoding the functionality in user variables that I set over serial...

Thanks for the help!

Please Log in or Create an account to join the conversation.

5 years 2 weeks ago #29531207 by TechSupport
So in a nutshell you are asking if a user defined variable is the similar to the VAR variable?

The user defined variables are variables you define and query or preset as either integer or boolean. This data is either gathered or preset.

The Var variables are a location that you set(16 of them). Therefore you can manually assign and change the var values.

dim a as integer means "a" is an integer value.
a = getvalue(_AI, 1) means you are getting a analog input 1 value and storing and assigning it to variable "a".

var 1 = 10 means you have assigned var 1 as a value of 10.

You can also set var 1 as either a or the getvalue.

a = getvalue(_ai, 1)
var 1 = a

or do away with defining a and make your var 1 = getvalue analog input 1.

setcommand(_var, 1, getvalue(_ai, 1))

They are similar, but not the same.

You can send serial data that can change the var 1 value by scripting var1 = getvalue(_var 1). You manually change the value by sending !Var cc nn where cc is the index and nn is the value.

!Var 2 50 means you are changing var 2 to a value of 50. This will override the previous value unless the script makes the value for that index permanent.

User defined ones cannot be changed on the fly.

Please Log in or Create an account to join the conversation.

5 years 6 days ago #29531278 by timj0909
Thanks for the note--I got it all sorted out.

Had a quick question about communication over RS232--my connection isn't working and I'm trying to debug why. I've hooked up pins 2 -> 2, 3->3 and GND -> 5 from the controller to the computer (and only these pins), with no comms coming through. Opening up the USB port, (seen as a com port in Hyperterminal or equivalent) I can get data through, but when I try to open up the actual serial I don't get anything.

So two questions off of this:
1)Is there any interference trying to have serial comms over the RS232 pins (2 and 3) AND serial over USB at the same time? I.e. if I have the controller talking to the Roboteq control software over USB, should I also be able to open up the serial port and talk to the controller? Or does the controller only deal with one communication form at once?

2)Any ideas why my serial may not be working? It doesn't work when I try only serial (no USB). Is there some configuration setting that may be preventing control over the RS232 pins?

Thanks for your help--y'all make a great product.

Please Log in or Create an account to join the conversation.

5 years 6 days ago - 5 years 6 days ago #29531279 by TechSupport
If it is a straight serial RS232 connection between the controller and PC, you have to make sure the communication port is set up and configured properly; refer to user manual for specifics.

Also the other issue could be is that you wired up as null modem connection. Rx to rx, Tx to tx. Therefore nothing happens. You have to swap pins 2 and 3.

The serial and usb can be connected at the same time, however only 1 will actually be selected; RS232 has higher priority over USB. You can select manually at the very top of Roborun+ which comport you are using.

If you use something like hyperterminal, then that would have to be specified manually in your comport set up.

Please Log in or Create an account to join the conversation.

Time to create page: 0.183 seconds