code issue
BatteryVolts = getvalue(_V, 2)
accel = setcommand(_GO, 1, 500)
if accel = 500
setcommand(_GO, 1, 0)
else
setcommand(_GO, 1, 500)
end if
Courant = getvalue(_A, 1)
print ("Batterie = ",BatteryVolts," Courant = ",Courant,"\r")
wait(100)
I can't run my code because there is a error for line 2 : "No Function named 'setcommand' that takes '3' arguments"
If I delete "accel", I can compile and run my code.
Please Log in or Create an account to join the conversation.
- Griffin Baker
Please Log in or Create an account to join the conversation.
Do you have something else idea for about it ?
Please Log in or Create an account to join the conversation.
- Griffin Baker
BatteryVolts = getvalue(_V, 2)
setcommand(_GO, 1, 500)
if accel = 500
setcommand(_GO, 1, 0)
else
setcommand(_GO, 1, 500)
end if
Courant = getvalue(_A, 1)
print ("Batterie = ",BatteryVolts," Courant = ",Courant,"\r")
wait(100)
Please Log in or Create an account to join the conversation.
The motor 1 is set to go +500 at the start of script. When motor 1 is 500 for a few microsecond (I use a function "wait (50/100)"), immediately I want to stop the script or set Motor at 0.
I don't know what to do.
Could you hep me, please !
Please Log in or Create an account to join the conversation.
- Griffin Baker
A few microseconds is too short. What exactly do you plan to achieve in the few microseconds?
If you give us a better idea of what it is you are trying to do, then writing the code to do what it is that you are trying to do would become easier.
Please Log in or Create an account to join the conversation.
- Griffin Baker
dim Time as integer
dim MotorState as integer
Time = 500 ' 500mS
MotorState = 0
Top:
if MotorState = 0 and gettimerstate(1) = 1
setcommand(_G, 1, 500)
else
setcommand(_GO, 1, 0)
end if
MotorState = 1
if motor state = 1 then terminate
goto top
Please Log in or Create an account to join the conversation.
I want to generate a signal with only one period. Therefore I plan to achieve in the few microseconds.
With a duty cycle = 50 % (setcommand(_GO, 1, 500)), my signal is ON for 25 µs. After 25 µs, it is OFF and script will be stopped.
But my code generates a signal periodic : it is ON for 25 µs, it is OFF for 25 µs and it is ON again for 25 µs...
Please Log in or Create an account to join the conversation.
- Griffin Baker
If you are using my script, then modify and remove the goto statement as it causes the script to loop over and over.
Please Log in or Create an account to join the conversation.
Griffin Baker wrote: Based on your previous code since no other directions were given. This is also not tested.
dim Time as integer
dim MotorState as integer
Time = 500 ' 500mS
MotorState = 0
Top:
if MotorState = 0 and gettimerstate(1) = 1
setcommand(_G, 1, 500)
else
setcommand(_GO, 1, 0)
end if
MotorState = 1
if motor state = 1 then terminate
goto top
You declare a variable "Time" but you don't use it in main function ?
Please Log in or Create an account to join the conversation.