Setting Acceleration and Deceleration in MicroBasic

5 years 7 months ago #29530172 by Trainee
Hello,

I am starting to learn MicroBasic to control a three phase dc brushless motor using HBL1650. I wrote a simple script just to make the motor turn when I pressed the 'run' button. But I can't seem to be able to modify the acceleration and deceleration of motor using MicroBasic. Here is my script :

SetCommand(_S,1000)
SetCommand(_AC,1000)
SetCommand(_DC,1000)
a=10
while a>0
SetCommand(_GO,1000)
End While

I have tested the script and saw that the motor still accelerates and decelerates using the values in the configuration page. Is there any flaw in this script? Any ideas for improvisation? Can someone help me out here please?

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

5 years 7 months ago - 5 years 7 months ago #29530173 by TechSupport
In closed loop speed mode, the setcommand(_S, 1000) is telling the motor to go to speed 1000. Then you have a setcommand_GO, 1000) which is the go command, which is telling the motor to go to full speed +1000 motor command. The 2 commands are conflicting with each other.

If you are trying to set max speed rpm, you would use setcommand(_MXRPM, 1000)
The following user(s) said Thank You: Trainee

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

5 years 7 months ago #29530174 by Trainee
Ok thank alot!

By the way, is it possible to configure the operating mode (open loop mode, closed loop speed mode, closed loop position relative mode etc) using MicroBasic as well? I can't seem to find the command in the MicroBasic section in the user manuel.

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

5 years 7 months ago #29530175 by TechSupport
Yes.

setconfig(_mmod, cc, nn)

where cc = motor channel
nn = value

For single channel controllers, the cc may not be necessary.

setconfig(_MMOD, 0) would be set to open loop mode.

dev.roboteq.com/dev1/index.php/datasheet...-nextgen-controllers

See section 16 (Page 163) of the user manual for more references.
The following user(s) said Thank You: Trainee

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

5 years 7 months ago #29530176 by Trainee
Thanks again!

By the way, the motor still not accelerating and decelerating following the value that I put in the MicroBasic script. I have tried SetConfig(_MAC) and SetCommand(_AC) for the acceleration but the motor still accelerates with the preset value in the configuration page. What's the difference between these two commands anyway? Can you help me out again please?

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

5 years 7 months ago - 5 years 7 months ago #29530177 by TechSupport
You can always query to see if that value has actually changed. The best way to do this is the following. forget the script for the time being and try with serial commands.

In the console tab, do the following.

Disable watchdog timer

^rwd 0

Send the actual speed command that you want. So 2000 rpms example.

!S 2000

Clear buffer history, and then query the acceleration parameter. Have it read back every 500mS. The "_" acts as a carriage return allowing you to execute more than 1 command in 1 single line.

# C_~AC_# 500 or try #C_?AC_# 500

While all that is running, the data should populate in the console tab. Then you can make changes to the parameters as needed. !AC nn. If the return answer is + then command was accepted. If it returns a -, then it was rejected.

An easy way to see what the command issued to the accel and decl, is to make the changes in value in the configuration, save to controller, and then go to the console tab to see what commands were issued to set those values.

If a "!" is used, then it is setcommand(). If "^" is used, the it is setconfig().
The following user(s) said Thank You: Trainee

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

5 years 6 months ago #29530255 by Trainee
I tried out the code that you suggested but from the clear buffer history step onwards it doesn't work anymore. There aren't any data that populate in the console tab. It shows a "-" sign. Why is that so?

I tested the telemetry string code from user manuel page 198 but it doesn't work either. It shows a negative sign too.

I have attached a printscreen here.

Can you help me out please?

File Attachment:

File Name: Roboteqconsole.zip
File Size:50 KB
Attachments:

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

5 years 6 months ago #29530256 by TechSupport
The telemetry string doesn't work and it hasn't been fixed(likely never will). A script can be written to do the exact same function in its' place.

The clear buffer history is

# C

If no space is used, then the reported echo is a "-".

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

Time to create page: 0.134 seconds