Various MicroBasic questions

6 years 4 months ago #29532914 by maple
1) For commands accepting channel bits in the parameter (like _DOA, _AINA etc.) is there difference between
setconfig(_DOA, 1, 0)
setconfig(_DOA, 1, 0 + 16 + 32)
for "no action" configuration?

2) Is there command to invert motor direction, something similar to setconfig(_APOL, 1, 1). I can do this in configuration tab but could not find corresponding command ID.

3) If booleans must be declared, shouldn't this produce error?
myvar = true
I mean, I don't really mind the simplicity of declaring "pseudo-boolean" flags this way, and they do work in "if" statements as expected. What I really would like to see is MicroBasic compiler to recognize this statement as creation of boolean variable, since it is clear that boolean literal is used as initial value.

4) I am really missing array literals. When the script needs couple hundred of values stored in an array it becomes unmanageable.

5) MAC parameter is said to have range 50..300000, AC parameter is 0..500000. Why the difference? Same with MDEC and DC.

6) MXTRN is said to take value multiplied by 10, however profile saved on disk seems to have multiplier 100.

7) Controller does not accept !MS command without parameter (from documentation it is optional). It accepts !MS cc, but it does not work as documented.
The current command is interrupted, and in Relative Position mode it is even replaced with last known position (nice touch, by the way!)
However any new command (e.g. !G) will be executed. Documentation implies that controller should not execute any commands until it receives !MG.
The following user(s) said Thank You: blake, Erik

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

6 years 4 months ago #29532919 by blake
Replied by blake on topic Various MicroBasic questions
First of all let me express my gratitude to you, it is not very often that we get a customer that gives us such excellent an thorough feedback! Many of these issues we cannot be aware of unless they are reported to us so we are truly thankful for you informing us of these things so that we can correct them!

Now let me answer your questions in turn:

1)There is no difference. In fact using the bit number (16 & 32) is now redundant in our modern controllers. You can now execute the command and exclude the motor channel bit number. eg _DOA, 1, 6 will activate digital output 1 when there is no mosfet failure. I will add this to our User Manual Errata promptly.

2) Yes there is a command to do this, I'm not sure how this was left out of our user manual but again I will add it to the Errata. The command is as follows:
^MDIR cc nn

Where:
cc = Motor Channel
nn = 0: Not inverted
1: Inverted

3) You will only receive an error if you have Option Explicit at the top of your script. This will force you to declare your variables, in which case this would have produced an error if "myvar" was not declared using dim myvar as boolean. If Option Explicit is not used than any undeclared variables will still not produce an error.

4) Thank you for the suggestion we will look into adding this

5) This is an error, both should be the same and in fact these numbers aren't quite correct for modern controllers either. The full acceleration and deceleration range will be 0.1 - 50,000 RPM/s. This is the range you can enter into the Configuration menues. If giving the command via script it will be this value x10 so 1 - 500000. I will add this correction to the errata

6) You are correct, it should have a x100 multiplier. This is a typo, I will add it to the Errata.

7) I understand that the documentation is not completely clear. Although simple in concept, !MS is sort of a complicated command when taking into consideration all of the operating modes of the controller. We will need to investigate this one further to ensure that !MS gives a consistent action in all operating modes.
The following user(s) said Thank You: maple

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

6 years 4 months ago - 6 years 3 months ago #29532928 by maple
Replied by maple on topic Various MicroBasic questions
I'll keep it here then:

8) Timer functions (e.g. SetTimerCount) seem to accept timer index 0-3, not 1-4 as per documentation (online and downloadable)

9) The description of ?CL command is confusing.
In the general information: "Within each 32-bit word are 8 groups of 4-bits", implying one number represents 8 nodes (4-bit word per node);
However later: "bits 4-7 of second number is for node 5", and in the reply description: "4 words of 4 bits", i.e. one number represents 4 nodes.
This also corresponds to mm parameter: "nn = 1 : nodes 0-3".

After some experimentation it looks like ?CL 1 returns in fact 8 nodes, for example with nodes 1,3 and 4 present the response is 69649, which is 0x00011011

10) Controller SDC2130, hardware version 2.1, firmware 1.7. The explanation in the datasheet says: "Analog input 1 has been moved from pin 10 to pin 4", however it is still on pin 10, and pin 4 has analog input 5.

11) If more than 3 SetCANCommand() called in a row only first 3 work. In the following example VAR 4 will not be delivered to other nodes.
setcancommand(0, _VAR, 1, 11)
setcancommand(0, _VAR, 2, 12)
setcancommand(0, _VAR, 3, 13)
setcancommand(0, _VAR, 4, 14)
There is no mention of this in the documentation. Inserting wait(5) between the calls fixes the problem, which hints at some kind of congestion issue.
Is this a limitation of the CAN implementation or CAN speed? Can it be solved by increasing network bit rate? The code above was tested with bit rate 250 kbit/s.

12) From documentation: "The local node, however, will not be reached by the broadcast command". In my experiments broadcast commands as above do set local node variables.

13) It seems in Position Tracking mode !AC and !DC work, however instead of setting acceleration and deceleration they set maximum speed. Furthermore, they do it in strange way - AC sets speed before passing 0 feedback, DC sets speed after. Considering that 0 has no special meaning in position mode this is very strange behavior.

Note that I am actually glad I found this - I was looking for a way to control speed in Relative Position mode and did not find any. !S does not work without encoder. This at least gives me an alternative. What I worry about is if this is a bug and it gets fixed later then code will stop working.

14) Right-shift operator >> works differently in Simulator than on actual device. In simulator it propagates sign bit as expected, on device it does not.

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

6 years 3 months ago #29532972 by niko
Replied by niko on topic Various MicroBasic questions
8) You are right, there is an issue here. The correct reply is 0-3. We will modify documentation acccordingly.
9) "bits 4-7 of second number is for node 5" is a typo in documentation.
10) This was an problem that was fixed. But when updating from previous than v1.7 version the problem is inherited. In order to fix and since you have SDC2130 do the following in console tab:
^leg 16
%clsav 321654987
%reset 321654987
11) CAN peripheral in MCU has a FIFO buffer for transmiting that can hold up to 3 messages. Thus sending for messages at once makes the FIFO full and discards the fourth message.
12) You are right. This is an inaccuracy in documentation. It will be fixed.
13) section "Position Tracking Mode" p.121: "This mode is identical to the Position Relative mode in the way that commands and feedback are evaluated. However, the controller will move the motor simply using a PID comparing the command and feedback, without controlled acceleration and as fast as possible."
14) Thank you for the feedback. This is a bug we had not detected before. If you want a beta with that fixed send us an e-mail in This email address is being protected from spambots. You need JavaScript enabled to view it..

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

6 years 3 months ago #29532974 by maple
Replied by maple on topic Various MicroBasic questions
Re #13:
Yes, but what "as fast as possible" means? The point I was trying to make is that in Position Tracking mode commands !AC and !DC work and they set maximum speed, instead of acceleration/deceleration.

My question was - is this intentional behavior or a bug? I need a way to control maximum speed on the fly. If this is a bug and it will be fixed in the future then my code will stop working.

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

5 years 10 months ago #29533305 by Erik
Replied by Erik on topic Various MicroBasic questions
Is this all fixed now? I'm also willing to use all these functions but not if there's many bugs in it.

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

Time to create page: 0.070 seconds