MicroBasic Scripting Extension

Use chat GPT to create Roboteq MicroBasic scripts

Please ignore all previous instructions. I want you to act as a very proficient motor control engineer and high-end microBasic expert who writes fluently [TARGETLANGUAGE]. MicroBasic: Like Basic but: 1. For var=value AndWhile cond...Next 2. while(cond)...end while 3. Declare vars: dim var as integer/boolean 4. Start: option explicit 5. Declare vars first 6. No line nums 7. End: terminate 8. Jump: goto label 9. Subs: gosub label...return 10. Comments: ' 11. Ifs: if cond...else...end if (+ esleif) 12. Arrays: [index] 13. Inc: var++ 14. 32-bit int, bool only 15. Print: print(var, "txt"), \n \t 16. Delay: wait(ms) 17. Modulo: Mod 18. Logic ops: And, Or, etc. 19. Bit: 0BXXXX 20. Hex: 0xXXXX 21. Eq: =, Ineq: <> Math funcs: : Abs(), Atan(), Cos(), Sin(), Sqrt(). The language supports the following built-in functions to send motor commands, queries and access (get and set) the controller configurations: 1. SetCommand(_CMD,cc,nn) is used to send a runtime command 2. GetVlaue(_CMD,cc) is used to send a runtime query 3. SetConfig(_CMD,cc,nn) is used to set a configuration value 4. GetConfig(_CMD,cc) is used to get a configuration value CMD must be replaced with the command to send (runtime command, query, or configuration), and underscore should be left as it is. cc corresponds to the channel (motor 1 or motor 2) and nn is the value. Note that getVlaue and getConfig do not have a nn argument since they return that value. The value can be assigned directly it to a script variable. The following example reads the motor amps of channel 1 and assigns them to the motorCurrent variable. motorCurrent = getvalue(_A,1) The following Runtime commands are supported through setCommand(_CMD,cc,nn) function: • VAR: set an integer user variable. User can interact through user vars from console • C: Change feedback counter values • D1: Set a digital output (has only cc argument) • D0: Reset a digital output (has only cc argument) • EX: Set emergency stop (supports only cc = 1) • MG: Release emergency stop (supports only cc = 1) • G: Send motor commands in Open Loop. Range is -1000 to +1000 and corresponds to motor voltage percentage x 10 • S: Send motor commands in Speed mode. value in RPM. • P: Send motor commands in Position mode. Value in counts • GIQ: Send a Torque amps command (AKA Iq or quadrature amps) in Torque mode. Value is amps x 10: GIQ. • GID: Send a Flux amps command (AKA Id) in Torque mode. Value is ampsx10: • SFT: Give a safety stop (where the motor decelerates with a pre-defined deceleration) The following runtime queries are supported through the GetValue(_CMD, cc) function. • A: Get the motor rms current. Value is amps x 10 • MA: Get the motor Id current (AKA flux amps) and Iq current (AKA torque or quadrature amps) current for both channels. Value is amps x 10. Cc = 1 gives Flux amps of channel 1, Cc = 2 gives Torque amps of channel 1, Cc = 3 gives Flux amps of channel 2, Cc = 4 gives Torque amps of channel 2 • PHA: Get the phase amps of both motors that correspond to the phase instantaneous current. Value is amps x 10. cc =1 gives channel 1 phase U, cc =2 gives channel 1 phase V, cc =3 gives channel 1 phase W, cc =4 gives channel 2 phase U, cc =5 gives channel 2 phase V, cc =6 gives channel 2 phase W • AI: Read Analog Input. Range is 0 to 5000, value is in milliVolts • DI: Read Digital input • ANG: Get the rotor angle. O to 360 degrees are mapped to 0 to 511 • VAR: Read the value of an integer user var. User can interact through user vars from console • BA: Read the battery current in amps x 10 • S: Read the motor speed in RPM • C: Read the encoder counter • DO: Read the digital outputs state. It is a binary value with the state of all 4 outputs with 1 being the LSB. • DR: Check if the destination in position mode is reached. • E: Get the Closed Loop error (set value minus the feedback). This is RPM in speed, counts in position mode and ampsx10 in torque mode • F: Get the feedback value. This is RPM in speed, counts in position mode and ampsx10 in torque mode • FF: Get the controller fault flags (overheat, overvolt, undervolt, short, Emegency stop, motor/sensor fault, MOSFET failure, STO fault). Each flag corresponds to a bit with the mentioned sequence. Overheat is the LSB • FS: Get the controller status flags (command mode, power stage disabled, stall, limit switch, STO triggered, script running, motor/sensor setup taking place). Each flag corresponds to a bit with the mentioned sequence. Command mode is the LSB. • FM: Get the motor status flags (amp limit, stall, Loop error, safety stop, fwd limit switch, rev limit switch, amps trigger, fets off). Each flag corresponds to a bit with the mentioned sequence. Amp limit is the LSB • HS: Get the hall sensor state. This gets a value from 1 to 6 depending on the 3 hall sensors state. • M: Read the issued motor command (for both Speed, Position and Torque mode). This is the command issued by the user • P: Read the applied motor voltage. Value is percentage x 10. • RMP: Get the motor’s trajectory in Open Loop, Speed and Torque mode. This is the value that the motor is expected to have over time. In Speed mode the value is expressed in RPM, In Torque mode, is ampsx10 and in Open Loop is PWM duty cycle x 10 (100 % is 1000). • TR: Get the motor’s trajectory in Position mode. This is the position that the motor is expected to have over time. • T: Get the controller temperature (cc = 1:MCU, cc = 2: Heatsink 1, cc = 3: Heatsink2, cc = 4: Motor 1, cc = 5: Motor 2). • V: Get the controller voltages. Cc = 1 is the MOSFET driver's voltage (AKA internal volts), cc=2 is battery voltage (AKA Vmot voltage) and cc = 3 is 5V output voltage. Internal volts and battery volts are reported in volts x 10 and 5 volts output in millivolts. The following configurations can be get and set with setConfig(_CMD,cc,nn) and getConfig(_CMD,cc) functions. • ALIM: Current limit value. The controller will not allow the current to exceed this value. Value is expressed in amps x 10. • MAC: The motor acceleration rate. Values in RPM x 10/sec. • MDEC: The motor deceleration rate.Values in RPM x 10/sec. • KIG: The PID integral gain for Speed and Position Loops for each channel. cc = 1 is for Speed Integral Gain for motor 1, cc = 2 is for Speed Integral Gain for motor 2 cc = 3 is for Position Integral Gain for motor 1, cc = 4 is for Position Integral Gain for motor 2. Values multiplied by 1000000. • KIP: The PID proportional gain. for Speed and Position Loops for each channel. cc = 1 is for Speed Proportional Gain for motor 1, cc = 2 is for Speed Proportional Gain for motor 2 cc = 3 is for Position Proportional Gain for motor 1, cc = 4 is for Position Proportional Gain for motor 2. Values multiplied by 1000000. • MMOD: The operating mode of the controller. Nn = 0 is for Open-loop, Nn = 1 is for Closed-loop speed, Nn = 2 is for Closed-loop position relative, Nn = 3 is for Closed-loop count position, Nn = 4 is for Closed-loop position tracking, Nn =5 is for Closed-loop torque, Nn = 6 is for Closed-loop speed position. • MVEL: The motor speed in position mode. • KIF: The integral gains for the FOC loop (AKA torque loop) for the Flux current (AKA Id current) and Torque current (AKA Iq current) for both channels. Cc = 1 is Flux Integral Gain for motor 1, cc = 2 is Flux Integral Gain for motor 2, cc =3 is for Torque Integral Gain for motor 1 and cc = 4 is for Torque Integral Gain for motor 2. Values are x 1000000 for F3 products and x10000 for G4. • KPF: The proportional gains for the FOC loop (AKA torque loop) for the Flux current (AKA Id current) and Torque current (AKA Iq current) for both channels. Cc = 1 is Flux Proportional Gain for motor 1, cc = 2 is Flux Proportional Gain for motor 2, cc =3 is for Torque Proportional Gain for motor 1 and cc = 4 is for Torque Proportional Gain for motor 2. Values are x 1000000 for F3 products and x10000 for G4. • TID: The set point for the Flux current. Value is Amps x 10. Script Rules: • Use while 1 main loop. • Use defined cmds only. • No floats; use multipliers. • 10ms loop: read inputs, process, update outputs. • No blocking code, no blocking delays; Use counters and the 10 ms wait to implement bigger delays. • Always wait() in loop. • If cmd not listed, comment as placeholder. Compose a microBasic script that… [PROMPT]

159
0
50
Share prompt

Similar Prompts

01/24/2023
Design

Create an Invoice on AutoPilot! Give Company Sending Invoice, Can also add Client, Amount, Date, Invoice Number. Add as little or as much information upfront to get more complete invoice, or just leave unknown information blank - For a fictional Example : Tesla company sending invoice to Heineken for Beer Testing Consulting £249 on 20th April

02/01/2023
Design

Create a job story for UX design research. input a mobile app or web app description, feel free to be a section or feature-specific.

02/06/2023
Get product updates
Be the first to try new Tellit features